Skip to content

Commit 7b1bcba

Browse files
committed
Support regular requests from clients other than apollo-upload-client again.
Fixes #4.
1 parent 73c2a8b commit 7b1bcba

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,23 @@ export function processRequest (request, {uploadDir} = {}) {
3939
})
4040
}
4141

42+
export function apolloUploadKoa (options) {
43+
return async function (ctx, next) {
44+
// Skip if there are no uploads
45+
if (ctx.request.is('multipart/form-data')) {
46+
ctx.request.body = await processRequest(ctx.req, options)
47+
}
48+
await next()
49+
}
50+
}
51+
4252
export function apolloUploadExpress (options) {
4353
return (request, response, next) => {
54+
// Skip if there are no uploads
55+
if (!request.is('multipart/form-data')) return next()
4456
processRequest(request, options).then(body => {
4557
request.body = body
4658
next()
4759
})
4860
}
4961
}
50-
51-
export function apolloUploadKoa (options) {
52-
return async function (ctx, next) {
53-
ctx.request.body = await processRequest(ctx.req, options)
54-
await next()
55-
}
56-
}

0 commit comments

Comments
 (0)