MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / task

Function task

packages/queue/src/tasks/custom-domain-propagate.ts:12–42  ·  view source on GitHub ↗
(logger: Logger)

Source from the content-addressed store, hash-verified

10};
11
12async function task(logger: Logger) {
13 const domains = await prisma.accounts.findMany({
14 select: { id: true, redirectDomain: true, redirectDomainPropagate: true },
15 where: { redirectDomain: { not: null } },
16 });
17 logger.info({ domains: domains.length });
18
19 const promises = domains.map(async (account) => {
20 if (account.redirectDomain) {
21 const res = await axios
22 .head(`https://${account.redirectDomain}/api/health`)
23 .catch((e) => {
24 return { status: 500 };
25 });
26 // it was ok, now isn't
27 if (res.status !== 200 && !!account.redirectDomainPropagate) {
28 await prisma.accounts.update({
29 where: { id: account.id },
30 data: { redirectDomainPropagate: false },
31 });
32 // probably new domain, is ok, it is mark as propagate
33 } else if (res.status === 200 && !account.redirectDomainPropagate) {
34 await prisma.accounts.update({
35 where: { id: account.id },
36 data: { redirectDomainPropagate: true },
37 });
38 }
39 }
40 });
41 await Promise.allSettled(promises);
42}

Callers 1

checkPropagationFunction · 0.70

Calls 3

mapMethod · 0.80
infoMethod · 0.65
updateMethod · 0.45

Tested by

no test coverage detected