-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (31 loc) · 1.05 KB
/
index.js
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
const PORT = process.env.tbmPORT || 8080
const cors = require('cors')
const path = require('path').resolve()
const chalk = require('chalk')
const express = require('express')
const packageInfo = require('./package.json')
const api = require('./src/api')
const manage = require('./src/manage')
const app = express()
app.use(cors())
app.use(express.json())
app.use('/manage', express.static(path + '/src/page/'))
app.get('/', (_req, res) => {
res.redirect('/manage/login')
})
app.get('/manage/:page', (req, res) => {
manage.query(req, res)
})
app.get('/manage/:page/:botKey', (req, res) => {
manage.query(req, res, api.bots)
})
app.get('/api/non-secured/:task/:botKey', (req, res) => {
api.nonSecure(req, res)
})
app.post('/api/secured', (req, res) => {
api.secure(req, res)
})
app.listen(PORT, () => {
console.log(packageInfo.name + ' Version ' + packageInfo.version)
console.log(chalk.green('Hello, Welcome to Tritium Networks Bot Manager') + ' | ' + chalk.yellow('Your TBM Server is now online on http://localhost:') + chalk.yellow.bold(PORT))
})