vv1.14.0
Main
The project uses Fastify as the core HTTP framework, configured for maximum performance and stricter security defaults. It is fully typed using fastify-type-provider-zod, enabling end-to-end type safety from the route definition to the controller.
The server configuration resides in src/infrastructure/server/webserver.ts.
const instance = fastify({
logger: Logs.settings("webserver"),
pluginTimeout: 20000,
requestTimeout: 20000,
// ...
}).withTypeProvider<ZodTypeProvider>();| Plugin | Purpose |
|---|---|
fastify-type-provider-zod | Enables Zod schemas for route validation. |
@fastify/swagger | Generates OpenAPI 3.0 specifications. |
@fastify/swagger-ui | Hosts the documentation UI at /docs. |
@fastify/helmet | Sets secure HTTP headers (XSS protection, no-sniff, etc). |
@fastify/cors | Configures Cross-Origin Resource Sharing. |
The server includes a global error handler that catches exceptions and normalizes them into a standard JSON format.
{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation error: invalid email"
}Routes are defined in the domain/{entity} layer and registered in the application entry point.
// src/domain/{entity}/routes.ts
export default (app: server) => {
api.get(
"/:id",
{
schema: {
tags: ["{entity}"],
summary: "Find {entity} by id",
params: schema.actions.id,
headers: schema.actions.headers,
response: { 200: schema.entity, ...request.reply.schemas },
},
},
request.restricted(getById),
);
};