2 |
import express, { Application, Request, Response } from 'express'; |
import express, { Application, Request, Response } from 'express'; |
3 |
import routes from './routes'; |
import routes from './routes'; |
4 |
import router from "./Router"; |
import router from "./Router"; |
5 |
|
import pubRouter from "./PublicRouter"; |
6 |
import { readFileSync } from "fs"; |
import { readFileSync } from "fs"; |
7 |
import path from "path"; |
import path from "path"; |
8 |
|
|
17 |
|
|
18 |
constructor(protected client: DiscordClient) { |
constructor(protected client: DiscordClient) { |
19 |
this.app = express(); |
this.app = express(); |
20 |
this.guildData = JSON.parse(readFileSync(path.resolve(__dirname, '..', '..', 'config', 'apiguilds.json')).toString()); |
const data: typeof this.guildData = {}; |
21 |
|
|
22 |
|
for (const key of Object.keys(process.env)) { |
23 |
|
if (key.startsWith('TOKEN_')) { |
24 |
|
data[key.replace(/^TOKEN_/g, '')] = { |
25 |
|
token: process.env[key]! |
26 |
|
}; |
27 |
|
} |
28 |
|
} |
29 |
|
|
30 |
|
this.guildData = data; |
31 |
|
console.log(data); |
32 |
} |
} |
33 |
|
|
34 |
verifyToken(guild: string, token: string): boolean { |
verifyToken(guild: string, token: string): boolean { |
49 |
res.send("Server is up."); |
res.send("Server is up."); |
50 |
}); |
}); |
51 |
|
|
52 |
|
this.app.use('/pub', pubRouter); |
53 |
this.app.use('/api', router); |
this.app.use('/api', router); |
54 |
} |
} |
55 |
|
|