2019-11-15 16:51:24 +00:00
|
|
|
//! Deps
|
2019-11-19 06:52:41 +00:00
|
|
|
const express = require('express');
|
|
|
|
const helmet = require('helmet');
|
|
|
|
const compression = require('compression');
|
|
|
|
const cors = require('cors');
|
|
|
|
const morgan = require('morgan');
|
|
|
|
const chalk = require('chalk');
|
2019-11-28 19:03:30 +00:00
|
|
|
const hbs = require('express-handlebars');
|
|
|
|
const UA = require('ua-parser-js');
|
2019-11-30 13:14:32 +00:00
|
|
|
const exec = require('shell-exec');
|
2019-11-30 15:26:13 +00:00
|
|
|
const simpleIcons = require('simple-icons');
|
2019-11-30 13:14:32 +00:00
|
|
|
|
2019-11-28 19:03:30 +00:00
|
|
|
const con = require('./constants');
|
2019-11-19 06:52:41 +00:00
|
|
|
let { port, hostname } = {
|
2019-12-17 17:15:11 +00:00
|
|
|
port: 3926
|
2019-12-03 09:31:05 +00:00
|
|
|
//hostname: '67.182.206.28'
|
2019-11-19 06:52:41 +00:00
|
|
|
};
|
2019-11-15 16:51:24 +00:00
|
|
|
|
2019-11-19 06:52:41 +00:00
|
|
|
const app = express();
|
2019-11-15 16:51:24 +00:00
|
|
|
|
2019-11-19 06:52:41 +00:00
|
|
|
app.engine(
|
|
|
|
'hbs',
|
|
|
|
hbs({
|
|
|
|
extname: 'hbs',
|
2019-12-10 20:47:05 +00:00
|
|
|
defaultView: 'default',
|
|
|
|
helpers: {
|
|
|
|
ifeq: function(a, b, options) {
|
|
|
|
if (a === b) {
|
2019-12-17 17:11:26 +00:00
|
|
|
return true;
|
2019-12-10 20:47:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 06:52:41 +00:00
|
|
|
})
|
|
|
|
);
|
2019-12-10 20:47:05 +00:00
|
|
|
|
|
|
|
app.set('view engine', 'hbs');
|
2019-11-15 16:51:24 +00:00
|
|
|
app.set('json spaces', 4);
|
2019-11-19 06:52:41 +00:00
|
|
|
app.use('/assets', express.static('./assets'));
|
2019-11-15 16:51:24 +00:00
|
|
|
app.set('view options', {
|
2019-11-19 06:52:41 +00:00
|
|
|
layout: false
|
2019-11-15 16:51:24 +00:00
|
|
|
});
|
|
|
|
app.use(express.json());
|
2019-11-19 06:52:41 +00:00
|
|
|
app.use(
|
|
|
|
express.urlencoded({
|
|
|
|
extended: true
|
|
|
|
})
|
|
|
|
);
|
2019-11-15 16:51:24 +00:00
|
|
|
app.use(helmet());
|
|
|
|
app.use(compression());
|
|
|
|
app.use(cors());
|
|
|
|
// Logging
|
|
|
|
app.use(
|
2019-11-19 06:52:41 +00:00
|
|
|
morgan((tokens, req, res) => {
|
|
|
|
return [
|
2019-12-09 19:48:19 +00:00
|
|
|
chalk.hex('#34ace0').bold(`[ ${tokens.method(req, res)} ]`),
|
2019-11-19 06:52:41 +00:00
|
|
|
chalk.hex('#ffb142').bold(tokens.status(req, res)),
|
|
|
|
chalk.hex('#ff5252').bold(req.hostname + tokens.url(req, res)),
|
|
|
|
chalk.hex('#2ed573').bold(tokens['response-time'](req, res) + 'ms'),
|
|
|
|
chalk.hex('#f78fb3').bold('@ ' + tokens.date(req, res))
|
|
|
|
].join(' ');
|
|
|
|
})
|
2019-11-15 16:51:24 +00:00
|
|
|
);
|
|
|
|
|
2019-11-19 06:52:41 +00:00
|
|
|
module.exports = (client) => {
|
|
|
|
app.get('/', async (req, res) => {
|
2019-11-28 19:03:30 +00:00
|
|
|
/* var ua = UA(req.headers['user-agent']);
|
|
|
|
console.log(ua) */
|
2019-11-19 06:52:41 +00:00
|
|
|
res.render('index', {
|
|
|
|
layout: 'main',
|
2019-11-28 19:03:30 +00:00
|
|
|
name: con.name,
|
|
|
|
host: req.hostname,
|
2019-12-17 17:11:26 +00:00
|
|
|
item: [ { name: 'TOS', source: '/tos' } ],
|
2019-11-30 13:14:32 +00:00
|
|
|
social: [
|
2019-12-17 17:11:26 +00:00
|
|
|
{ name: 'Twitter', link: 'twitter.com/CorgiYugy', icon: simpleIcons.Twitter },
|
|
|
|
{ name: 'Instagram', link: 'instagram.com/CorgiYugy', icon: simpleIcons.Instagram },
|
|
|
|
{ name: 'Patreon', link: 'Patreon.com/CorgiYugy', icon: simpleIcons.Patreon },
|
|
|
|
{ name: 'Ko-Fi', link: 'ko-fi.com/CorgiYugy', icon: simpleIcons['Ko-fi'] },
|
|
|
|
{ name: 'Trello', link: 'trello.com/b/PTh1X2bw/yugen-the-corgi-commisions', icon: simpleIcons.Trello }
|
2019-11-30 13:14:32 +00:00
|
|
|
]
|
2019-11-19 06:52:41 +00:00
|
|
|
});
|
|
|
|
});
|
2019-12-09 19:48:19 +00:00
|
|
|
|
2019-12-17 19:08:45 +00:00
|
|
|
app.get('/tos', async (req, res) => {
|
|
|
|
/* var ua = UA(req.headers['user-agent']);
|
|
|
|
console.log(ua) */
|
|
|
|
res.render('tos', {
|
|
|
|
layout: 'tos',
|
|
|
|
name: con.name,
|
|
|
|
host: req.hostname,
|
|
|
|
WillDraw: [ 'Furries', 'Toony', 'Cell Shaded', 'Any Species', 'SFW', 'Candy-/Softgore' ],
|
|
|
|
WontDraw: [ 'NSFW', 'Hardgore', 'Feral (unless Chibi)', 'Realism', 'Humans', 'Hard fetish (ask)' ],
|
|
|
|
tos: con.tos
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-12-03 09:31:05 +00:00
|
|
|
app.listen(port /* , hostname */, () => {
|
2019-12-09 19:48:19 +00:00
|
|
|
console.log(`[ Server ] Listening on ${port}`);
|
2019-12-03 09:24:12 +00:00
|
|
|
});
|
2019-11-19 06:52:41 +00:00
|
|
|
};
|