왜 Fastify인가
Fastify는 Express 대비 약 2~3배 빠른 처리 성능을 제공합니다. JSON Schema 기반 검증과 직렬화가 핵심입니다.
스키마 기반 라우트
import Fastify from "fastify";
const app = Fastify({ logger: true });
app.post("/users", {
schema: {
body: {
type: "object",
required: ["name", "email"],
properties: {
name: { type: "string" },
email: { type: "string", format: "email" },
},
},
},
handler: async (req, reply) => {
const user = await createUser(req.body);
return reply.code(201).send(user);
},
});
댓글 0