summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-05-06 18:51:30 +0200
committerTor Andersson <tor@ccxvii.net>2021-05-06 18:51:30 +0200
commite2a88e6065988a637c6ac541ff4abf0181503f4f (patch)
treee08417b1003c06e9ffce3392bc2cbff3bb7d8efb /server.js
parentedfb71ff2054ec41691ccc94237826011a3f9f13 (diff)
downloadserver-e2a88e6065988a637c6ac541ff4abf0181503f4f.tar.gz
server: Save rotating HTTP access log.
Diffstat (limited to 'server.js')
-rw-r--r--server.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/server.js b/server.js
index f980f49..c01f711 100644
--- a/server.js
+++ b/server.js
@@ -18,7 +18,7 @@ const SESSION_SECRET = "Caesar has a big head!";
const MAX_OPEN_GAMES = 3;
-let sessionStore = new SQLiteStore();
+let session_store = new SQLiteStore();
let db = new sqlite3(process.env.DATABASE || "./db");
let app = express();
let http_port = process.env.PORT || 8080;
@@ -36,6 +36,11 @@ let io = {
on: function (ev,fn) { io1.on(ev,fn); io2.on(ev,fn); },
};
+const morgan = require('morgan');
+const rfs = require('rotating-file-stream');
+const log_file = rfs.createStream('access.log', { interval: '1d', path: 'log' });
+app.use(morgan('combined', {stream: log_file}));
+
app.disable('etag');
app.set('view engine', 'ejs');
app.use(body_parser.urlencoded({extended:false}));
@@ -43,7 +48,7 @@ app.use(express_session({
secret: SESSION_SECRET,
resave: false,
saveUninitialized: true,
- store: sessionStore,
+ store: session_store,
cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 }
}));
app.use(connect_flash());
@@ -51,7 +56,7 @@ app.use(connect_flash());
io.use(passport_socket.authorize({
key: 'connect.sid',
secret: SESSION_SECRET,
- store: sessionStore,
+ store: session_store,
}));
const is_immutable = /\.(svg|png|jpg|jpeg|woff2)$/;