diff --git a/src/api/index.ts b/src/api/index.ts index 88934e7..469bf45 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -2,7 +2,13 @@ // You can access these endpoints at the following URL: // https://starbasedb.YOUR-IDENTIFIER.workers.dev/api/your/path/here -export async function handleApiRequest(request: Request): Promise { +import { StarbaseContext } from '../handler' +import { DataSource } from '../types' + +export async function handleApiRequest( + request: Request, + dataSource: DataSource +): Promise { const url = new URL(request.url) // EXAMPLE: diff --git a/src/handler.ts b/src/handler.ts index fd459a9..b5d8122 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -176,7 +176,9 @@ export class StarbaseDB { ) } - this.app.all('/api/*', async (c) => handleApiRequest(c.req.raw)) + this.app.all('/api/*', async (c) => + handleApiRequest(c.req.raw, this.dataSource) + ) // Set up error handlers this.app.notFound(() => { diff --git a/src/index.ts b/src/index.ts index d4026c9..13af797 100644 --- a/src/index.ts +++ b/src/index.ts @@ -181,11 +181,11 @@ export default { events: [], }) - cdcPlugin.onEvent(({ action, schema, table, data }) => { + cdcPlugin.onEvent(async ({ action, schema, table, data }) => { // Include change data capture code here }, ctx) - cronPlugin.onEvent(({ name, cron_tab, payload }) => { + cronPlugin.onEvent(async ({ name, cron_tab, payload }) => { // Include cron event code here }, ctx)