libsql / libsql-node-sqlite3

node-sqlite3 compatible API for libSQL
MIT License
12 stars 1 forks source link

Throw an error if token is undefined #5

Open penberg opened 1 year ago

penberg commented 1 year ago

Pete Hunt pointed out that passing an undefined token doesn't throw any errors.

honzasp commented 1 year ago

What does it mean for the token to be undefined? The token is passed as a query parameter, so it is always a string.

ujjwal-kr commented 1 year ago

I think it is because of https://github.com/libsql/hrana-client-ts/blob/d3f93e0d7b95b8c9d26e85482faf54b3bf547017/src/libsql_url.ts#L21

ujjwal-kr commented 1 year ago

Maybe I can add

 const parsedUrl = hrana.parseLibsqlUrl(url);
 if (!parsedUrl.authToken) {
   throw new Error("authToken is undefined");
 }

here: https://github.com/libsql/libsql-node-sqlite3/blob/main/src/database.ts#L47 Assign it to me if I should send a PR and test it