Gathering detailed insights and metrics for oswedev-connect-pg-simple
Gathering detailed insights and metrics for oswedev-connect-pg-simple
Gathering detailed insights and metrics for oswedev-connect-pg-simple
Gathering detailed insights and metrics for oswedev-connect-pg-simple
A simple, minimal PostgreSQL session store for Express
npm install oswedev-connect-pg-simple
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99.79%)
Shell (0.21%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
242 Stars
395 Commits
74 Forks
5 Watchers
16 Branches
22 Contributors
Updated on Jul 09, 2025
Latest Version
7.0.1
Package Id
oswedev-connect-pg-simple@7.0.1
Unpacked Size
33.76 kB
Size
11.33 kB
File Count
6
NPM Version
6.14.8
Node Version
12.20.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
43
A simple, minimal PostgreSQL session store for Express/Connect
1npm install connect-pg-simple
Once npm installed the module, you need to create the "session" table in your database.
For that you can use the table.sql file provided with the module:
1psql mydatabase < node_modules/connect-pg-simple/table.sql
Or simply play the file via a GUI, like the pgAdminIII queries tool.
Or instruct this module to create it itself, by setting the createTableIfMissing
option.
Note that connect-pg-simple
requires PostgreSQL version 9.5 or above.
Examples are based on Express 4.
Simple example:
1const session = require('express-session'); 2 3app.use(session({ 4 store: new (require('connect-pg-simple')(session))({ 5 // Insert connect-pg-simple options here 6 }), 7 secret: process.env.FOO_COOKIE_SECRET, 8 resave: false, 9 cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days 10 // Insert express-session options here 11}));
Advanced example showing some custom options:
1const pg = require('pg'); 2const expressSession = require('express-session'); 3const pgSession = require('connect-pg-simple')(expressSession); 4 5const pgPool = new pg.Pool({ 6 // Insert pool options here 7}); 8 9app.use(expressSession({ 10 store: new pgSession({ 11 pool : pgPool, // Connection pool 12 tableName : 'user_sessions' // Use another table-name than the default "session" one 13 // Insert connect-pg-simple options here 14 }), 15 secret: process.env.FOO_COOKIE_SECRET, 16 resave: false, 17 cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days 18 // Insert express-session options here 19}));
Listed in the order they will be picked up. If multiple are defined, then the first in the lists that is defined will be used, the rest ignored.
pg-promise
to be used for DB communications.conString
to specify a PostgreSQL Pool connection object and this module will create a new pool for you.conObject
to specify a PostgreSQL connection string and this module will create a new pool for you. If the connection string is in the DATABASE_URL
environment variable (as you do by default on eg. Heroku) – then this module fallback to that if this option is not specified.true
then creates the table in the case where the table does not already exist. Defaults to false
.true
disables the updating of TTL in the database when using touch. Defaults to false.session
, then you can specify that here.60
seconds. If set to false
no automatic pruning will happen. By default every delay is randomized between 50% and 150% of set value, resulting in an average delay equal to the set value, but spread out to even the load on the database. Automatic pruning will happen pruneSessionInterval
seconds after the last pruning (includes manual prunes).false
, then the exact value of pruneSessionInterval
will be used in all delays. No randomization will happen. If multiple instances all start at once, disabling randomization can mean that multiple instances are all triggering pruning at once, causing unnecessary load on the database. Can also be set to a method, taking a numeric delay
parameter and returning a modified one, thus allowing a custom delay algorithm if wanted.console.error()
, but can be useful to override if one eg. uses Bunyan for logging.Promise
that will resolve when the database has shut down.false
– which can be useful if one wants improved control of the pruning.Available as part of the Tidelift Subscription.
The maintainers of connect-pg-simple and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
SAST tool is not run on all commits -- score normalized to 4
Details
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More