Search code examples
postgresqlknex.jsfeathersjs

How to create FeathersJS services with knex postgres


While trying out FeathersJS, i tried to create two services following the docs. The first is called x and the other y.

When I create x with

~/r/feathers-chat ❯❯❯ feathers generate service
? What kind of service is it? KnexJS
? What is the name of the service? x
? Which path should the service be registered on? /x
? Which database are you connecting to? PostgreSQL
? What is the database connection string?
  postgres://user:password@localhost:5432/feathers_chat

Everything works perfectly.

When I create y

~/r/feathers-chat ❯❯❯ feathers generate service
? What kind of service is it? KnexJS
? What is the name of the service? y
? Which path should the service be registered on? /y
? Which database are you connecting to? PostgreSQL

The following error is thrown.

events.js:160
  throw er; // Unhandled 'error' event
  ^

TypeError: Parameter "url" must be a string, not object
at Url.parse (url.js:88:11)
at Object.urlParse [as parse] (url.js:82:5)
at ConnectionGenerator._getConfiguration (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:46:24)
at ConnectionGenerator._writeConfiguration (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:103:32)
at ConnectionGenerator.writing (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:293:10)
at Object.<anonymous> (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/yeoman-generator/lib/index.js:417:23)
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/run-async/index.js:25:25
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/run-async/index.js:24:19
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/yeoman-generator/lib/index.js:418:9
at runCallback (timers.js:666:20)

It seems that the feathersJS client crashes when there a postgres connection defined in the default.js

So if i create the connection before hand, the client crashes upon creating the first service with the same exact error.

I don't understand what im doing wrong, any help on creating this second service using the same postgres database is appreciated!


Solution

  • Turns out there is a bug in the [email protected], I uninstalled and installed version 2.1.1 and I had no more problems. Will inform of this error.