The serverless API for our final software engineering project.

notion.ts 748B

1234567891011121314151617181920212223242526272829
  1. import { NotionAPI } from "notion-client";
  2. import { NOTION_KEY, NOTION_USER_ID, NOTION_USER_TOKEN } from "../config";
  3. import { DatabaseType } from "../types";
  4. const { Client } = require("@notionhq/client");
  5. export const notion = new Client({ auth: NOTION_KEY });
  6. export const renderClient = new NotionAPI({
  7. authToken: NOTION_USER_TOKEN,
  8. activeUser: NOTION_USER_ID,
  9. });
  10. /**
  11. * Translates incoming GET parameters into a valid block ID.
  12. * @param type
  13. * @returns string
  14. */
  15. export function getDatabaseId(type: DatabaseType): string | undefined {
  16. switch (type) {
  17. case "laws":
  18. return "d02fa51eda254c9fa4b97e5f9beb1a86";
  19. case "advice":
  20. return "9515c0f02e454e968c44336bd1beb463";
  21. default:
  22. return undefined;
  23. }
  24. }