3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
1import { Hono } from "npm:hono";
2import { getPage } from "../../controllers/page.controller.ts";
3
4const app = new Hono();
5
37- Hono /backend/routes, including
38 - index.ts and what it does, and the routing strategy it establishes, including
39 - /api routes for serving JSON and other content to views
40 - /view routes for serving the demo at /demo/:id/
41 - /task routes for handling Notion webhooks
13}
14
15interface ApiErrorResponse {
16 message: string;
17 status: string | number;
18}
19
20export type DemoData = NotionPage | ApiErrorResponse;
21
22// Type guards
23export function isApiError(data: DemoData): data is ApiErrorResponse {
24 return 'message' in data && 'status' in data;
25}
60 }
61
62 // If no initial data, fetch it from the API
63 const demoId = window.__DEMO_ID__ || getDemoIdFromPath();
64 if (demoId && demoId !== 'demo') {
65 try {
66 const response = await fetch(`/api/demo/${demoId}`);
67 const data = await response.json();
68 return {
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";
33
34// Mount route modules
35app.route("/api", api);
36app.route("/tasks", tasks);
37app.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",
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
16 }}
17 >
18 <h3 className="font-bold capitalize">
19 {item?.properties?.Name?.title?.[0]?.plain_text}
20 </h3>
5// Initialize Notion client
6const notion = new Client({
7 auth: Deno.env.get("NOTION_API_KEY"),
8});
9