Bläddra i källkod

[feat] Initial commit with Notion configuration

Sergio Mattei 2 år sedan
förälder
incheckning
4c7b5d4ce5
3 ändrade filer med 21 tillägg och 4 borttagningar
  1. 1
    0
      config.ts
  2. 16
    0
      lib/notion.ts
  3. 4
    4
      pages/api/getTopicList.ts

+ 1
- 0
config.ts Visa fil

@@ -0,0 +1 @@
1
+export const NOTION_KEY = process.env.NOTION_KEY;

+ 16
- 0
lib/notion.ts Visa fil

@@ -0,0 +1,16 @@
1
+import { NOTION_KEY } from "../config";
2
+
3
+interface NotionAuth {}
4
+
5
+/**
6
+ * Returns authentication configuration for a Notion API `fetch` call.
7
+ * @returns
8
+ */
9
+export function notionCall(): Partial<RequestInit> {
10
+  return {
11
+    headers: {
12
+      "Notion-Version": "2022-06-28",
13
+      Authorization: `Bearer ${NOTION_KEY}`,
14
+    },
15
+  };
16
+}

pages/api/hello.ts → pages/api/getTopicList.ts Visa fil

@@ -1,13 +1,13 @@
1 1
 // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2
-import type { NextApiRequest, NextApiResponse } from 'next'
2
+import type { NextApiRequest, NextApiResponse } from "next";
3 3
 
4 4
 type Data = {
5
-  name: string
6
-}
5
+  name: string;
6
+};
7 7
 
8 8
 export default function handler(
9 9
   req: NextApiRequest,
10 10
   res: NextApiResponse<Data>
11 11
 ) {
12
-  res.status(200).json({ name: 'John Doe' })
12
+  res.status(200).json({ name: "John Doe" });
13 13
 }