File tree Expand file tree Collapse file tree 7 files changed +342
-181
lines changed
Expand file tree Collapse file tree 7 files changed +342
-181
lines changed Original file line number Diff line number Diff line change 2828 "@monkeytype/contracts" : " workspace:*" ,
2929 "@monkeytype/funbox" : " workspace:*" ,
3030 "@monkeytype/util" : " workspace:*" ,
31- "@ts-rest/core" : " 3.51.0 " ,
32- "@ts-rest/express" : " 3.51.0 " ,
33- "@ts-rest/open-api" : " 3.51.0 " ,
31+ "@ts-rest/core" : " 3.52.1 " ,
32+ "@ts-rest/express" : " 3.52.1 " ,
33+ "@ts-rest/open-api" : " 3.52.1 " ,
3434 "bcrypt" : " 5.1.1" ,
3535 "bullmq" : " 1.91.1" ,
3636 "chalk" : " 4.1.2" ,
3939 "date-fns" : " 3.6.0" ,
4040 "dotenv" : " 16.4.5" ,
4141 "etag" : " 1.8.1" ,
42- "express" : " 4.21.1 " ,
43- "express-rate-limit" : " 7.4.0 " ,
42+ "express" : " 5.1.0 " ,
43+ "express-rate-limit" : " 7.5.1 " ,
4444 "firebase-admin" : " 12.0.0" ,
4545 "helmet" : " 4.6.0" ,
4646 "ioredis" : " 4.28.5" ,
7272 "@types/bcrypt" : " 5.0.2" ,
7373 "@types/cors" : " 2.8.12" ,
7474 "@types/cron" : " 1.7.3" ,
75- "@types/express" : " 4.17.21 " ,
75+ "@types/express" : " 5.0.3 " ,
7676 "@types/ioredis" : " 4.28.10" ,
7777 "@types/lodash" : " 4.14.178" ,
7878 "@types/mjml" : " 4.7.4" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111import { compatibilityCheckMiddleware } from "./middlewares/compatibilityCheck" ;
1212import { COMPATIBILITY_CHECK_HEADER } from "@monkeytype/contracts" ;
1313import { createETagGenerator } from "./utils/etag" ;
14+ import { v4RequestBody } from "./middlewares/utility" ;
1415
1516const etagFn = createETagGenerator ( { weak : true } ) ;
1617
@@ -29,6 +30,7 @@ function buildApp(): express.Application {
2930
3031 app . use ( badAuthRateLimiterHandler ) ;
3132 app . use ( rootRateLimiter ) ;
33+ app . use ( v4RequestBody ) ;
3234
3335 app . set ( "etag" , etagFn ) ;
3436
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export function rateLimitRequest<
129129 )
130130 ) ;
131131 } else {
132- rateLimiter ( req , res , next ) ;
132+ await rateLimiter ( req , res , next ) ;
133133 }
134134 } ;
135135}
Original file line number Diff line number Diff line change @@ -45,3 +45,22 @@ export function getMetadata(req: TsRestRequestWithContext): EndpointMetadata {
4545 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4646 return ( req . tsRestRoute [ "metadata" ] ?? { } ) as EndpointMetadata ;
4747}
48+
49+ /**
50+ * The req.body property returns undefined when the body has not been parsed. In Express 4, it returns {} by default.
51+ * Restore the v4 behavior
52+ * @param req
53+ * @param _res
54+ * @param next
55+ */
56+ export async function v4RequestBody (
57+ req : Request ,
58+ _res : Response ,
59+ next : NextFunction
60+ ) : Promise < void > {
61+ if ( req . body === undefined ) {
62+ req . body = { } ;
63+ }
64+
65+ next ( ) ;
66+ }
Original file line number Diff line number Diff line change 8585 "@monkeytype/util" : " workspace:*" ,
8686 "@sentry/browser" : " 9.14.0" ,
8787 "@sentry/vite-plugin" : " 3.3.1" ,
88- "@ts-rest/core" : " 3.51.0 " ,
88+ "@ts-rest/core" : " 3.52.1 " ,
8989 "balloon-css" : " 1.2.0" ,
9090 "canvas-confetti" : " 1.5.1" ,
9191 "chart.js" : " 3.7.1" ,
Original file line number Diff line number Diff line change 1212 "lint" : " npm run oxlint && npm run eslint"
1313 },
1414 "peerDependencies" : {
15- "@ts-rest/core" : " 3.51.0 " ,
15+ "@ts-rest/core" : " 3.52.1 " ,
1616 "zod" : " 3.23.8"
1717 },
1818 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments