hyphacoop / api.distributed.press

https://distributed.press
GNU Affero General Public License v3.0
77 stars 8 forks source link

backend Json Value Check #4

Closed YurkoWasHere closed 3 years ago

YurkoWasHere commented 3 years ago

Added If ahead of JSON values use that may not exist

Eliminates constant try-catch log entries such as

Feb  9 21:36:00 srv1 node[19072]: TypeError: Cannot read property 'accounts' of undefined
Feb  9 21:36:00 srv1 node[19072]:     at /home/press/api.distributed.press/backend/index.js:80:29
Feb  9 21:36:00 srv1 node[19072]:     at Array.forEach (<anonymous>)
Feb  9 21:36:00 srv1 node[19072]:     at CronJob.<anonymous> (/home/press/api.distributed.press/backend/index.js:67:24)
Feb  9 21:36:00 srv1 node[19072]:     at CronJob.fireOnTick (/home/press/api.distributed.press/backend/node_modules/cron/lib/cron.js:600:23)
Feb  9 21:36:00 srv1 node[19072]:     at Timeout.callbackWrapper [as _onTimeout] (/home/press/api.distributed.press/backend/node_modules/cron/lib/cron.js:667:10)
Feb  9 21:36:00 srv1 node[19072]:     at listOnTimeout (node:internal/timers:556:17)
Feb  9 21:36:00 srv1 node[19072]:     at processTimers (node:internal/timers:499:7)