Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate off planetscale #130

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/api/getIssuePublishedDate/[issueNumber]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const revalidate = 43200;
export const runtime = 'edge';
export const preferredRegion = 'fra1';
// export const revalidate = 43200;
// export const runtime = 'edge';
// export const preferredRegion = 'fra1';

import { type NextRequest, NextResponse } from 'next/server'
import { getIssue } from '../../../../db'
Expand Down
44 changes: 30 additions & 14 deletions db/conn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { drizzle } from 'drizzle-orm/planetscale-serverless';
import { connect } from '@planetscale/database';
// import { drizzle } from 'drizzle-orm/planetscale-serverless';
// import { connect } from '@planetscale/database';

import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";


import {
DATABASE_HOST,
Expand All @@ -8,20 +12,32 @@ import {
} from '../env';

// Create fetch-isr
const fetchISR = (input: string, options?: RequestInit | undefined) => {
if (options) {
delete options['cache'];
//@ts-ignore
options['next'] = { revalidate: 43200 };
}
return fetch(input, options);
};

const connection = connect({
fetch: fetchISR,
// const fetchISR = (input: string, options?: RequestInit | undefined) => {
// if (options) {
// delete options['cache'];
// //@ts-ignore
// options['next'] = { revalidate: 43200 };
// }
// return fetch(input, options);
// };

// const connection = connect({
// fetch: fetchISR,
// host: DATABASE_HOST,
// username: DATABASE_USERNAME,
// password: DATABASE_PASSWORD,
// });

const connection = await mysql.createConnection({
host: DATABASE_HOST,
username: DATABASE_USERNAME,
user: DATABASE_USERNAME,
password: DATABASE_PASSWORD,
port: 3306,
database: "the_gazelle",
ssl: {
rejectUnauthorized: false,
},
});


export const db = drizzle(connection);
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const nextConfig = {
swcMinify: true,
experimental: {
appDir: true,
serverComponentsExternalPackages: ["mysql2"],
},
images: {
loader: 'custom',
Expand Down
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,39 @@
"addTTS": "npx ts-node-esm ./scripts/articleTTS/readArticle.ts"
},
"dependencies": {
"@planetscale/database": "^1.6.0",
"commonmark": "^0.30.0",
"date-fns": "^2.29.3",
"drizzle-orm": "^0.23.12",
"date-fns": "^2.30.0",
"drizzle-orm": "^0.23.13",
"mysql2": "^3.9.3",
"next": "^13.4.19",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.6",
"react-markdown": "^8.0.7",
"rehype-raw": "^6.1.1"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.328.0",
"@cloudflare/next-on-pages": "^0.10.1",
"@google-cloud/text-to-speech": "^4.2.2",
"@prisma/client": "^4.12.0",
"@prisma/client": "^4.13.0",
"@types/commonmark": "^0.27.6",
"@types/fluent-ffmpeg": "^2.1.21",
"@types/lodash": "^4.14.191",
"@types/lodash": "^4.14.194",
"@types/node": "18.15.5",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"@types/unist": "^2.0.6",
"autoprefixer": "^10.4.14",
"drizzle-kit": "^0.17.1",
"drizzle-kit": "^0.17.6",
"eslint": "8.36.0",
"eslint-config-next": "13.4.3",
"eslint-config-next": "14.1.4",
"fluent-ffmpeg": "^2.1.2",
"mysql2": "^3.2.0",
"postcss": "^8.4.21",
"prisma": "^4.12.0",
"tailwindcss": "^3.2.7",
"postcss": "^8.4.23",
"prisma": "^4.13.0",
"tailwindcss": "^3.3.2",
"ts-node": "^10.9.1",
"typescript": "5.0.2",
"vercel": "^28.0.2"
"vercel": "^28.20.0"
},
"engines": {
"node": "18.x"
Expand Down
Loading
Loading