diff options
Diffstat (limited to 'src/api/routes/updates.ts')
-rw-r--r-- | src/api/routes/updates.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/api/routes/updates.ts b/src/api/routes/updates.ts index 8fe6fc2a..275c458b 100644 --- a/src/api/routes/updates.ts +++ b/src/api/routes/updates.ts @@ -1,14 +1,26 @@ import { Router, Response, Request } from "express"; import { route } from "@fosscord/api"; -import { Config, Release } from "@fosscord/util"; +import { Config, FieldErrors, Release } from "@fosscord/util"; const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { const { client } = Config.get(); + const platform = req.query.platform; + + if (!platform) throw FieldErrors({ + platform: { + code: "BASE_TYPE_REQUIRED", + message: req.t("common:field.BASE_TYPE_REQUIRED"), + } + }); const release = await Release.findOneOrFail({ - where: { name: client.releases.upstreamVersion }, + where: { + enabled: true, + platform: platform as string, + }, + order: { pub_date: "DESC" } }); res.json({ |