stevensDemogetWeather.ts1 match
130}
131132console.log(`Weather forecast updated in the database.`);
133return summary;
134}
125}
126127console.log(`Calendar events imported into the database.`);
128return events;
129} catch (error) {
stevensDemogenerateFunFacts.ts2 matches
89/**
10* Retrieves previously generated fun facts from the memories database
11* @returns Array of previous fun facts
12*/
4748/**
49* Inserts a fun fact into the memories database
50* @param date Date for the fun fact in ISO format
51* @param factText The fun fact text
stevensDemo.cursorrules2 matches
208```
209โโโ backend/
210โ โโโ database/
211โ โ โโโ migrations.ts # Schema definitions
212โ โ โโโ queries.ts # DB query functions
270- Handle API calls properly with proper error catching
271272### Database Patterns
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
toolsnotion_endpoints.tsx15 matches
1import { NotionDatabase } from "./notion-db-interface.tsx";
23export default async function(req: Request): Promise<Response> {
7try {
8// Check required environment variables
9const databaseId = Deno.env.get("NOTION_DATABASE_ID");
1011if (!databaseId) {
12return new Response(
13JSON.stringify({
14error: "NOTION_DATABASE_ID environment variable is required",
15setup_instructions: {
16step1: "Open your Notion database",
17step2: "Copy the database ID from the URL",
18step3: "URL format: https://notion.so/[workspace]/[DATABASE_ID]?v=...",
19step4: "Set NOTION_DATABASE_ID environment variable in Val Town",
20},
21}),
27}
2829const notion = new NotionDatabase();
30let result;
3132switch (action) {
33case "query":
34// Query all pages from the database
35const pages = await notion.queryDatabase(databaseId);
36result = {
37total_pages: pages.length,
4142case "schema":
43// Get database schema/structure
44result = await notion.getDatabaseSchema(databaseId);
45break;
4669available_actions: ["query", "schema", "search"],
70usage: {
71query: "?action=query - Get all pages from database",
72schema: "?action=schema - Get database structure",
73search: "?action=search&q=term - Search for pages",
74},
toolsnotion-db-interface.tsx33 matches
1import { Client } from "npm:@notionhq/client@2.2.3";
23// Types for Notion database operations
4interface NotionPage {
5id: string;
9}
1011interface DatabaseQueryOptions {
12filter?: any;
13sorts?: any[];
16}
1718class NotionDatabase {
19private client: Client;
20
2829/**
30* Query a database with optional filters and sorting
31*/
32async queryDatabase(databaseId: string, options: DatabaseQueryOptions = {}): Promise<NotionPage[]> {
33try {
34const response = await this.client.databases.query({
35database_id: databaseId,
36filter: options.filter,
37sorts: options.sorts,
42return response.results as NotionPage[];
43} catch (error) {
44console.error('Error querying database:', error);
45throw error;
46}
4849/**
50* Get database schema/structure
51*/
52async getDatabaseSchema(databaseId: string) {
53try {
54const response = await this.client.databases.retrieve({
55database_id: databaseId,
56});
57return response.properties;
58} catch (error) {
59console.error('Error getting database schema:', error);
60throw error;
61}
104// Check environment variables first
105const notionToken = Deno.env.get('NOTION_TOKEN');
106const databaseId = Deno.env.get('NOTION_DATABASE_ID');
107
108if (action === 'debug') {
112notion_token_length: notionToken?.length || 0,
113notion_token_prefix: notionToken?.substring(0, 10) + '...' || 'not set',
114database_id_exists: !!databaseId,
115database_id_length: databaseId?.length || 0,
116database_id_prefix: databaseId?.substring(0, 10) + '...' || 'not set'
117}
118}, null, 2), {
129step3: 'Copy the Internal Integration Token',
130step4: 'Set NOTION_TOKEN environment variable in Val Town',
131step5: 'Share your database with the integration'
132}
133}), {
137}
138
139if (!databaseId) {
140return new Response(JSON.stringify({
141error: 'NOTION_DATABASE_ID environment variable is required',
142setup_instructions: {
143step1: 'Open your Notion database',
144step2: 'Copy the database ID from the URL',
145step3: 'URL format: https://notion.so/[workspace]/[DATABASE_ID]?v=...',
146step4: 'Set NOTION_DATABASE_ID environment variable in Val Town'
147}
148}), {
152}
153154const notion = new NotionDatabase();
155let result;
156157switch (action) {
158case 'schema':
159// Get database schema
160result = await notion.getDatabaseSchema(databaseId);
161break;
162
163case 'query':
164// Query all pages (default action)
165const pages = await notion.queryDatabase(databaseId);
166result = {
167total_pages: pages.length,
191usage: {
192debug: '?action=debug - Check environment variables',
193query: '?action=query - Get all pages from database',
194schema: '?action=schema - Get database structure',
195search: '?action=search&q=term - Search for pages'
196}
214common_issues: [
215'Invalid API token - check NOTION_TOKEN',
216'Database not shared with integration',
217'Invalid database ID - check NOTION_DATABASE_ID',
218'Integration lacks proper permissions'
219]
227228// Export for direct usage
229export { NotionDatabase };
Tarunkumarwebsiteindex.ts2 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { runMigrations } from "./database/migrations.ts";
4import auth from "./routes/auth.ts";
5import destinations from "./routes/destinations.ts";
9const app = new Hono();
1011// Initialize database on startup
12await runMigrations();
13
Tarunkumarwebsitebookings.ts1 match
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { getSessionUser, createFlightBooking, createTrainBooking, createCabBooking, getUserBookings } from "../database/queries.ts";
4import { generateId } from "../../shared/utils.ts";
5import type { FlightBooking, TrainBooking, CabBooking, ApiResponse } from "../../shared/types.ts";
5const destinations = new Hono();
67// Mock destinations data (in a real app, this would come from a database)
8const mockDestinations: Destination[] = [
9{
Tarunkumarwebsiteauth.ts1 match
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { setCookie, getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createUser, getUserByEmail, createSession, getSessionUser } from "../database/queries.ts";
4import { generateId, validateEmail } from "../../shared/utils.ts";
5import type { AuthResponse } from "../../shared/types.ts";