server: fix TypeError in registerOrFetchInstanceDoc
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
Changelog: Fixed
This commit is contained in:
parent
c5cf167ffa
commit
bdf2e14a73
1 changed files with 7 additions and 3 deletions
|
@ -7,14 +7,18 @@ import { HOUR } from '@/const.js';
|
|||
|
||||
const cache = new Cache<Instance>(
|
||||
HOUR,
|
||||
(host) => Instances.findOneBy({ host }).then(x => x ?? undefined),
|
||||
async (host) => {
|
||||
if (host == null) return undefined;
|
||||
const res = await Instances.findOneBy({ host });
|
||||
return res ?? undefined;
|
||||
} ,
|
||||
);
|
||||
|
||||
export async function registerOrFetchInstanceDoc(idnHost: string): Promise<Instance> {
|
||||
const host = toPuny(idnHost);
|
||||
|
||||
const cached = cache.fetch(host);
|
||||
if (cached) return cached;
|
||||
const cached = await cache.fetch(host);
|
||||
if (cached != null) return cached;
|
||||
|
||||
// apparently a new instance
|
||||
const i = await Instances.insert({
|
||||
|
|
Loading…
Reference in a new issue