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:
11
app.js
11
app.js
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user