feathersjs-ecosystem / generator-feathers

A Yeoman generator for a Feathers application
https://github.com/feathersjs/feathers
MIT License
120 stars 131 forks source link

Parameter "url" must be a string, not object [KnexJS & SQLite] #260

Closed LinusBorg closed 7 years ago

LinusBorg commented 7 years ago

Description of the Problem

In a Project I want to use knexJS and sqlite. I ran feathers genrate authentication with those choices, which generated the users service and a knex.js connection file and all went fine.

Then I tried to generate a second service, and now get the following error:

throw er; // Unhandled 'error' event
      ^
TypeError: Parameter "url" must be a string, not object
    at Url.parse (url.js:102:11)
    at Object.urlParse [as parse] (url.js:96:5)
    at ConnectionGenerator._getConfiguration (/Users/thorstenlunborg/.nvm/versions/node/v8.3.0/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:46:24)

The Source

it appears the generator wants to generate a connection file for knex again(?) and wants to re-use the connection-string from the config file, but for sqlite, it's not a string, it's an object:

"connection": {
      "filename": "db.sqlite"
    }

Steps to reproduce

  1. Run feathers generate app, accept default choices
  2. Run feathers generate service
    • Choose KnexJS
    • name it "test1"
    • Choose "SQLite
    • ... it should install fine
  3. Again, run feathers generate service
    • Choose KnexJS
    • name it "test2"
    • Choose "SQLite
    • and the error appears.
koenverburg commented 7 years ago

I'm getting the same error, did you solve it or not?

I'm trying to switch from Knex to Sequelize.

LinusBorg commented 7 years ago

No, didn't find a fix..

azable commented 7 years ago

+1 Getting the same error here

TNick commented 7 years ago

Moving const parsed = url.parse(connectionString); from line 46 to line 55 (the only block where it is needed) and changing filename: connectionString.substring(9, connectionString.length) to filename: connectionString.filename on line 91 seems to fix the issue; this might be just a superficial fix as I have no understanding whatsoever of the code.

ping @daffl as he seems to be the one who did the work on parsed.

AlokJoshi commented 7 years ago

@daffl. I am getting the same error when I tried using knex SQLite service today. I am using feathers cli version 2.3.5. Can you please suggest a solution?