UNPKG

@dazejs/framework

Version:

Daze.js - A powerful web framework for Node.js

25 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Rest = void 0; const utils_1 = require("../utils"); const symbol_1 = require("../symbol"); const defaultRestRoutes = { index: [{ uri: '/', method: 'get' }], create: [{ uri: '/create', method: 'get' }], show: [{ uri: '/:id', method: 'get' }], store: [{ uri: '/', method: 'post' }], edit: [{ uri: '/:id/edit', method: 'get' }], update: [{ uri: '/:id', method: 'put' }], destroy: [{ uri: '/:id', method: 'delete' }], }; const Rest = function (...prefixs) { return function (constructor) { var _a; Reflect.defineMetadata(symbol_1.INJECTABLE, true, constructor); Reflect.defineMetadata('prefixs', (_a = prefixs === null || prefixs === void 0 ? void 0 : prefixs.map(prefix => utils_1.Str.formatPrefix(prefix))) !== null && _a !== void 0 ? _a : ['/'], constructor); const routes = Reflect.getMetadata('routes', constructor); Reflect.defineMetadata('routes', Object.assign(Object.assign({}, defaultRestRoutes), routes), constructor); }; }; exports.Rest = Rest; //# sourceMappingURL=rest.js.map