alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
43 lines (42 loc) • 2.29 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteChainManger = void 0;
const names_1 = require("../names");
class RouteChainManger {
router;
routesNames;
constructor(router, routesNames) {
this.router = router;
this.routesNames = routesNames;
}
getChain(path) {
const routeChain = {
name: (routeName) => {
this.routesNames[routeName] = path;
names_1.RoutesNames[routeName] = path;
// addToRouteList(path, method, routeName, ...handlers);
return routeChain;
},
all: (path, ...handlers) => this.router.all(path, ...handlers),
get: (path, ...handlers) => this.router.get(path, ...handlers),
post: (path, ...handlers) => this.router.post(path, ...handlers),
put: (path, ...handlers) => this.router.put(path, ...handlers),
delete: (path, ...handlers) => this.router.delete(path, ...handlers),
patch: (path, ...handlers) => this.router.patch(path, ...handlers),
options: (path, ...handlers) => this.router.options(path, ...handlers),
head: (path, ...handlers) => this.router["head"](path, ...handlers),
use: (pathOrHandler, ...handlers) => this.router.use(pathOrHandler, ...handlers),
resource: (path, controller, option) => this.router.resource(path, controller, option),
// controller: (path: string, controller: any, option?: ResourceOptions) =>
// this.router.controller(path, controller, option),
resources: (resources, option) => this.router.resources(resources, option),
restfulResources: (resources, option) => this.router.restfulResources(resources, option),
restfulResource: (path, controller, option) => this.router.restfulResource(path, controller, option),
apiResource: (path, controller, option) => this.router.apiResource(path, controller, option),
apiResources: (resources, option) => this.router.apiResources(resources, option),
view: (path, view, data) => this.router.view(path, view, data),
};
return routeChain;
}
}
exports.RouteChainManger = RouteChainManger;
;