1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-02 18:39:29 +00:00

Refactored database connection system to use a shared pool per-request

This commit is contained in:
2022-03-23 23:29:55 +00:00
parent bd662661ee
commit 4c2a078530
14 changed files with 162 additions and 144 deletions

11
app.js
View File

@@ -41,14 +41,21 @@ async function main() {
const serverOptions = importJSON('server');
const sessionOptions = importJSON('session');
const dbp = await new DatabaseConnectionPool();
// Set up express-session to store in mysql database
const mysqlStore = require('express-mysql-session')(session);
const sessionStore =
new mysqlStore({}, (await new DatabaseConnectionPool()).pool);
const sessionStore = new mysqlStore({}, dbp.pool);
// Initialise express app
const app = express();
// Set up global database pool
app.use((req, res, next) => {
req.db = dbp;
next();
});
// Set up templating language and path
app.engine(
'hbs',