Loading CHANGES.md +10 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,16 @@ Version 1.8.6 To be released. ### @fedify/nestjs - Fixed a critical error that prevented the middleware from processing ActivityPub requests in NestJS applications. The middleware now correctly handles request bodies that have been pre-processed by other NestJS middleware or interceptors. [[#279], [#386] by Jaeyeol Lee] [#279]: https://github.com/fedify-dev/fedify/issues/279 [#386]: https://github.com/fedify-dev/fedify/pull/386 ### @fedify/testing - Updated exports to include context creation functions. Loading docs/manual/integration.md +7 −2 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ import { RequestMethod, } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import * as express from 'express'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DatabaseModule } from './database/database.module'; Loading Loading @@ -439,8 +440,12 @@ export class AppModule implements NestModule { }, ); // Apply middleware to all routes except auth endpoints consumer.apply(fedifyMiddleware).forRoutes({ path: '*', method: RequestMethod.ALL }); // Fedify middleware requires the raw request body for HTTP signature verification // so we apply `express.raw()` before `fedifyMiddleware` to preserve the body. consumer.apply( express.raw({ type: '*/*' }), fedifyMiddleware ).forRoutes({ path: '*', method: RequestMethod.ALL }); } } ~~~~ Loading packages/nestjs/README.md +8 −2 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ import { NestModule, RequestMethod, } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import * as express from 'express'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DatabaseModule } from './database/database.module'; Loading Loading @@ -117,8 +119,12 @@ export class AppModule implements NestModule { }, ); // Apply middleware to all routes except auth endpoints consumer.apply(fedifyMiddleware) // Fedify middleware requires the raw request body for HTTP signature verification // so we apply `express.raw()` before `fedifyMiddleware` to preserve the body. consumer.apply( express.raw({ type: '*/*' }), fedifyMiddleware, ).forRoutes({ path: '*', method: RequestMethod.ALL } } Loading packages/nestjs/src/fedify.middleware.ts +1 −3 Original line number Diff line number Diff line Loading @@ -86,9 +86,7 @@ function fromERequest(req: ERequest): Request { headers, // @ts-ignore: duplex is not supported in Deno, but it is in Node.js duplex: "half", body: req.method === "GET" || req.method === "HEAD" ? undefined : (Readable.toWeb(req)), body: req.method === "GET" || req.method === "HEAD" ? undefined : (req.body && typeof req.body === 'object' && !Buffer.isBuffer(req.body) ? JSON.stringify(req.body) : req.body), }); } Loading Loading
CHANGES.md +10 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,16 @@ Version 1.8.6 To be released. ### @fedify/nestjs - Fixed a critical error that prevented the middleware from processing ActivityPub requests in NestJS applications. The middleware now correctly handles request bodies that have been pre-processed by other NestJS middleware or interceptors. [[#279], [#386] by Jaeyeol Lee] [#279]: https://github.com/fedify-dev/fedify/issues/279 [#386]: https://github.com/fedify-dev/fedify/pull/386 ### @fedify/testing - Updated exports to include context creation functions. Loading
docs/manual/integration.md +7 −2 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ import { RequestMethod, } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import * as express from 'express'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DatabaseModule } from './database/database.module'; Loading Loading @@ -439,8 +440,12 @@ export class AppModule implements NestModule { }, ); // Apply middleware to all routes except auth endpoints consumer.apply(fedifyMiddleware).forRoutes({ path: '*', method: RequestMethod.ALL }); // Fedify middleware requires the raw request body for HTTP signature verification // so we apply `express.raw()` before `fedifyMiddleware` to preserve the body. consumer.apply( express.raw({ type: '*/*' }), fedifyMiddleware ).forRoutes({ path: '*', method: RequestMethod.ALL }); } } ~~~~ Loading
packages/nestjs/README.md +8 −2 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ import { NestModule, RequestMethod, } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import * as express from 'express'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DatabaseModule } from './database/database.module'; Loading Loading @@ -117,8 +119,12 @@ export class AppModule implements NestModule { }, ); // Apply middleware to all routes except auth endpoints consumer.apply(fedifyMiddleware) // Fedify middleware requires the raw request body for HTTP signature verification // so we apply `express.raw()` before `fedifyMiddleware` to preserve the body. consumer.apply( express.raw({ type: '*/*' }), fedifyMiddleware, ).forRoutes({ path: '*', method: RequestMethod.ALL } } Loading
packages/nestjs/src/fedify.middleware.ts +1 −3 Original line number Diff line number Diff line Loading @@ -86,9 +86,7 @@ function fromERequest(req: ERequest): Request { headers, // @ts-ignore: duplex is not supported in Deno, but it is in Node.js duplex: "half", body: req.method === "GET" || req.method === "HEAD" ? undefined : (Readable.toWeb(req)), body: req.method === "GET" || req.method === "HEAD" ? undefined : (req.body && typeof req.body === 'object' && !Buffer.isBuffer(req.body) ? JSON.stringify(req.body) : req.body), }); } Loading