markdown-embedsetDemoURL.ts1 match
3// Initialize Notion client
4const notion = new Client({
5auth: Deno.env.get("NOTION_API_KEY"),
6});
7
markdown-embedsetCobrowse.ts1 match
13console.log(page.id);
14// get the cobrowse value from the payload
15// warning: properties in Notion are capitalized as a convention (see Cobrowse)
16const cobrowse = (page.properties.Cobrowse.checkbox) ? false : true;
17// save new cobrowse boolean to Notion page
markdown-embedsetCobrowse.ts1 match
3// Initialize Notion client
4const notion = new Client({
5auth: Deno.env.get("NOTION_API_KEY"),
6});
7
markdown-embedsetAction.ts1 match
3// Initialize Notion client
4const notion = new Client({
5auth: Deno.env.get("NOTION_API_KEY"),
6});
7
markdown-embedroot.ts2 matches
6// Initialize Notion client
7const notion = new Client({
8auth: Deno.env.get("NOTION_API_KEY"),
9});
1020{
21status: "error",
22message: "Failed to connect to Notion API",
23error: error.message,
24},
markdown-embedrecordClick.ts1 match
7console.log("click: ", JSON.stringify(clickData));
89fetch("/api/action", {
10method: "POST",
11headers: {
markdown-embedREADME.md11 matches
17let html = await readFile("/frontend/index.html", import.meta.url);
1819const response = await fetch(`/api/demo/${id}`);
20const initialData = await response.json();
2187// Client-side event recording
88window.recordClick = function (action) {
89fetch(`/api/setAction`, {
90method: "POST",
91headers: { "Content-Type": "application/json" },
103104```
105โโโ backend/ # Server-side logic and API routes
106โ โโโ controllers/ # Business logic for Notion integration
107โ โโโ crons/ # Scheduled tasks for cache management
108โ โโโ routes/ # HTTP route handlers
109โ โ โโโ api/ # JSON API endpoints
110โ โ โโโ tasks/ # Notion webhook handlers
111โ โ โโโ views/ # HTML page serving
121### Backend (`/backend`)
122123Handles all server-side operations including API routes, Notion integration, and static file serving. Built with Hono for routing and includes authentication middleware.
124125### Frontend (`/frontend`)
134135- **Val Town & Deno**: Serverless runtime environment with TypeScript support
136- **Notion Client**: Official npm library for Notion API integration
137- **Hono**: Lightweight web framework for routing and middleware
138- **Blob Storage**: Val Town's built-in caching solution for performance optimization
170171// Route modules
172app.route("/api", api); // JSON API endpoints
173app.route("/tasks", tasks); // Notion webhook handlers
174app.route("/demo", demo); // Demo page serving
175```
176177#### API Routes (`/api`)
178179Serve JSON data and handle CRUD operations for demo management, cobrowsing status, and user interactions.
241```typescript
242const notion = new Client({
243auth: Deno.env.get("NOTION_API_KEY"),
244});
245249Required environment variables:
250251- `NOTION_API_KEY`: Notion integration token
252- `GLANCE_DEMOS_DB_ID`: Notion database ID for demo pages
253- `GLANCE_INTERACTIONS_DB_ID`: Notion database ID for interaction tracking
289Different route areas serve specific purposes:
290291- `/api/*`: JSON data endpoints for frontend consumption
292- `/demo/*`: Personalized demo page serving with data injection
293- `/tasks/*`: Notion webhook processing and database updates
markdown-embedREADME.md1 match
7### Task endpoints use /controllers to get and save data
89In 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.
1011### Naming convention for routes and controllers
markdown-embedREADME.md2 matches
1## /api
23This directory holds the endpoints that serve JSON for the /demo, and a few other endpoints that handle POSTS and GETs from the /frontend.
5## Conventions
67As with other directories in `/routes`, the convention in this directory is that the file in the directory that has same name as the directory handles routing in this directory; i.e., `/api/api.ts` handles routing that directs a request from `/api/cobrowse` to the file that does the work: `/api/cobrowse.ts`.
89(If you're wondering why the file that handles routing in this directory isn't an `index.ts` file... Glad you asked! The reason is that when you have a bunch of files open in your IDE called `index.ts`, it's impossible to know without clicking in to each file which one is which. Similar issue with debugging server logs.)
markdown-embedREADME.md2 matches
8// Initialize Notion client
9const notion = new Client({
10auth: Deno.env.get("NOTION_API_KEY"),
11});
12```
1314Keeping controllers in this directory and importing them into our routes keeps our API endpoints thin and easier to work with. (See the /tasks directory as an example.)
1516## Re: /controllers and /utils