spacebar/api/src/routes/discoverable-guilds.ts
2021-09-03 23:31:56 +02:00

18 lines
612 B
TypeScript

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;