Public
Like
glimpse2-runbook-view-glimpse-save-login-react
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v26View latest version
Provide working sample URLs for glimpse routes using actual page IDs from the GLANCE_DEMOS_DB_ID database without trial and error.
// In /backend/routes/api/_api.routes.ts, add:
app.get("/demo-pages", async (c) => {
const databaseId = Deno.env.get("GLANCE_DEMOS_DB_ID");
if (!databaseId) {
return c.json({ error: "GLANCE_DEMOS_DB_ID not configured" }, 500);
}
const result = await getDatabasePages(databaseId);
return c.json(result);
});
// In /backend/services/notion.service.ts, add:
export async function getDatabasePages(databaseId: string) {
try {
const response = await notion.databases.query({
database_id: databaseId,
page_size: 10, // Limit to first 10 pages
});
return {
success: true,
data: response,
timestamp: new Date().toISOString(),
};
} catch (error) {
return {
success: false,
error: error.message,
timestamp: new Date().toISOString(),
};
}
}
// In main.tsx, change:
// FROM: app.use("/api/*", authCheck);
// TO:
app.use("/api/health", authCheck);
// This allows /api/demo-pages to be accessed without auth
# Make request to get actual page IDs
fetch("/api/demo-pages")
// From the JSON response, extract the first page ID:
const pageId = response.data.results[0].id;
// Example: "20789f51-c349-81e0-8b17-d2d89039c636"
// In main.tsx, restore:
app.use("/api/*", authCheck);
Original route: /views/glimpse/{pageId}
New route: /glimpse/{pageId}
// 1. Add to notion.service.ts
export async function getDatabasePages(databaseId: string) {
try {
const response = await notion.databases.query({
database_id: databaseId,
page_size: 10,
});
return { success: true, data: response, timestamp: new Date().toISOString() };
} catch (error) {
return { success: false, error: error.message, timestamp: new Date().toISOString() };
}
}
// 2. Add to _api.routes.ts
app.get("/demo-pages", async (c) => {
const databaseId = Deno.env.get("GLANCE_DEMOS_DB_ID");
if (!databaseId) return c.json({ error: "GLANCE_DEMOS_DB_ID not configured" }, 500);
const result = await getDatabasePages(databaseId);
return c.json(result);
});
// 3. Temporarily modify main.tsx
app.use("/api/health", authCheck); // Instead of "/api/*"
// 4. Fetch data
const response = await fetch("/api/demo-pages");
const data = await response.json();
const pageId = data.data.results[0].id;
// 5. Restore main.tsx
app.use("/api/*", authCheck);
// 6. Provide URLs
const originalUrl = `/views/glimpse/${pageId}`;
const newUrl = `/glimpse/${pageId}`;
- Always use GLANCE_DEMOS_DB_ID environment variable for database ID
- Temporarily bypass auth only for the demo endpoint
- Extract the first available page ID from results array
- Restore full authentication after getting the ID
- Both routes should work identically with the real page ID
This process eliminates guesswork and provides actual working URLs with real Notion page IDs from the configured database.