Spaces:
Sleeping
Sleeping
File size: 1,300 Bytes
170b9b6 f69e867 76b46a3 170b9b6 f69e867 170b9b6 f69e867 170b9b6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import "reflect-metadata";
import { NestFactory } from "@nestjs/core";
import { FastifyAdapter, type NestFastifyApplication } from "@nestjs/platform-fastify";
import { AppModule } from "./app.module.js";
import { serve } from "inngest/node";
import { inngest as workerInngest, functions } from "@courtmitra/worker";
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(), {
logger: ["error", "warn", "log"],
});
app.setGlobalPrefix("api");
app.enableCors({ origin: true });
// Mount Inngest worker handler on /api/inngest (combined container)
const inngestHandler = serve({ client: workerInngest, functions });
const fastify = app.getHttpAdapter().getInstance();
fastify.route({
method: ["GET", "POST", "PUT"],
url: "/api/inngest",
handler: async (request: any, reply: any) => {
reply.hijack();
inngestHandler(request.raw, reply.raw);
},
});
const port = Number(process.env.API_PORT ?? process.env.PORT ?? 3001);
await app.listen(port, "0.0.0.0");
console.log(`[api] listening on http://localhost:${port}/api`);
console.log(`[worker] inngest endpoint on http://localhost:${port}/api/inngest`);
}
bootstrap().catch((err) => {
console.error(err);
process.exit(1);
});
|