@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.
34 lines • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpressPageAdapter = void 0;
const express_1 = __importDefault(require("express"));
class ExpressPageAdapter {
server;
constructor(server) {
this.server = server;
}
registerStaticFiles(config) {
this.server.use(config.prefix ?? '/', express_1.default.static(config.root));
}
registerSpaFallback(apiPrefix, staticDir) {
this.server.use((req, res, _next) => {
if (req.path.startsWith(apiPrefix)) {
res.status(404).json({
code: 404,
error: 'Not Found',
message: `Route ${req.method}:${req.path} not found`,
});
}
else {
res.sendFile('index.html', { root: staticDir });
}
});
}
async register() {
}
}
exports.ExpressPageAdapter = ExpressPageAdapter;
//# sourceMappingURL=express.js.map