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: v25View latest version
Here are the step-by-step instructions that would lead directly to the correct, clean implementation:
- Endpoint: GET /views/glimpse/:id
- Authentication: Required (existing Google OAuth)
- Input: Notion page ID (not database ID)
- Output: JSON response with full service response (minus UI elements)
- Data source: Notion page properties
cat /backend/services/notion.service.ts
cat /backend/routes/views/\_views.routes.ts
cat /main.tsx # Look for auth middleware setup
- Current service has getDatabaseById() for database metadata
- Need getPageById() for individual page data
- Service should return full Notion response for flexibility
// Add to /backend/services/notion.service.ts
export async function getPageById(pageId: string) {
try {
const response = await notion.pages.retrieve({
page_id: pageId,
});
return {
success: true,
data: response,
timestamp: new Date().toISOString(),
};
} catch (error) {
return {
success: false,
error: error.message,
timestamp: new Date().toISOString(),
};
}
}
// Add to /backend/services/notion.service.ts
export async function getDatabasePages(databaseId: string) {
try {
const response = await notion.databases.query({
database_id: databaseId,
});
return {
success: true,
data: response,
timestamp: new Date().toISOString(),
};
} catch (error) {
return {
success: false,
error: error.message,
timestamp: new Date().toISOString(),
};
}
}
// Create /backend/controllers/glimpse.controller.ts
import { Context } from "npm:hono@3.12.12";
import { getPageById } from "../services/notion.service.ts";
export async function glimpseHandler(c: Context) {
const id = c.req.param("id");
if (!id) {
return c.json({ error: "Page ID is required" }, 400);
}
const result = await getPageById(id);
if (!result.success) {
return c.json({ error: "Failed to fetch page data", details: result.error }, 500);
}
// Filter out button properties from the response
if (result.data?.properties) {
const filteredProperties = Object.fromEntries(
Object.entries(result.data.properties).filter(([key, value]) => value?.type !== "button")
);
result.data.properties = filteredProperties;
}
return c.json(result);
}
// Update /backend/routes/views/\_views.routes.ts
import { Hono } from "npm:hono@3.12.12";
import { glimpseHandler } from "../../controllers/glimpse.controller.ts";
const app = new Hono();
app.get("/glimpse/:id", glimpseHandler);
export default app;
Add to /backend/routes/views/README.md
- Purpose: Returns Notion page data as JSON (filtered for data consumption)
- Authentication: Required (Google OAuth)
- Parameters:
id
- Notion page ID - Response: Service response object with Notion page data (button properties removed)
- Filtering: Removes UI-specific properties (type: "button") for cleaner data consumption
✅ Controller Best Practices:
- Single Responsibility: Controller handles HTTP concerns + minimal data cleanup
- Thin Layer: Minimal processing, focused on improving data consumption
- Useful Filtering: Remove UI elements that don't belong in data APIs
- Consistent Error Handling: Standard error response format