import { MiddlewareConsumer , Type } from '@nestjs/common' ; import { RouteInfo } from '@nestjs/common/interfaces' ; import { ConfigurableRawBodyMiddleware , JsonBodyMiddleware , RawBodyMiddleware , } from './webhooks.middleware' ; export const applyRawBodyWebhookMiddleware = ( consumer , rawBodyRoutes , jsonBodyRoutes ) => { consumer . apply ( RawBodyMiddleware ) . forRoutes ( ... rawBodyRoutes ) . apply ( JsonBodyMiddleware ) . forRoutes ( ... jsonBodyRoutes ) ; } ; export const applyRawBodyOnlyTo = ( consumer , ... rawBodyRoutes ) => { consumer . apply ( RawBodyMiddleware ) . forRoutes ( ... rawBodyRoutes ) . apply ( JsonBodyMiddleware ) . exclude ( ... rawBodyRoutes ) . forRoutes ( '*' ) ; } ; param consumer param rawBodyRoutes param jsonBodyRoutes export const applyConfigurableRawBodyWebhookMiddleware = ( consumer , rawBodyRoutes , jsonBodyRoutes = [ '*' ] ) => { consumer . apply ( ConfigurableRawBodyMiddleware ) . forRoutes ( ... rawBodyRoutes ) . apply ( JsonBodyMiddleware ) . forRoutes ( ... jsonBodyRoutes ) ; } ;