Skip to content

Commit

Permalink
Merge pull request #1123 from andrew-bierman/fix/add-back-queue
Browse files Browse the repository at this point in the history
🐛 fix bucket on queue
  • Loading branch information
andrew-bierman authored Jul 22, 2024
2 parents 50e6deb + eb40a8f commit 4963d7b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
27 changes: 19 additions & 8 deletions server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { type Ai } from '@cloudflare/ai';
import { Hono } from 'hono';
import { fetchHandler } from 'trpc-playground/handlers/fetch';
import { appRouter } from './routes/trpcRouter';
import { honoTRPCServer } from './trpc/server';
import { cors } from 'hono/cors';
import { securityHeaders } from './middleware/securityHeaders';
import { fetchHandler } from 'trpc-playground/handlers/fetch';
import { CORS_METHODS } from './config';
import { enforceHttps } from './middleware/enforceHttps';
import { securityHeaders } from './middleware/securityHeaders';
import { queue } from './queue';
import router from './routes';
import { CORS_METHODS } from './config';
import { type Ai } from '@cloudflare/ai';
import { appRouter } from './routes/trpcRouter';
import { httpDBContext } from './trpc/httpDBContext';
import { honoTRPCServer } from './trpc/server';

interface Bindings {
export interface Bindings {
[key: string]: any;
DB: IDBDatabase;
VECTOR_INDEX: VectorizeIndex;
Expand All @@ -21,6 +22,8 @@ interface Bindings {
MAPBOX_ACCESS_TOKEN: string;
CLOUDFLARE_ACCOUNT_ID: string;
VECTORIZE_API_KEY: string;
readonly ETL_QUEUE: Queue<Error>;
readonly ETL_BUCKET: R2Bucket;
}

const TRPC_API_ENDPOINT = '/api/trpc';
Expand Down Expand Up @@ -74,4 +77,12 @@ app.use(TRPC_PLAYGROUND_ENDPOINT, async (c, next) => {
app.use(`${HTTP_ENDPOINT}/*`, httpDBContext);
app.route(`${HTTP_ENDPOINT}/`, router);

export default app;
// SETUP CLOUDFLARE WORKER WITH EVENT HANDLERS
const worker = {
...app,
fetch: app.fetch,
queue,
};

// EXPORT WORKER
export default worker;
2 changes: 1 addition & 1 deletion server/src/queue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const queueHandlersMap = new Map<
string,
(batch: MessageBatch<Error>, env: Bindings) => Promise<void>
>([
['etl-queue', handleEtlQueue],
['packrat-etl-queue', handleEtlQueue],
// Add more handlers here
]);

Expand Down
2 changes: 1 addition & 1 deletion server/wrangler.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ max_batch_size = 10
max_batch_timeout = 5

[[r2_buckets]]
bucket_name = "etl-bucket"
bucket_name = "packrat-etl-bucket"
binding = "ETL_BUCKET"

# Add vars below
Expand Down

0 comments on commit 4963d7b

Please sign in to comment.