-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a Koa example #9
Comments
Hi, I don't think that except the middleware using koa will result in a different setup doesn't it ? But maybe your are thinking about something specifically ? Did you try it with koa and experimented some problems ? Thanks for your interest and feedback. |
Some general feedback when I tried to install this library to a feathersjs(v5) projected generated by the CLI.
Honestly at this point I just quit adjusting my code, removed the dependency and moved on. |
Always nice to get some feedback even if we can't probably tackle all of these problems by ourselves.
|
In case you want to follow up this further. I created a stackblitz container, using the cli with typescript + koa and manually added your library according to the docs:
When running this project (npm run dev) I get the following error:
Stackblitz: https://stackblitz.com/edit/stackblitz-starters-ig2b9r?file=src%2Findex.ts |
The problem is that
|
@gustojs Here short explanation how run it on TS project tsconfig.json {
"ts-node": {
"files": true
},
"compilerOptions": {
"target": "es2022",
"module": "NodeNext",
"moduleResolution": "Node16",
"outDir": "./lib",
"rootDir": "./src",
"declaration": true,
"strict": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"skipLibCheck": true,
},
"include": [
"src"
],
"exclude": [
"test"
]
} then in service for example import { discard } from 'feathers-hooks-common'
import type { Application, HookContext } from '../../declarations'
import { storageMethods, storagePath } from './storage.shared'
import { NotFound } from '@feathersjs/errors'
export const storage = async (app: Application) => {
const { Service, getObject } = await import('@kalisio/feathers-s3')
const config = Object.assign({}, app.get('storage'))
const service = new Service(config)
app.use(storagePath, service, {
// A list of all methods this service exposes externally
methods: storageMethods,
// You can add additional custom events to be sent to clients here
events: []
})
app.service(storagePath).path = storagePath
const getObjectPath = config.getObjectPath || '/storage'
app.use(getObjectPath + '/*', getObject(service))
// Initialize hooks
app.service(storagePath).hooks({
before: {
all: [],
find: [],
get: [],
create: [discard('buffer')],
remove: [discard('buffer')]
},
error: {
get: [
(hook: HookContext) => {
if (hook.error.Code === 'NoSuchKey') {
throw new NotFound('Object not found')
}
return hook
}
]
}
})
}
// Add this service to the service type index
declare module '../../declarations' {
interface ServiceTypes {
[storagePath]: any
}
} @claustres I think also would be great add this to documentation. |
All the examples in the readme use Express, but the default for Feathers v5 is Koa. It would be nice to see how to use this library with Koa instead.
Thanks! <3
The text was updated successfully, but these errors were encountered: