xonecas.io
4436
Sl

sesame-labs-coding-assignment / files

sesame-labs-coding-assignment / api / dist / routes.js

1.7 KB
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4    return new (P || (P = Promise))(function (resolve, reject) {
5        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8        step((generator = generator.apply(thisArg, _arguments || [])).next());
9    });
10};
11var __importDefault = (this && this.__importDefault) || function (mod) {
12    return (mod && mod.__esModule) ? mod : { "default": mod };
13};
14Object.defineProperty(exports, "__esModule", { value: true });
15const koa_router_1 = __importDefault(require("koa-router"));
16const authentication_1 = __importDefault(require("./authentication"));
17const discord_1 = __importDefault(require("./discord"));
18const quest_1 = __importDefault(require("./quest"));
19const router = new koa_router_1.default();
20router.all("/health-check", (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
21    // Check if server is healthy and has connection to db:
22    ctx.body = `Server is healthy. \n${yield ctx.prisma.user.count()} records found in the db.`;
23    ctx.status = 200;
24    yield next();
25}));
26router
27    .use(authentication_1.default.routes())
28    .use(authentication_1.default.allowedMethods())
29    .use(discord_1.default.routes())
30    .use(discord_1.default.allowedMethods())
31    .use(quest_1.default.routes())
32    .use(quest_1.default.allowedMethods());
33exports.default = router;