fix(backend): ensure req.body exists with global parser setup (#9340)

This commit is contained in:
Ulf Gebhardt 2026-03-02 13:34:49 +01:00 committed by GitHub
parent ac228ebdfc
commit 71a00f55ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -27,7 +27,7 @@ export default {
],
coverageThreshold: {
global: {
lines: 93,
lines: 92,
},
},
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],

View File

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import-x/no-named-as-default-member */
@ -126,11 +125,15 @@ const createServer = async (options?: CreateServerOptions) => {
) as any,
)
app.use(express.static('public'))
app.use(bodyParser.json({ limit: '10mb' }) as any)
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }) as any)
app.use(graphqlUploadExpress())
app.use((req, _res, next) => {
if (!req.body) req.body = {}
next()
})
app.use(
'/',
bodyParser.json({ limit: '10mb' }) as any,
bodyParser.urlencoded({ limit: '10mb', extended: true }) as any,
expressMiddleware(server, {
context: async ({ req }) => {
if (options?.context) {