-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
43 lines (41 loc) · 1.31 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Koa from 'koa';
import { Routes } from './src/routes';
import MongoProvider from 'eve-esi-client-mongo-provider';
import ESI from 'eve-esi-client';
import { DiscordNotifier } from './src/notifier/discordNotifier';
import { Cron } from './src/scheduler/cron';
require('dotenv').config()
const PORT = process.env.PORT;
const user = process.env?.MONGODB_USER;
const pass = process.env?.MONGODB_PASSWORD;
const provider = new MongoProvider(process.env.MONGODB_URL, {
connectionOptions: {
dbName: 'esi',
user,
pass,
useCreateIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true
}
});
const esi = new ESI({
provider: provider,
clientId: process.env.EVE_CLIENT_ID,
secretKey: process.env.EVE_SECRET,
callbackUri: process.env.CALLBACK_URI
});
const discordNotifer = new DiscordNotifier(provider);
const routes = new Routes(provider, esi, discordNotifer);
const app = new Koa();
var bodyParser = require('koa-body');
//Set up body parsing middleware
app.use(bodyParser({
multipart: true,
urlencoded: true
}));
app.use(routes.getRouter().middleware());
app.listen(PORT, function () {
console.log(`Server listening on port ${PORT}`);
});
//Start scheduler
const cron = new Cron(provider, esi, discordNotifer);