Browse Source

fix: Catch clause for in-memory cache retreival

develop
Dale 4 weeks ago
parent
commit
906a8f33d3
2 changed files with 4 additions and 2 deletions
  1. 3
    1
      src/lib/status.ts
  2. 1
    1
      src/lib/xmpp.ts

+ 3
- 1
src/lib/status.ts View File

@@ -5,6 +5,8 @@ import getMumbleStatus from 'src/lib/mumble';
import getMastodonStatus from 'src/lib/mastodon';
import getXMPPStatus from 'src/lib/xmpp';

const defaultStatus = { online: false };

const cache = inMemoryCache({ initial: {}, maxAge: 60000 });
const updateMastodonStatus = () => getMastodonStatus('https://gensokyo.social');
const updateMumbleStatus = () => getMumbleStatus('gensokyo.social');
@@ -14,4 +16,4 @@ export const getFromCache = () => Promise.all([
cache.get('mastodonStatus', { worker: updateMastodonStatus, ttl: 60000 }),
cache.get('mumbleStatus', { worker: updateMumbleStatus, ttl: 60000 }),
cache.get('XMPPStatus', { worker: updateXMPPStatus, ttl: 60000 }),
]).then(R.map(val => val.value));
]).then(R.map(val => val.value)).catch(() => [defaultStatus, defaultStatus, defaultStatus]);

+ 1
- 1
src/lib/xmpp.ts View File

@@ -11,5 +11,5 @@ export default function getXMPPStatus(host: string, port: number = 5222): Promis
return { online: true };
}).catch(() => {
return { online: false };
})
});
}

Loading…
Cancel
Save