mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-26 15:57:47 +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: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
lines: 93,
|
lines: 92,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],
|
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* 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-unsafe-return */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable import-x/no-named-as-default-member */
|
/* eslint-disable import-x/no-named-as-default-member */
|
||||||
@ -126,11 +125,15 @@ const createServer = async (options?: CreateServerOptions) => {
|
|||||||
) as any,
|
) as any,
|
||||||
)
|
)
|
||||||
app.use(express.static('public'))
|
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(graphqlUploadExpress())
|
||||||
|
app.use((req, _res, next) => {
|
||||||
|
if (!req.body) req.body = {}
|
||||||
|
next()
|
||||||
|
})
|
||||||
app.use(
|
app.use(
|
||||||
'/',
|
'/',
|
||||||
bodyParser.json({ limit: '10mb' }) as any,
|
|
||||||
bodyParser.urlencoded({ limit: '10mb', extended: true }) as any,
|
|
||||||
expressMiddleware(server, {
|
expressMiddleware(server, {
|
||||||
context: async ({ req }) => {
|
context: async ({ req }) => {
|
||||||
if (options?.context) {
|
if (options?.context) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user