-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
50 lines (43 loc) · 3.06 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
const express = require('express');
const session = require('express-session');
const app = express();
const path = require('path');
const { textSync } = require('figlet');
const chalk = require('chalk');
const axios = require('axios').default;
const settings = require('./settings.json');
const expressWs = require('express-ws');
expressWs(app)
app.set('view engine', 'ejs');
app.use(express.urlencoded({ extended: false }));
app.set('views', path.join(__dirname, '/views'));
app.use(session({
secret: settings.auth.secret,
resave: true,
saveUninitialized: true
}));
axios.get('https://api.github.com/repos/JamieGrimwood/Crosshatch/releases/latest').then(function (response) {
if (response.data.tag_name === "0.0.2") {
console.log(chalk.cyanBright(textSync('Crosshatch', { horizontalLayout: 'fitted' })));
console.log(`${chalk.yellow.bold('#=============================')}${chalk.grey.bold('[')} ${chalk.cyanBright.bold('Crosshatch')} ${chalk.grey.bold(']')}${chalk.yellow.bold('=============================#')}`)
console.log(`${chalk.yellow.bold('#')} ${chalk.magenta.bold('Created by: Jamie09__')} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.green(`You are running an up to date version!`)} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.grey.bold(`Running on port ${settings.port}`)} ${chalk.yellow.bold('#')}`);
console.log(chalk.yellow.bold('#========================================================================#'));
} else {
console.log(chalk.cyanBright(textSync('Crosshatch', { horizontalLayout: 'fitted' })));
console.log(`${chalk.yellow.bold('#=============================')}${chalk.grey.bold('[')} ${chalk.cyanBright.bold('Crosshatch')} ${chalk.grey.bold(']')}${chalk.yellow.bold('=============================#')}`)
console.log(`${chalk.yellow.bold('#')} ${chalk.magenta.bold('Created by: Jamie09__')} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.red(`You are running an out of date version of crosshatch!`)} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.red(`Please update at the link below:`)} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.red(`https://github.com/JamieGrimwood/Crosshatch/releases/`)} ${chalk.yellow.bold('#')}`);
console.log(`${chalk.yellow.bold('#')} ${chalk.grey.bold(`Running on port ${settings.port}`)} ${chalk.yellow.bold('#')}`);
console.log(chalk.yellow.bold('#========================================================================#'));
}
})
app.use(require("./router/api"));
app.use(require("./router/index"));
app.use(require("./router/authenticated"));
app.listen(settings.port, () => {
console.log(`Crosshatch listening on port ${settings.port}`);
});