Kest

Search

Search the documentation

Recipes

Migrating from Fastify

Fastify concepts (schemas, hooks, plugins, decorators) mapped to Kest.

Fastify and Kest share a philosophy: speed, structure and validation up front. Kest runs on Netty and can be benchmarked against Fastify-style workloads (see Benchmarks).

FastifyKest
fastify.get('/x', { schema }, handler)@Get("/x") on a controller method; the request class carries the constraints
JSON Schema for body, query, paramsconstraint annotations (@NotBlank, @Min, @Pattern, @Email...), checked by ValidationPipe
Response schema (fast serialization)return a typed value; @Exclude/@Expose shape it
fastify.register(plugin) and encapsulation@Module with imports, providers, exports
fastify.decorate('db', db)a provider injected through the constructor
Hooks: onRequest, preHandlerMiddleware (before routing), Guard, Pipe
Hooks: onSend, onResponseInterceptor (after the handler)
onError, setErrorHandlerExceptionFilter, @ControllerAdvice
fastify-cors, @fastify/helmet, @fastify/compressenableCors, useSecurityHeaders, useCompression
@fastify/jwtJwtModule, @Authenticated
@fastify/staticserveStatic
@fastify/multipart@FormFile
@fastify/rate-limitthrottler
@fastify/swaggerapi-docs
pinoLogger (it has a JSON mode, see Logging.configure)
app.inject() for testsTesting.createModule<AppModule> and startHttp(...)
HTTP/2 optionNettyHttpAdapter(port, http2 = true)

Differences to expect

  • Validation is not JSON Schema. Constraints are annotations; there is no schema object to share with other tools. For documentation, api-docs produces OpenAPI from the same classes.
  • Plugins do not encapsulate by prefix. Modules group providers; every provider is visible to every module (the build still checks that dependencies exist). Use setGlobalPrefix or a controller path for URL prefixes.
  • Async hooks become plain functions running on virtual threads.

Steps

  1. One controller per route prefix; one module per plugin.
  2. Turn decorated values (fastify.decorate) into injectable providers.
  3. Replace hooks according to the table: authentication becomes a guard, response shaping an interceptor.
  4. Replace route schemas with request classes carrying constraint annotations.