UNPKG

@adonisjs-community/girouette

Version:

An AdonisJS package allowing decorators-based routing.

23 lines (22 loc) 632 B
import { REFLECT_RESOURCE_ONLY_KEY } from '../constants.js'; /** * The `@Only` decorator specifies which CRUD methods should be included in the resource. * * @param names The CRUD methods to include in the resource * * @example * ```ts * @Resource('/posts', 'blog.posts') * @Only(['index', 'show']) * export default class PostsController { * // Generates routes: * // GET /posts (blog.posts.index) * // GET /posts/:id (blog.posts.show) * } * ``` */ export const Only = (names) => { return (target) => { Reflect.defineMetadata(REFLECT_RESOURCE_ONLY_KEY, names, target); }; };