turtle-express
Version:
`turtle-express` is kinda a framework or a library based on `express.js` with an opinionated express router with type safety and schema validation with zod. Also many [more features](https://github.com/mm-ninja-turtles/turtle-express/discussions/7) planni
27 lines • 959 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRouter = void 0;
const create_path_1 = require("../path/create-path");
function createRouter(_router, _options) {
const basePath = _options?.basePath ?? '/';
return {
use(..._handlers) {
return _router.use(..._handlers);
},
path(path, options) {
return (0, create_path_1.createPath)(path, options);
},
setup(expressApp, options) {
const paths = options.paths;
paths.forEach((eachPath) => {
eachPath._handlers.forEach((eachHandlers) => {
const { _method } = eachHandlers;
_router[_method](eachPath._path, ...eachHandlers._middlewares);
});
});
expressApp.use(basePath, _router);
},
};
}
exports.createRouter = createRouter;
//# sourceMappingURL=create-router.js.map