steep-balloon-41261
01/04/2023, 2:08 PMbulky-pizza-75657
01/04/2023, 3:10 PMwebhook {}in the nest console. I have outputted both @Body which is supposed to capture req.body and also getting the request and outputting req.body. Same output.
bulky-pizza-75657
01/04/2023, 3:22 PMasync webhook(@Req() req: RawBodyRequest<Request>) {
const raw = req.rawBody; // returns a `Buffer`.
console.log(raw);
I now get undefined.bulky-pizza-75657
01/04/2023, 4:30 PMbulky-pizza-75657
01/04/2023, 4:38 PMimport { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
import { urlencoded, json } from 'express';
import * as bodyParser from 'body-parser';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
bodyParser: false,
});
const rawBodyBuffer = (req, res, buf: Buffer, encoding) => {
console.log('buff', buf.toString());
if (buf && buf.length) {
req.rawBody = buf.toString(encoding || 'utf8');
}
};
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(bodyParser.urlencoded());
app.use(
bodyParser.raw({
verify: rawBodyBuffer,
type: ['*/*'],
}),
);
app.enableCors();
app.setGlobalPrefix('api');
app.use(json({ limit: '50mb' }));
app.use(urlencoded({ extended: true, limit: '50mb' }));
await app.listen(process.env.LISTEN_PORT);
}
bootstrap();magnificent-art-43333
01/04/2023, 5:11 PMbulky-pizza-75657
01/04/2023, 5:45 PMmagnificent-art-43333
01/04/2023, 6:11 PM