Our great sponsors
-
nestjs
A collection of badass modules and utilities to help you level up your NestJS applications 🚀
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
import { Injectable, NestMiddleware } from '@nestjs/common' import { json } from 'body-parser' /** * Copied this middleware to parse the raw response into a param to use later * from https://github.com/golevelup/nestjs/blob/master/packages/webhooks/src/webhooks.middleware.ts */ @Injectable() export class RawBodyMiddleware implements NestMiddleware { public constructor() {} public use(req: Request, res: Response, next: () => any): any { json({ verify: (req: any, res, buffer) => { if (Buffer.isBuffer(buffer)) { const rawBody = Buffer.from(buffer) req['parsedRawBody'] = rawBody } return true }, })(req, res as any, next) } }
Related posts
- Are there any guides for message brokers in a traditional NestJS REST app?
- Providing Providers to Dynamic NestJS Modules
- What are some good practises for mocking providers in tests
- How to Build a Node.js GraphQL API With NestJS and Prisma
- How to Become a Node.js Backend Developer? Share Helpful Resources!