From 80a54214dfd8036f6075cf81ce80202c7aa44714 Mon Sep 17 00:00:00 2001 From: xWafl <73sampleperson@gmail.com> Date: Sat, 11 Jul 2020 16:44:32 -0400 Subject: [PATCH] feat: all achievements route --- .../src/modules/achievements/actions/getAchievements.ts | 6 ++++++ packages/api/src/modules/achievements/router.ts | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 packages/api/src/modules/achievements/actions/getAchievements.ts diff --git a/packages/api/src/modules/achievements/actions/getAchievements.ts b/packages/api/src/modules/achievements/actions/getAchievements.ts new file mode 100644 index 0000000..218acdf --- /dev/null +++ b/packages/api/src/modules/achievements/actions/getAchievements.ts @@ -0,0 +1,6 @@ +import Achievement from "../types/Achievement"; +import knex from "../../../../db/knex"; + +export default async () => { + return await knex("achievements"); +}; diff --git a/packages/api/src/modules/achievements/router.ts b/packages/api/src/modules/achievements/router.ts index dc4e3fd..988362b 100644 --- a/packages/api/src/modules/achievements/router.ts +++ b/packages/api/src/modules/achievements/router.ts @@ -4,6 +4,7 @@ import { HttpError } from "../../common/error/classes/httpError"; import editAchievement from "./actions/editAchievement"; import { requireAdmin } from "../auth/middleware/requireAdmin"; import deleteAchievement from "./actions/deleteAchievement"; +import getAchievements from "./actions/getAchievements"; const router = new Router({ prefix: "/achievement" }); @@ -37,4 +38,11 @@ router.delete("/deleteAchievement", requireAdmin(), async (ctx, next) => { await next(); }); +router.get("/", async (ctx, next) => { + const data = await getAchievements(); + ctx.status = 200; + ctx.body = data; + await next(); +}); + export default router.routes();