7
8export async function getAllInteractionsPages() {
9 const databaseId = Deno.env.get("GLANCE_INTERACTIONS_DB_ID");
10
11 if (!databaseId) {
12 throw new Error(
13 "GLANCE_INTERACTIONS_DB_ID environment variable is not set"
16
17 try {
18 const response = await notion.databases.query({
19 database_id: databaseId,
20 });
21
37
38export async function getAllInteractionsPagesWithPagination() {
39 const databaseId = Deno.env.get("GLANCE_INTERACTIONS_DB_ID");
40
41 if (!databaseId) {
42 throw new Error(
43 "GLANCE_INTERACTIONS_DB_ID environment variable is not set"
51
52 while (hasMore) {
53 const response = await notion.databases.query({
54 database_id: databaseId,
55 start_cursor: startCursor,
56 });
12// that blob determines whether or not the cobrowsing button is ON or OFF
13export default async function (interval: Interval) {
14 // every page in the "Glancer demo" database should have it's own blob, so we have a cache for each demo
15 // this cron saves a blob for every page in the Demos DB
16 try {
17 // get notion pages with the databaseId
18 const pages = await notion.databases.query({
19 database_id: Deno.env.get("GLANCE_DEMOS_DB_ID"),
20 });
21 // for each page in the demo database, save a blob
22 for (const page of pages.results) {
23 const blobKey = await blobKeyForDemoCache(import.meta.url, page.id);
1import { Hono } from "npm:hono";
2import { getDatabase } from "../../controllers/getDatabase.ts";
3
4const app = new Hono();
9 // hit the controller to return data
10 try {
11 const data = await getDatabase(id);
12 //
13 console.log(data);
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
14 console.log("New dental form submission:", { name, phone });
15
16 // Optional: Trigger Twilio, store in database, etc.
17
18 return new Response(
3import { Hono } from "https://esm.sh/hono@3.11.7";
4import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { runMigrations, seedSampleData } from "./database/migrations.ts";
6import { PropertyQueries } from "./database/queries.ts";
7import authRoutes from "./routes/auth.ts";
8import listingsRoutes from "./routes/listings.ts";
17});
18
19// Initialize database on startup
20let dbInitialized = false;
21async function initializeDatabase() {
22 if (!dbInitialized) {
23 console.log("Initializing database...");
24 await runMigrations();
25
31
32 dbInitialized = true;
33 console.log("Database initialized successfully!");
34 }
35}
37// Health check endpoint
38app.get('/api/health', async (c) => {
39 await initializeDatabase();
40
41 return c.json({
95app.get('/api/stats', async (c) => {
96 try {
97 await initializeDatabase();
98
99 // Get basic statistics
142app.get('/', async (c) => {
143 try {
144 await initializeDatabase();
145
146 let html = await readFile("/frontend/index.html", import.meta.url);
8 InspectionQueries,
9 UserQueries
10} from "../database/queries.ts";
11import { requireAuth } from "./auth.ts";
12import type {
4import { sign, verify } from "https://esm.sh/hono@3.11.7/jwt";
5import { setCookie, getCookie, deleteCookie } from "https://esm.sh/hono@3.11.7/cookie";
6import { UserQueries } from "../database/queries.ts";
7import type { AuthResponse, LoginForm, RegisterForm } from "../../shared/types.ts";
8import { isValidEmail, isValidNigerianPhone, validatePassword } from "../../shared/utils.ts";
1// Database query functions for Enugu Rents
2
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
1// Database migrations for Enugu Rents
2
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
5// Run all migrations
6export async function runMigrations() {
7 console.log("Running database migrations...");
8
9 await createUsersTable();
13 await createInspectionRequestsTable();
14
15 console.log("Database migrations completed successfully!");
16}
17