7
8// Import route modules
9import api from "./routes/api/api.routes.ts";
10import auth from "./routes/auth.ts";
11import root from "./routes/root.routes.ts";
34
35// Mount route modules
36app.route("/api", api);
37app.route("/tasks", tasks);
38app.route("/demo", demo);
9 <script src="https://cdn.tailwindcss.com"></script>
10 <link
11 href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"
12 rel="stylesheet"
13 />
5// Initialize Notion client
6const notion = new Client({
7 auth: Deno.env.get("NOTION_API_KEY"),
8});
9
11 return {
12 status: "connected",
13 message: "Successfully connected to Notion API",
14 databases: response.results.map((db) => ({
15 title: db.title?.[0]?.plain_text || "Untitled",
6// Initialize Notion client
7const notion = new Client({
8 auth: Deno.env.get("NOTION_API_KEY"),
9});
10
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useEffect, useState } from "https://esm.sh/react@18.2.0";
3import { DemoData, isApiError, isNotionPage } from "../index.tsx";
4import { TOC } from "./content/demoTableOfContents.tsx";
5import { GenerateHTML } from "./content/generateHTML.tsx";
54 if (!demoData) return <div>No demo data available</div>;
55
56 // Handle error responses from the API
57 if (isApiError(demoData)) {
58 return (
59 <div>
60 <h3>API Response:</h3>
61 <p>
62 <strong>Status:</strong> {demoData.status}
145 ? "active"
146 : ""
147 } capitalize`}
148 onClick={() => {
149 closeMenu();
224 }}
225 >
226 <h1 className="capitalize">
227 {page.properties.Name?.title?.[0]?.plain_text
228 || "Untitled"}
11// Initialize Notion client
12export const notion = new Client({
13 auth: Deno.env.get("NOTION_API_KEY"),
14});
15
6// Initialize Notion client
7const notion = new Client({
8 auth: Deno.env.get("NOTION_API_KEY"),
9});
10
21 {
22 status: "error",
23 message: "Failed to connect to Notion API",
24 error: error.message,
25 },
4// Initialize Notion client
5const notion = new Client({
6 auth: Deno.env.get("NOTION_API_KEY"),
7});
8
7### Task endpoints use /controllers to get and save data
8
9In order to keep the API easy to look and work with, the routes in /tasks handle routing but do not get data from or save data to Notion. The functions that connect to Notion live in the /controllers directory, and are _called_ from the endpoints in /tasks.
10
11### Naming convention for routes and controllers
1## /api
2
3This directory holds the endpoints that serve JSON for the /demo, and a few other endpoints that handle POSTS and GETs from the /frontend.