-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from zhangzewei/main
feature: upgrade db with vercel postgres
- Loading branch information
Showing
12 changed files
with
235 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,4 +135,5 @@ next-env.d.ts | |
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
*.pem | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
async rewrites() { | ||
return [ | ||
{ | ||
source: '/api/:path*', | ||
destination: 'http://localhost:3000/api/:path*', | ||
}, | ||
]; | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
import { connectDB } from "../utils"; | ||
import { connectPostgres } from "../utils"; | ||
|
||
export interface Chapter { | ||
id: string, | ||
belongs_to: string, | ||
chapter_num: number, | ||
chapter_name: string, | ||
content: string, | ||
nft_ip_id: string | ||
nft_ip_id: string, | ||
image_url: string | ||
} | ||
|
||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const id = searchParams.get('id'); | ||
const db = await connectDB(); | ||
try { | ||
const result = await db?.all(`select * from chapter where belongs_to = '${id}'`, []); | ||
db?.close(); | ||
return Response.json({ data: result }); | ||
} catch (err) { | ||
return Response.json({ data: err }) | ||
const db = await connectPostgres(); | ||
if (db) { | ||
try { | ||
const { rows } = await db.query<Chapter>({ | ||
text: 'select * from chapter where belongs_to = $1', | ||
values: [id] | ||
}); | ||
db.end(); | ||
return Response.json({ data: rows }); | ||
} catch (err) { | ||
return Response.json({ data: err }) | ||
} | ||
} | ||
return Response.json({ data: [] }) | ||
} |
Oops, something went wrong.