dwyl / hapi-postgres-connection

:zap: Creates a PostgreSQL Connection (Pool) available anywhere in your Hapi App
GNU General Public License v2.0
40 stars 13 forks source link

I keep getting this error and I don't know why #39

Closed VictorBaudot closed 6 years ago

VictorBaudot commented 6 years ago

I'm using your example and I keep getting this error: image

I think that this plugin is not up-to-date with the last version of hapi :/

siarcarse commented 6 years ago

Nope! This plugin works on hapi@16 and later. You can use pg on hapi17 with async await. Regards

VictorBaudot commented 6 years ago

Okay, so I cloned the repo, added DATABASE_URL=postgres://victor:@localhost/test and It still crashes... image How can I make it work?

nelsonic commented 6 years ago

@VictorBaudot as @siarcarse suggests, this package is only compatible with Hapi versions below v17. Is your project using Hapi v16?

VictorBaudot commented 6 years ago

as i just downloaded the repo and installed the deps from package.json, yes I'm using Hapi v16

nelsonic commented 6 years ago

@VictorBaudot please try to run npm test on your localhost in the hapi-postgres-connection directory. do tests pass?

VictorBaudot commented 6 years ago

:/ Is it because it does not find my database? image

nelsonic commented 6 years ago

Yep. that's what it looks like ... You appear to be on a UNIX-based system. (Linux/Mac) Can you test your PostgreSQL connection in the terminal; run the pg_isready you should see the following output:

/tmp:5432 - accepting connections
VictorBaudot commented 6 years ago

Yes, I'm on Linux. I can connect to my test db with psql -d test so it should work...

image

I tried to change my env export DATABASE_URL=postgres://victor:@localhost/test multiple times with others users too but not effects

nelsonic commented 6 years ago

@VictorBaudot does your default postgres user not have a password? https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING e.g: export DATABASE_URL=postgresql://victor:password@localhost/test

VictorBaudot commented 6 years ago

I tried with my password too but not working either.

But it finally works.

image

I followed these instructions and npm test is now working. Thanks for your help :)