UNPKG

@sentzunhat/zacatl

Version:

A modular, high-performance TypeScript microservice framework for Node.js, featuring layered architecture, dependency injection, and robust validation for building scalable APIs and distributed systems.

33 lines 1.02 kB
import proxy from '@fastify/http-proxy'; export class FastifyApiAdapter { server; constructor(server) { this.server = server; } registerRoute(handler) { this.server.withTypeProvider().route({ url: handler.url, method: handler.method, schema: handler.schema, handler: handler.execute.bind(handler), }); } registerHook(handler) { this.server.addHook(handler.name, handler.execute.bind(handler)); } registerProxy(config) { this.server.register(proxy, { upstream: config.upstream, prefix: config.prefix, ...(config.rewritePrefix != null ? { rewritePrefix: config.rewritePrefix } : {}), ...(config.http2 !== undefined ? { http2: config.http2 } : {}), }); } async listen(port) { await this.server.listen({ port, host: '0.0.0.0' }); } getRawServer() { return this.server; } } //# sourceMappingURL=fastify-adapter.js.map