Registry / devops / connect-request-logger-pg

connect-request-logger-pg

JSON →
library0.0.7jsnpmunverified

An Express/Connect middleware that logs HTTP request details directly to a PostgreSQL database with automatic monthly table partitioning. Version 0.0.7 is the last release on npm; the project appears to be unmaintained (no commits since 2013, no activity on GitHub). It supports custom fields from the request object and uses pg-native or pg as the PostgreSQL client. Alternatives include pino-http and morgan with PostgreSQL transport, which are actively maintained.

npm install connect-request-logger-pg
INSTALL
IMPORT
SIG · CONNECT-REQUEST-LO
C
connect-request-logger-pg
devopsjavascriptv0.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import connectReqLogPg from 'connect-request-logger-pg';
const connectReqLogPg = require('connect-request-logger-pg');
ESM named default import, not named export.
express
const logger = require('connect-request-logger-pg');
const logger = require('connect-request-logger-pg').default;
CommonJS require gives the default export directly.
middleware usage
app.use(logger({ connectionString: '...', tableName: 'logs' }));
app.use(connectReqLogPg.logger(...));
The module exports a factory function directly, not a named export.

Sets up Express app with the middleware logging requests to PostgreSQL with automatic table partitioning.

import express from 'express'; import logger from 'connect-request-logger-pg'; const app = express(); app.use(logger({ connectionString: process.env.DATABASE_URL ?? 'postgres://user:pass@localhost/mydb', tableName: 'http_logs' })); app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(3000);
Debug
Known issues
deprecatedThis package has not been updated since 2013 and is effectively unmaintained. Use actively maintained alternatives like pino-http or morgan with PostgreSQL transport.
fix
Migrate to a supported logging middleware (e.g., pino-http).
affects: >=0.0.0
gotchaThe package prefers pg-native over pg. If pg-native is installed, it will be used; otherwise pg must be installed. Ensure at least one PostgreSQL client is available.
fix
Install either `pg` or `pg-native` as a dependency.
affects: >=0.0.0
gotchaThe log function expects a connection object with a `query` method. If using a custom pool, you must pass a client instance, not a pool.
fix
Pass a connected client: `logger({ client: someClient })` instead of a pool.
affects: >=0.0.0
breakingThe module does not support ESM natively. Using `import` may require a bundler or Node.js --experimental-modules flag (Node < 14).
fix
Use CommonJS `require()` or ensure your project is configured to handle CJS dependencies.
affects: >=0.0.0
Errors
Common errors & fixes
ERROR: Cannot find module 'pg'
Missing required PostgreSQL client dependency.
fix
Run `npm install pg` to install the pg module.
TypeError: client.query is not a function
Passed a pool instance instead of a client instance to the middleware.
fix
Obtain a client from the pool: `pool.connect().then(client => { ... })` and pass that client.
Error: Connect middleware expects function
Using logger without calling the factory function (e.g., `app.use(logger)` instead of `app.use(logger(...))`).
fix
Invoke logger with options: `app.use(logger({ ... }))`.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
pgrequiredRequired to communicate with PostgreSQL. Must be installed separately as a peer dependency.
pg-nativeoptionalAlternative PostgreSQL client; if pg-native is installed, it is preferred over pg.
Agent activity
2 hits · last 30 days
node
2
Resources
connect-request-logger-pg — npm install connect-request-logger-pg · libregistry