Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
feat: all achievements route
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonHowe committed Jul 11, 2020
1 parent 0fa4083 commit 80a5421
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Achievement from "../types/Achievement";
import knex from "../../../../db/knex";

export default async () => {
return await knex<Achievement>("achievements");
};
8 changes: 8 additions & 0 deletions packages/api/src/modules/achievements/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });

Expand Down Expand Up @@ -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();

0 comments on commit 80a5421

Please sign in to comment.