summary refs log tree commit diff
path: root/api/src/routes/discoverable-guilds.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/discoverable-guilds.ts')
-rw-r--r--api/src/routes/discoverable-guilds.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts
new file mode 100644
index 00000000..0808727f
--- /dev/null
+++ b/api/src/routes/discoverable-guilds.ts
@@ -0,0 +1,17 @@
+import { Guild } from "@fosscord/util";
+import { Router, Request, Response } from "express";
+import { In } from "typeorm";
+
+const router = Router();
+
+router.get("/", async (req: Request, res: Response) => {
+	const { limit } = req.params;
+
+	// ! this only works using SQL querys
+	// TODO: implement this with default typeorm query
+	// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
+	const guilds = await Guild.find({ where: `"features" LIKE 'COMMUNITY'`, take: Math.abs(Number(limit)) });
+	res.send({ guilds: guilds });
+});
+
+export default router;