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.

37 lines 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FastifyPageAdapter = void 0; const static_1 = __importDefault(require("@fastify/static")); class FastifyPageAdapter { server; constructor(server) { this.server = server; } registerStaticFiles(config) { this.server.register(static_1.default, { root: config.root, ...(config.prefix != null ? { prefix: config.prefix } : {}), }); } registerSpaFallback(apiPrefix, staticDir) { this.server.setNotFoundHandler(async (request, reply) => { if (request.raw.url != null && request.raw.url.startsWith(apiPrefix)) { reply.status(404).send({ code: 404, error: 'Not Found', message: `Route ${request.method}:${request.url} not found`, }); } else { reply.sendFile('index.html', staticDir); } }); } async register() { } } exports.FastifyPageAdapter = FastifyPageAdapter; //# sourceMappingURL=fastify.js.map