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);
|
|
|
|
}
|