UNPKG

@aprilnea/nest-file-fastify

Version:

fastify-multipart decorators for Nest.js

20 lines 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getParts = exports.getMultipartRequest = void 0; const common_1 = require("@nestjs/common"); /* Function to extract and validate the multipart request from the HTTP context */ const getMultipartRequest = (ctx) => { const req = ctx.getRequest(); if (!req.isMultipart()) { throw new common_1.BadRequestException("Not a multipart request"); } return req; }; exports.getMultipartRequest = getMultipartRequest; /* Function to get the parts of a multipart request */ const getParts = (req, options) => { // Use the Fastify request's parts method to get the multipart parts return req.parts(options); }; exports.getParts = getParts; //# sourceMappingURL=request.js.map