Code review feedback from friends
1. Lazily initialize the database client
https://code.aether.earth/nogweii/qwick-interview-2022/-/blob/main/scraper/src/db.js#L12 can be written with as a getter to lazily initialize the object:
let client;
function getClient() {
if(client) {
return client;
}
return client = makeClient();
}
then
when fetching gitlab version
2. An extra https://code.aether.earth/nogweii/qwick-interview-2022/-/blob/main/scraper/src/sources.js#L45
Mixing the two styles (await
vs .then
) is ugly. The first one (decoding the JSON) is arguable, but the second one is probably is unnecessary.
3. Use Promise.all for the array of versions
Right now it's serial, making the async part fairly useless. I can bundle them all up with Promise.all
and actually be async.