1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
1import ValTown from "npm:@valtown/sdk";
2import { getProjectState, getWebhooks, updateProjectState } from "./database/queries.ts";
3import { sendWebhookNotification } from "./webhookService.ts";
4const vt = new ValTown();
38 const currentFiles = await getProjectFiles(projectId);
39
40 // Get previous project state from our database
41 const previousState = await getProjectState(projectId);
42
88 }
89
90 // Update project state in database
91 await updateProjectState(projectId, currentFiles);
92 } catch (error) {
21
22 // You could also do additional processing here based on the event
23 // For example, trigger other systems, update a database, etc.
24 return Response.json({
25 ok: true,
23
24 // You could also do additional processing here based on the event
25 // For example, trigger other systems, update a database, etc.
26 return Response.json({
27 ok: true,
3import { createTables, projectStatesTableName, subscriptionsTableName } from "./migrations.ts";
4
5// This will create the database table if it doesn't exist.
6// This will run every time the app starts up. You can
7// comment out this line for a modest (30ms) perforamnce improvement
8// on cold starts. It's left in to ensure the database tables are
9// automatically set up correctly for users who fork this app.
10await createTables();
1const NOTION_API_KEY = Deno.env.get("NOTION_API_KEY");
2const COFFEE_TABLE_DB_ID = Deno.env.get("NOTION_COFFEE_DATABASE_ID");
3const NOTION_DATABSE_API = "https://api.notion.com/v1/databases";
4const NOTION_PAGES_API = "https://api.notion.com/v1/pages";
5
9
10if (!COFFEE_TABLE_DB_ID) {
11 throw new Error("Missing NOTION_COFFEE_DATABASE_ID");
12}
13
6- Update your enviroment vairables to include these keys
7 - Notion Integration API Key: `NOTION_API_KEY`
8 - [Coffee Journal Database ID](https://developers.notion.com/reference/retrieve-a-database): `COFFEE_TABLE_DB_ID`
2import { readFile, servePublicFile } from "https://esm.town/v/stevekrouse/utils@187-main/serve-public/index.ts";
3import { Hono } from "npm:hono";
4import { insertWebhook } from "./database/queries.ts";
5
6const app = new Hono();