-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
39 lines (35 loc) · 1.02 KB
/
server.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
import sirv from "sirv";
import express from "express";
import bodyParser from "body-parser";
import session from "express-session";
import compression from "compression";
import sessionFileStore from "session-file-store";
import Gun from "gun";
import { promisifyGun } from "@Utils/promisifyGun";
import * as sapper from "@sapper/server";
const FileStore = sessionFileStore(session);
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === "development";
const app = express();
app.use(
bodyParser.json(),
session({
name: "pokerSession",
secret: "Ra-:4xJ?89h3!C}5",
resave: false,
saveUninitialized: true,
cookie: { maxAge: 31536000 },
store: new FileStore({ path: `.sessions` }),
}),
compression({ threshold: 0 }),
sirv("static", { dev }),
sapper.middleware({
ignore: "gun",
session: ({ sessionID }) => ({ sessionID }),
})
);
const server = app.listen(PORT, (err) => {
if (err) console.log("error", err);
});
promisifyGun(Gun);
export const gun = Gun({ file: ".gun", web: server });