mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-03-22 18:25:29 +00:00
fix(backend): ensure req.body exists with global parser setup (#9340)
This commit is contained in:
parent
ac228ebdfc
commit
71a00f55ca
@ -27,7 +27,7 @@ export default {
|
||||
],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
lines: 93,
|
||||
lines: 92,
|
||||
},
|
||||
},
|
||||
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user