Support for Feathers 5 with koa middleware
See original GitHub issueSteps to reproduce
Create a new application with the Feathers 5 (currently 5.0.0-pre.31) generator and choose the defaults but specifically choose these -> (KOA) (JAVASCRIPT) Note: When I chose TypeScript, I couldn’t get past the typescript errors so I went back and used JavaScript.
npx @feathersjs/cli@pre generate app
Add feathers-distributed according to the documentation page: app.js
import feathersDistribution from '@kalisio/feathers-distributed'
...
app.configure(
feathersDistribution({
hooks: {
before: {
all: [
// authenticate('jwt'),
]
}
},
services: (service) => true,
remoteServices: (service) => true
})
)
export { app }
Then try to run the application with
npm run dev
Expected behavior
The application should run like it does with ExpressJS
Actual behavior
Application crashes with the following output:
> server@0.0.0 dev
> nodemon src/
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node src/`
warn: Publishing all events to all authenticated users. See `channels.js` and https://docs.feathersjs.com/api/channels.html for more information.
/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/service.js:55
throw new Error(`Invalid service object passed for path \`${location}\``);
^
Error: Invalid service object passed for path `distribution/healthcheck/:key?`
at wrapService (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/service.js:55:15)
at Feathers.use (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/application.js:107:56)
at Feathers.use (/home/user/code/feathers5-2/server/node_modules/@feathersjs/koa/lib/index.js:48:36)
at Feathers.<anonymous> (file:///home/user/code/feathers5-2/server/node_modules/@kalisio/feathers-distributed/lib/index.js:385:9)
at Feathers.configure (/home/user/code/feathers5-2/server/node_modules/@feathersjs/feathers/lib/application.js:37:18)
at file:///home/user/code/feathers5-2/server/src/app.js:59:5
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
[nodemon] app crashed - waiting for file changes before starting...
I’ve debugged through the feathers-distributed code to the error points, but I don’t know how to fix them.
System configuration
Module versions (especially the part that’s not working): package.json
"dependencies": {
"@feathersjs/authentication": "^5.0.0-pre.31",
"@feathersjs/authentication-local": "^5.0.0-pre.31",
"@feathersjs/authentication-oauth": "^5.0.0-pre.31",
"@feathersjs/configuration": "^5.0.0-pre.31",
"@feathersjs/errors": "^5.0.0-pre.31",
"@feathersjs/feathers": "^5.0.0-pre.31",
"@feathersjs/koa": "^5.0.0-pre.31",
"@feathersjs/mongodb": "^5.0.0-pre.31",
"@feathersjs/schema": "^5.0.0-pre.31",
"@feathersjs/socketio": "^5.0.0-pre.31",
"@feathersjs/transport-commons": "^5.0.0-pre.31",
"@feathersjs/typebox": "^5.0.0-pre.31",
"@kalisio/feathers-distributed": "^2.0.2",
"koa-static": "^5.0.0",
"mongodb": "^4.11.0",
"winston": "^3.8.2"
},
"devDependencies": {
"@feathersjs/authentication-client": "^5.0.0-pre.31",
"@feathersjs/cli": "^5.0.0-pre.31",
"@feathersjs/rest-client": "^5.0.0-pre.31",
"axios": "^0.27.2",
"cross-env": "^7.0.3",
"mocha": "^10.1.0",
"nodemon": "^2.0.20",
"prettier": "^2.7.1"
}
NodeJS version: v16.15.1
NPM version: 8.11.0
Operating System: Ubuntu 22.04.1 LTS
Browser Version: n/a
React Native Version: n/a
Module Loader: n/a
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
@claustres feathers-swaggers working branch for v5 has some test helpers. https://github.com/feathersjs-ecosystem/feathers-swagger/blob/custom-methods-v5/lib/helpers.js
Thanks so much @claustres . I tested the new healthcheck and it works great. I’ll try your suggestion for the errorHandler. I don’t know why I didn’t think of it but it makes sense the way you showed it. Guess I was thinking too hard. 😃