toptal / haste-server

open source pastebin written in node.js
https://www.toptal.com/developers/hastebin/about
2.94k stars 795 forks source link

Parse the expiration time as an INT #392

Closed linus-jansson closed 2 years ago

linus-jansson commented 3 years ago

Using .ENV files with haste-server causes the expiration time to be seen as a String. This results in the expireJS being enormously large and causes a "value is out of range for type integer" error, in probably most databases (postgres in my case).

https://github.com/toptal/haste-server/blob/5d2965ffc5d9b309ef6d4be9e8c2288c83d72c73/lib/document_stores/postgres.js#L27

filipechagas commented 2 years ago

Hello @linus-jansson Thank you once more for contributing!

I'm about to merge your PR but I wanted to ask you one last thing: Can you be so kind to check if after the changes applied by https://github.com/toptal/haste-server/pull/366/files this is still necessary?

linus-jansson commented 2 years ago

Good Evening @filipechagas!

I am guessing that docker-entrypoint.js is runned at runtime. (taking env variables and moving them into config.js). I think it's necessary that explicitly specifying the vars (in this case the expire time as a base 10 INT) in the actual query to the database is necessary as specifying it in the query is also a lot less painful if anything would go wrong and DEBUG is needed.