From bb511abc03bb66848947e37a999502b813c77269 Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Thu, 23 Jul 2020 23:24:17 -0700 Subject: goodbye old uwufier :cry: --- server/src/API/API.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 server/src/API/API.ts (limited to 'server/src/API/API.ts') diff --git a/server/src/API/API.ts b/server/src/API/API.ts new file mode 100644 index 0000000..8a6eb0f --- /dev/null +++ b/server/src/API/API.ts @@ -0,0 +1,33 @@ +import { AkairoClient } from 'discord-akairo'; +import express, { Application } from 'express'; +import { createServer } from 'http'; +import cors from 'cors'; +import OAuth2 from '../structures/OAuth2'; + +import OAuth2Router from './routers/OAuth2Router'; +import GuildRouter from './routers/GuildRouter'; + +export default class API { + protected client: AkairoClient; + protected server: Application; + protected oauth: OAuth2; + + public constructor(client: AkairoClient) { + this.client = client; + this.oauth = new OAuth2(this.client); + } + + public start(): void { + this.server = express(); + this.server.use(express.json()); + this.server.use(cors({ + origin: true, + credentials: true + })); + + new OAuth2Router(this.server, this.client, this.oauth); + new GuildRouter(this.server, this.client); + + createServer(this.server).listen(8088, (): void => console.log('API is online.')); + } +} \ No newline at end of file -- cgit v1.2.3