Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
intercept(context: ExecutionContext, next: CallHandler) {
const req = context.switchToHttp().getRequest();
try {
/* istanbul ignore else */
if (!req[PARSED_CRUD_REQUEST_KEY]) {
const { ctrlOptions, crudOptions, action } = this.getCrudInfo(context);
const parser = RequestQueryParser.create();
parser.parseQuery(req.query);
if (!isNil(ctrlOptions)) {
const search = this.getSearch(parser, crudOptions, action, req.params);
const auth = this.getAuth(parser, crudOptions, req);
parser.search = auth.or
? { $or: [auth.or, { $and: search }] }
: { $and: [auth.filter, ...search] };
} else {
parser.search = { $and: this.getSearch(parser, crudOptions, action) };
}
req[PARSED_CRUD_REQUEST_KEY] = this.getCrudRequest(parser, crudOptions);
}