1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00
_/vercel-fastify/api/index.ts

19 lines
450 B
TypeScript
Raw Normal View History

2024-04-22 00:20:58 +09:00
import autoload from "@fastify/autoload";
import type { VercelRequest, VercelResponse } from "@vercel/node";
import fastify from "fastify";
import path from "node:path";
2022-04-26 10:51:36 +09:00
2024-04-22 00:20:58 +09:00
const app = fastify();
2022-04-26 10:51:36 +09:00
2024-04-22 00:20:58 +09:00
app.register(autoload, {
dir: path.resolve(__dirname, "_routes"),
options: {
prefix: "/api",
},
});
2022-04-26 10:51:36 +09:00
2024-04-22 00:20:58 +09:00
export default async function handler(req: VercelRequest, res: VercelResponse) {
await app.ready();
app.server.emit("request", req, res);
}