Skip to content

Commit

Permalink
removed the redundant ok fields
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyTails committed Aug 20, 2024
1 parent 1a5895c commit 858a2b1
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions api/src/server/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ const app = new Hono()

// FIXME: Remove when packaging script reworked
return word && word.usage_category !== "sandbox"
? c.json({ ok: true as const, data: word })
: c.json(
{ ok: false as const, message: `Could not find the word ${c.req.param("word")}` },
400,
);
? c.json({ data: word })
: c.json({ message: `Could not find the word ${c.req.param("word")}` }, 400);
},
)

Expand All @@ -129,10 +126,9 @@ const app = new Hono()
const word = (await rawData).words[c.req.param("word")];
// FIXME: Remove when packaging script reworked
return word && word.usage_category === "sandbox"
? c.json({ ok: true as const, data: word })
? c.json({ data: word })
: c.json(
{
ok: false as const,
message: `Could not find the sandbox word "${c.req.param("word")}"`,
},
400,
Expand All @@ -153,8 +149,8 @@ const app = new Hono()
const sign = (await rawData).fingerspelling[c.req.param("sign")];

return sign
? c.json({ ok: true as const, data: sign })
: c.json({ ok: false as const, message: `Could not find a sign named ${sign}` }, 400);
? c.json({ data: sign })
: c.json({ message: `Could not find a sign named ${sign}` }, 400);
},
)

Expand All @@ -171,8 +167,8 @@ const app = new Hono()
const sign = (await rawData).signs[c.req.param("sign")];

return sign
? c.json({ ok: true as const, data: sign })
: c.json({ ok: false as const, message: `Could not find a sign named ${sign}` }, 400);
? c.json({ data: sign })
: c.json({ message: `Could not find a sign named ${sign}` }, 400);
},
)

Expand All @@ -184,8 +180,8 @@ const app = new Hono()
const font = (await rawData).fonts[c.req.param("font")];

return font
? c.json({ ok: true as const, data: font })
: c.json({ ok: false as const, message: `Could not find a font named ${font}` }, 400);
? c.json({ data: font })
: c.json({ message: `Could not find a font named ${font}` }, 400);
})

.get("/languages", async (c) => {
Expand All @@ -201,11 +197,8 @@ const app = new Hono()
const langId = langIdCoalesce(language, languages);

return langId
? c.json({ ok: true as const, data: languages[langId]! })
: c.json(
{ ok: false as const, message: `Could not find a language named ${language}` },
400,
);
? c.json({ data: languages[langId]! })
: c.json({ message: `Could not find a language named ${language}` }, 400);
},
);

Expand Down

0 comments on commit 858a2b1

Please sign in to comment.