-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
37 lines (30 loc) · 848 Bytes
/
server.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
import express from "express";
import * as http from "http";
import * as https from "https";
import morgan from "morgan";
import * as path from "path";
import { readFileSync } from "fs";
// initialize express.
const app = express();
// Initialize variables.
let port: number = 3000;
// Configure morgan module to log all requests.
app.use(morgan("dev"));
// Setup app folders.
app.use(express.static("out"));
// Set up a route for index.html
/*app.get("*", (req: express.Request, res: express.Response) => {
res.sendFile(path.join(process.cwd(), "out", "index.html"));
});*/
// Start the server.
http.createServer(app).listen(port, "0.0.0.0");
https
.createServer(
{
key: readFileSync("key.pem"),
cert: readFileSync("cert.pem"),
},
app
)
.listen(8443, "0.0.0.0");
console.log(`Listening on port ${port}...`);