Skip to content

Commit

Permalink
Merge pull request #291 from kirillkurko/vercel-kv-migration
Browse files Browse the repository at this point in the history
Migrate to vercel/kv
  • Loading branch information
kirillkurko authored Mar 17, 2024
2 parents a9ef604 + fda3c8b commit 3b6bff0
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 260 deletions.
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
"dev": "next dev",
"build": "contentlayer build && next build",
"start": "next start",
"lint": "next lint",
"seed": "node prisma/seed.js",
"postinstall": "prisma generate"
"lint": "next lint"
},
"dependencies": {
"@prisma/client": "5.10.2",
"@tailwindcss/typography": "^0.5.10",
"@vercel/analytics": "^1.2.2",
"@vercel/kv": "^1.0.1",
"@vercel/speed-insights": "^1.0.10",
"babel-runtime": "^6.26.0",
"clsx": "^2.1.0",
Expand Down Expand Up @@ -50,7 +48,6 @@
"eslint-plugin-react": "^7.34.0",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"prisma": "^5.10.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2"
},
Expand Down
82 changes: 24 additions & 58 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions prisma/data.js

This file was deleted.

23 changes: 0 additions & 23 deletions prisma/schema.prisma

This file was deleted.

26 changes: 0 additions & 26 deletions prisma/seed.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PageTitle, Paragraph } from '@components/typography';
import AboutCard from './AboutCard';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

interface Feedback {
avatar: string;
Expand Down
10 changes: 9 additions & 1 deletion src/app/blog/[slug]/ViewTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ interface Props {
slug: string;
}

let finished = false;

function ViewTracker({ slug }: Props) {
useEffect(() => {
trackBlogPostView(slug);
if (!finished) {
trackBlogPostView(slug);
}

return () => {
finished = true;
};
}, [slug]);

return <></>;
Expand Down
4 changes: 2 additions & 2 deletions src/app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Mdx } from '@components/mdx';
import { allBlogs } from '@contentlayer/generated';
import { type Metadata } from 'next';
import ViewTracker from './ViewTracker';
import { BASE_URL } from '../../../utils/const';
import { getBlogPostOpengraphImage } from '../../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { getBlogPostOpengraphImage } from '@utils/ogImages';

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = params;
Expand Down
4 changes: 2 additions & 2 deletions src/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { PageTitle, Paragraph, SectionTitle } from '@components/typography';
import ArticlePreview from '@components/ArticlePreview';
import { type Metadata } from 'next';
import { getAllBlogPosts } from '@lib/models/blog';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const metadata: Metadata = {
title: 'Blog',
Expand Down
2 changes: 1 addition & 1 deletion src/app/emoji/Emoji.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import { useState } from 'react';
import { Paragraph } from '@components/typography';
import { EmojiName } from '@lib/models/emoji';
import { EmojiName } from '@app-types/EmojiName';
import { upvoteEmoji } from './upvoteEmoji';
import { useDebounce } from 'react-use';

Expand Down
4 changes: 2 additions & 2 deletions src/app/emoji/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Emoji from './Emoji';
import { PageTitle, Paragraph } from '@components/typography';
import { getAllEmojis } from '@lib/models/emoji';
import { type Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const revalidate = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/app/emoji/upvoteEmoji.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use server';
import { EmojiName, updateEmojiUpvoteCount } from '@lib/models/emoji';
import { updateEmojiUpvoteCount } from '@lib/models/emoji';
import { EmojiName } from '@app-types/EmojiName';

export async function upvoteEmoji(emoji: EmojiName, upvoteCount: number) {
return updateEmojiUpvoteCount(emoji, upvoteCount);
Expand Down
4 changes: 2 additions & 2 deletions src/app/gallery/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const metadata: Metadata = {
title: 'Gallery',
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Analytics } from '@vercel/analytics/react';
import type { Metadata } from 'next';
import Container from '@components/Container';
import './globals.css';
import { BASE_URL } from '../utils/const';
import { BASE_URL } from '@utils/const';

const redHatText = Red_Hat_Text({
variable: '--font-red-hat-text',
Expand Down
4 changes: 2 additions & 2 deletions src/app/newsletter/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const metadata: Metadata = {
title: 'Newsletter',
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PageTitle, Paragraph } from '@components/typography';
import type { Metadata } from 'next';
import { BASE_URL } from '../utils/const';
import { OG_IMAGE } from '../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const metadata: Metadata = {
title: 'Kirill Kurko',
Expand Down
2 changes: 1 addition & 1 deletion src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MetadataRoute } from 'next';
import { BASE_URL } from '../utils/const';
import { BASE_URL } from '@utils/const';
import { getAllBlogPosts } from '@lib/models/blog';

export default function sitemap(): MetadataRoute.Sitemap {
Expand Down
4 changes: 2 additions & 2 deletions src/app/snippets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WorkInProgress from '@components/WorkInProgress';
import type { Metadata } from 'next';
import { BASE_URL } from '../../utils/const';
import { OG_IMAGE } from '../../utils/ogImages';
import { BASE_URL } from '@utils/const';
import { OG_IMAGE } from '@utils/ogImages';

export const metadata: Metadata = {
title: 'Snippets',
Expand Down
12 changes: 12 additions & 0 deletions src/lib/database/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createClient } from '@vercel/kv';
import invariant from 'tiny-invariant';

const KV_URL = process.env.REDIS_REST_API_URL;
const KV_TOKEN = process.env.REDIS_REST_API_TOKEN;

invariant(KV_URL && KV_TOKEN, 'KV_URL and KV_TOKEN are required');

export const client = createClient({
url: KV_URL,
token: KV_TOKEN,
});
Loading

0 comments on commit 3b6bff0

Please sign in to comment.