Here are the step-by-step instructions that would lead directly to the correct, clean implementation:
cat /backend/services/notion.service.ts
cat /backend/routes/views/\_views.routes.ts
cat /main.tsx # Look for auth middleware setup
// 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
id
- Notion page ID✅ Controller Best Practices: