experimental: refactoring for pg pool
This commit is contained in:
11
db/Pool.js
Normal file
11
db/Pool.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const { Pool } = require('pg');
|
||||||
|
require('dotenv').config({ path: './config.env' });
|
||||||
|
|
||||||
|
const pool = new Pool({
|
||||||
|
connectionString: process.env.CONNECTION,
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
// text = SQL query; params = array of values to inject
|
||||||
|
query: (text, params) => pool.query(text, params)
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ module.exports = (app) => {
|
|||||||
store: new (require('connect-pg-simple')(session))({
|
store: new (require('connect-pg-simple')(session))({
|
||||||
conString: process.env.CONNECTION,
|
conString: process.env.CONNECTION,
|
||||||
createTableIfMissing: true,
|
createTableIfMissing: true,
|
||||||
|
pruneSessionInterval: 60 * 30
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
const express = require('express');
|
|
||||||
const app = express();
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
const express = require('express');
|
||||||
const PORT = process.env.PORT || 8088;
|
const PORT = process.env.PORT || 8088;
|
||||||
|
|
||||||
|
const app = express();
|
||||||
const loaders = require('./loaders');
|
const loaders = require('./loaders');
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|||||||
Reference in New Issue
Block a user