UNPKG

@adonisjs-community/girouette

Version:

An AdonisJS package allowing decorators-based routing.

26 lines (25 loc) 800 B
import { REFLECT_RESOURCE_EXCEPT_KEY } from '../constants.js'; /** * The `@Except` decorator specifies which CRUD methods should be excluded from the resource. * * @param names The CRUD methods to exclude from the resource * * @example * ```ts * @Resource('/posts', 'blog.posts') * @Except(['create', 'show']) * export default class PostsController { * // Generates routes: * // GET /posts (blog.posts.index) * // POST /posts (blog.posts.store) * // GET /posts/:id/edit (blog.posts.edit) * // PUT /posts/:id (blog.posts.update) * // DELETE /posts/:id (blog.posts.destroy) * } * ``` */ export const Except = (names) => { return (target) => { Reflect.defineMetadata(REFLECT_RESOURCE_EXCEPT_KEY, names, target); }; };