6 const pinger = setInterval(async () => {
7 // check the boolean to see if a Glancer has enabled the link to start a cobrowsing session
8 const resp = await fetch("/api/cobrowse/" + window.__DEMO_ID__, {
9 method: "GET",
10 headers: {
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.ts";
10import auth from "./routes/auth.ts";
11import root from "./routes/root.ts";
33
34// Mount route modules
35app.route("/api", api);
36app.route("/tasks", tasks);
37app.route("/demo", demo);
8 <script src="https://cdn.tailwindcss.com"></script>
9 <link
10 href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"
11 rel="stylesheet"
12 />
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7
5} from "https://esm.town/v/std/utils/index.ts";
6import { Hono } from "npm:hono";
7import { examplePDF } from "../../api/servePDF.ts";
8import { getPage } from "../../../controllers/getPage.ts";
9
31 let html = await readFile("/frontend/index.html", import.meta.url);
32
33 // Use the /demo API endpoint to get data
34 const apiUrl = new URL(c.req.url);
35 apiUrl.pathname = `/api/demo/${id}`;
36
37 const response = await fetch(apiUrl.toString());
38 const initialData = await response.json();
39