@mee4dy/crud
Version:
Create a backend and frontend in 5 minutes! With our powerful full stack crud system, customize it to suit you.
20 lines (15 loc) • 443 B
text/typescript
import { applyDecorators } from '@nestjs/common';
import { UseMiddleware } from './use-middleware.decorator';
export const UseCrudScope = (callback) => {
const middlewareDecorator = UseMiddleware((req) => {
const crudScope = callback(req);
if (!req.crudCtx) {
req.crudCtx = {};
}
req.crudCtx.params = {
...req.crudCtx.params,
...crudScope,
};
});
return applyDecorators(middlewareDecorator);
};