← Docs
Express
One connection module, any route handler. Middleware-friendly — attach to req or import directly.
Install
npm install @goldlapel/goldlapel Setup
Create a connection module at db.js:
import goldlapel from '@goldlapel/goldlapel';
const conn = await goldlapel.start(process.env.DATABASE_URL);
export default conn; Route Handler
Import the connection and query directly:
import conn from './db.js';
app.get('/users', async (req, res) => {
const result = await conn.query('SELECT * FROM users');
res.json(result.rows);
}); Middleware Pattern
Attach the connection to req for use in any downstream handler:
import conn from './db.js';
app.use((req, res, next) => {
req.db = conn;
next();
}); ORMs
Using Prisma? See @goldlapel/prisma. Using Drizzle? See @goldlapel/drizzle.