express: log to a file, rather than what docker might lose

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-09-15 10:01:56 -04:00
parent efd9572e32
commit 65cd5b2f1e
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED

View file

@ -1,5 +1,6 @@
const express = require('express');
const fs = require('fs');
const path = require('path');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const sqlite3 = require('sqlite3').verbose();
@ -25,8 +26,10 @@ const db = new sqlite3.Database('db/results.db', (err) => {
}
});
var accessLogStream = fs.createWriteStream(path.join(__dirname, 'log', 'access.log'), { flags: 'a' })
app.use(bodyParser.json());
app.use(morgan('combined'));
app.use(morgan('combined', { stream: accessLogStream }));
var animals;
// check and load animals into redis