tmpim / Krist

Krist is a centralized-database economy system for Minecraft servers. Krist does not use a block-chain, or any similar technology. Krist is not a "cryptocurrency".
https://krist.dev/
GNU General Public License v3.0
24 stars 19 forks source link

chore: use async/await where possible #53

Closed lurr closed 2 years ago

lurr commented 3 years ago

This PR replaces all instances of Promise, .catch, and .then with their ES6 counterparts of async/await, where appropriate.

Lemmmy commented 3 years ago

Something is wrong with websocket error handling, this function:

https://github.com/tmpim/Krist/blob/6bdd0357cfd60d8273411938556a3de30736fe34/src/websocket_routes/addresses.js#L38-L44

Will fail very ungracefully if the address wasn't found:

[19:03:40] [Error] Uncaught error.
[19:03:40] TypeError: Cannot read property 'address' of null
    at Function.Addresses.addressToJSON (/home/lem/Projects/krist/src/addresses.js:148:22)
    at Function.AddressesController.addressToJSON (/home/lem/Projects/krist/src/controllers/addresses.js:70:20)
    at Array.address (/home/lem/Projects/krist/src/websocket_routes/addresses.js:43:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async WebSocket.<anonymous> (/home/lem/Projects/krist/src/websockets.js:186:24)

https://github.com/tmpim/Krist/blob/6bdd0357cfd60d8273411938556a3de30736fe34/src/websockets.js#L186 Is this await in the right place?

Lemmmy commented 2 years ago

thank you for your work on this - i believe most of these edits will have been picked up in the typescript refactor, but if you think of anything i might not have caught please let me know :)