summary refs log tree commit diff
path: root/src/api/routes/discovery.ts
blob: 904500350883ae21d01cf8db988ccc53d4f084e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { Categories } from "@fosscord/util";
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";

const router = Router();

router.get("/categories", route({}), async (req: Request, res: Response) => {
	// TODO:
	// Get locale instead

	const { locale, primary_only } = req.query;

	const out = primary_only
		? await Categories.find()
		: await Categories.find({ where: { is_primary: true } });

	res.send(out);
});

export default router;