UNPKG

@avonjs/avonjs

Version:

A fluent Node.js API generator.

41 lines (40 loc) 2.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Dispatcher_1 = __importDefault(require("./Dispatcher")); class default_1 { router; constructor(router) { this.router = router; } register() { this.resourceRoutes(); } resourceRoutes() { // schema this.router.get('/schema', Dispatcher_1.default.dispatch('SchemaController')); // actions API this.router.get('/resources/:resourceName/actions', Dispatcher_1.default.dispatch('ActionIndexController')); // common actions this.router.post('/resources/:resourceName/actions/:actionName', Dispatcher_1.default.dispatch('ActionStoreController')); this.router.post('/resources/:resourceName/:resourceId/actions/:actionName', Dispatcher_1.default.dispatch('ActionStoreController')); // destructive actions this.router.delete('/resources/:resourceName/actions/:actionName', Dispatcher_1.default.dispatch('ActionStoreController')); this.router.delete('/resources/:resourceName/:resourceId/actions/:actionName', Dispatcher_1.default.dispatch('ActionStoreController')); // Associable Resources... this.router.get('/resources/:resourceName/associable/:field', Dispatcher_1.default.dispatch('AssociableController')); // resources API this.router.get('/resources/:resourceName', Dispatcher_1.default.dispatch('ResourceIndexController')); this.router.post('/resources/:resourceName', Dispatcher_1.default.dispatch('ResourceStoreController')); this.router.get('/resources/:resourceName/:resourceId', Dispatcher_1.default.dispatch('ResourceDetailController')); this.router.get('/resources/:resourceName/:resourceId/using/:field', Dispatcher_1.default.dispatch('ResourceLookupByFieldController')); this.router.put('/resources/:resourceName/:resourceId', Dispatcher_1.default.dispatch('ResourceUpdateController')); this.router.delete('/resources/:resourceName/:resourceId', Dispatcher_1.default.dispatch('ResourceDeleteController')); this.router.delete('/resources/:resourceName/:resourceId/force', Dispatcher_1.default.dispatch('ResourceForceDeleteController')); this.router.put('/resources/:resourceName/:resourceId/restore', Dispatcher_1.default.dispatch('ResourceRestoreController')); this.router.get('/resources/:resourceName/:resourceId/review', Dispatcher_1.default.dispatch('ResourceReviewController')); } } exports.default = default_1;