
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
connect-pg-pool
Advanced tools
A simple, minimal PostgreSQL session store for Connect/Express with connection pooling
A simple, minimal PostgreSQL session store for Express/Connect with connection pooling.
npm install connect-pg-pool
Once npm installed the module, you need to create the session table in your database. For that you can use the [table.sql] (https://github.com/nDmitry/node-connect-pg-pool/blob/master/table.sql) file provided with the module:
psql mydatabase < node_modules/connect-pg-pool/table.sql
Or simply play the file via a GUI, like the pgAdminIII queries tool.
Express 4:
const session = require('express-session');
const pg = require('pg');
// create a pool once per process and reuse it
const pool = new pg.Pool(/* { your DB config } */);
app.use(session({
store: new (require('connect-pg-pool')(session))({
pool: pool // required option
}),
secret: process.env.FOO_COOKIE_SECRET,
resave: false,
cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days
}));
Express 3 (and similar for Connect):
const express = require('express');
const pg = require('pg');
const pool = new pg.Pool(/* { your DB config } */);
app.use(session({
store: new (require('connect-pg-simple')(express.session))({
pool: pool // required option
}),
secret: process.env.FOO_COOKIE_SECRET,
cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days
}));
session
, then you can specify that here.60
seconds. If set to false
no automatic pruning will happen. Automatic pruning weill happen pruneSessionInterval
seconds after the last pruning – manual or automatic.console.error()
, but can be useful to override if one eg. uses Bunyan for logging.3.0.0
, then the timers will block any graceful shutdown unless you tell the automatic pruning to stop by closing the session handler using this method.false
– which can be useful if one wants improved control of the pruning.FAQs
A simple, minimal PostgreSQL session store for Connect/Express with connection pooling
The npm package connect-pg-pool receives a total of 135 weekly downloads. As such, connect-pg-pool popularity was classified as not popular.
We found that connect-pg-pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.