planetscale/database-js

Add database url validator

Meierschlumpf opened this issue ยท 4 comments

It would be great, if the database url that is passed to the connection class would be validated as http / https url. I just spend 2 hours debuging and then realized, that I was using mysql and my local mysql database ๐Ÿ˜‚

I'm not sure how that's true. There's no way database-js can work against a local mysql database. Even if the protocol in the url you pass is mysql://.. we internally just use https always since this library strictly interacts with PlanetScale over https.

Do you have more information about what you think happened?

Yeah it was just me beeing dumb, I was using a mysql connection string for a local database but in my app databasejs was used. So it tried to connect to localhost:443 - The only improvement i see is a validator of the url, so that if someone stumbles over the same issue, he directly knows whats the problem ๐Ÿ˜„

But if it's getting rejected then it's fine to ๐Ÿ‘๐Ÿผ

Ah, ok, yeah, that at least makes sense in that case then that it was trying to connect to a local https server. I think if anything, we should guard against a localhost, but even that, arguably is valid. I've considered writing an HTTP proxy for a local mysql instance so database-js can be used locally against a local mysql. It's come up a few times, so think all around, this is just user error and misconfiguration. I don't think we can sensible validate anything.

Yeah your right, thanks for the quick feedback and have a good one ๐Ÿ‘๐Ÿผ