|
@@ -0,0 +1,26 @@
|
|
1
|
+// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
2
|
+import type { NextApiRequest, NextApiResponse } from "next";
|
|
3
|
+import NextCors from "nextjs-cors";
|
|
4
|
+import { getDatabaseId, notion, renderClient } from "../../lib/notion";
|
|
5
|
+import { DatabaseType, Error, Topic } from "../../types";
|
|
6
|
+
|
|
7
|
+export default async function handler(
|
|
8
|
+ req: NextApiRequest,
|
|
9
|
+ res: NextApiResponse<any>
|
|
10
|
+) {
|
|
11
|
+ await NextCors(req, res, {
|
|
12
|
+ methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
|
|
13
|
+ origin: "*",
|
|
14
|
+ optionsSuccessStatus: 200,
|
|
15
|
+ });
|
|
16
|
+
|
|
17
|
+ const {
|
|
18
|
+ query: { id },
|
|
19
|
+ } = req;
|
|
20
|
+ if (!id) {
|
|
21
|
+ res.status(404).json({ status: "ID not supplied." });
|
|
22
|
+ } else {
|
|
23
|
+ const recordMap = await renderClient.getPage(id as string);
|
|
24
|
+ res.status(200).json(recordMap);
|
|
25
|
+ }
|
|
26
|
+}
|