@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.
27 lines • 800 B
JavaScript
import express from 'express';
export class ExpressPageAdapter {
server;
constructor(server) {
this.server = server;
}
registerStaticFiles(config) {
this.server.use(config.prefix ?? '/', express.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() {
}
}
//# sourceMappingURL=express.js.map