diia-open-source / be-pkg-db

European Union Public License 1.2
4 stars 4 forks source link

Fs sync access is not a good solution for asyn runtime #2

Open tshemsedinov opened 6 months ago

tshemsedinov commented 6 months ago

We have multiple places like this where fs.existsSyns can be easily be changed to async await syntax

https://github.com/diia-open-source/be-pkg-db/blob/0ac6f89eb7d1a961ced739c033862527caece65f/src/services/database.ts#L165

Consider:

const toBool = [() => true, () => false];
const exists = await fs.promises.access(filePath).then(...toBool);
vird commented 6 months ago

https://github.com/diia-open-source/be-pkg-db/pull/3