-
migrating an app from feathersjs/express to feathersjs/koa
by service definition I mean this
following this I can use
but in feathersjs/koa , you need to use koa-multer right? and you need Koa-router to use it the second middleware function can directly call function1() so service definition is not needed I do register the routes following this since I need to use koa-router for koa-multer, how do I register the router as a service? or is there another way to do it the main thing is that I need to upload a .glb with a feathersjs/koa application I saw this discussion I hope more can be elaborated on this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
i cant seem to find a way to use koa-router , but you can use before: service middle wate with koa multer instead import Multer from 'koa-multer' |
Beta Was this translation helpful? Give feedback.
i cant seem to find a way to use koa-router , but you can use before: service middle wate with koa multer instead
example snippet
import Multer from 'koa-multer'
const multipartMiddleware = Multer({ limits: { fieldSize: Infinity, files: 1 } })
// other code
app.use(
'upload',
{
create: upload(app)
},
{
koa: {
before: [
multipartMiddleware.any(),
async (ctx, next) => {
console.log('trying to upload file')
// handle as needed
await next()
console.log('uploaded file')
return ctx.body
}
]
}
}