diff options
Diffstat (limited to 'server/src/API/API.ts')
| -rw-r--r-- | server/src/API/API.ts | 33 |
1 files changed, 33 insertions, 0 deletions
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 |