UNPKG

@nestjs/core

Version:

The core of NestJS, a TypeScript framework for Node.js backends: modules, dependency injection and the request pipeline, on Express, Fastify or node:http.

29 lines (28 loc) • 995 B
/** * Marks a request whose pipes rejected it. A registered symbol, so packages * that cannot import this module (e.g. an upload interceptor in a platform * package of another version) can still read the marker. */ const REJECTED_BY_PIPES = Symbol.for('nestjs:rejected-by-pipes'); /** * Records that the pipes of `request` rejected it, so its route handler did * not run. */ export function markRejectedByPipes(request) { if (typeof request === 'object' && request !== null) { Object.defineProperty(request, REJECTED_BY_PIPES, { value: true, configurable: true, }); } } /** * Whether the pipes of `request` rejected it, so its route handler did not * run. An interceptor can then release what it prepared for the handler, * e.g. the files an upload interceptor stored. */ export function isRejectedByPipes(request) { return (typeof request === 'object' && request !== null && request[REJECTED_BY_PIPES] === true); }