-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
85 lines (69 loc) · 2.25 KB
/
server.js
File metadata and controls
85 lines (69 loc) · 2.25 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const https = require('https');
const fs = require('fs');
const { default: enforceHttps } = require('koa-sslify');
const koastatic = require('koa-static')
const path = require('path');
const Koa = require('koa')
const http = require('http');
const views = require("co-views")
var render = views("public", { map: { html: 'swig' }});
//const sslify = require('koa-sslify').default; // factory with default options
const Router = require('koa-joi-router')
const Joi = Router.Joi
const errorHandler = require('koa-better-error-handler')
const koa404Handler = require('koa-404-handler')
const Boom = require('@hapi/boom')
const bodyParser = require('koa-bodyparser')
//const { default: axios } = require('axios');
const { allowedNodeEnvironmentFlags } = require('process');
const koaCors = require('koa-cors')
const app = new Koa()
const router = Router()
app.context.onerror = errorHandler()
app.use(koa404Handler)
app.use(bodyParser())
app.use(enforceHttps({
port: 443
}));
const koaOptions = {
origin: true,
credentials: true
};
router.get("/", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'home.html' }),
next)
);
router.get("/privacy-policy", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'privacypolicy.html' }),
next)
);
router.get("/discord", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'discord.html' }),
next)
);
router.get("/soon", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'placeholder.html' }),
next)
);
router.get("/seized", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'secret.html' }),
next)
);
router.get("/tos", async(ctx, next) =>
koastatic(`${__dirname}/website/pages`)(
Object.assign(ctx, { path: 'tos.html' }),
next)
);
app.use(router.middleware())
app.use(koaCors(koaOptions))
var options = {
key: fs.readFileSync(`${__dirname}/certificate/private.key`),
cert: fs.readFileSync(`${__dirname}/certificate/certificate.crt`)
}
// http.createServer(app.callback()).listen(80);
https.createServer(options, app.callback()).listen(443);