UNPKG

vyndra-js

Version:

Micro Node.js framework with routing, ORM, decorators, and automatic DI

10 lines (9 loc) 405 B
export const ROUTES_KEY = Symbol('routes'); export function defineRoute(target, method, path, handler) { const routes = Reflect.getMetadata(ROUTES_KEY, target.constructor) || []; routes.push({ method, path, handler }); Reflect.defineMetadata(ROUTES_KEY, routes, target.constructor); } export function getRoutes(target) { return Reflect.getMetadata(ROUTES_KEY, target.constructor) || []; }