Fork Horse repository, listed by its owner. Publisher snapshot.
packages/forkhorse-core/src/index.ts
Snapshot at 34e3175
1import { publicFetch } from "./public";
2import { parsePush, projectForRepo } from "./events";
3import type { Env } from "./types";
4export { ReceiptRunner, GitReadGateway, QuickFiles } from "../../forkhorse-runner/src/index";
5export { Supervisor } from "./supervisor";
6
7export default {
8 fetch: publicFetch,
9
10 async queue(batch: MessageBatch<unknown>, env: Env): Promise<void> {
11 for (const message of batch.messages) {
12 try {
13 const event = parsePush(message.body);
14 if (event && event.source.namespace === env.ARTIFACTS_NAMESPACE) {
15 const project = projectForRepo(event.source.repoName);
16 if (
17 project &&
18 !(await env.SUPERVISOR.get(env.SUPERVISOR.idFromName(project)).recordPush(event))
19 ) {
20 message.retry();
21 continue;
22 }
23 }
24 message.ack();
25 } catch {
26 // Retry provider/storage failures and malformed push envelopes; configure a DLQ.
27 // Never acknowledge a push whose complete diff could not be recorded.
28 message.retry();
29 }
30 }
31 },
32} satisfies ExportedHandler<Env>;
33