worker-que 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +337 -0
- package/DASHBOARD.md +254 -252
- package/README.md +362 -261
- package/package.json +2 -3
- package/DASHBOARD-QUICKSTART.md +0 -278
- package/SSL-QUICK-REFERENCE.md +0 -225
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worker-que",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A TypeScript job queue library for PostgreSQL with real-time web dashboard, SSL support, and cross-language compatibility",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
"README.md",
|
|
23
23
|
"LICENSE",
|
|
24
24
|
"DASHBOARD.md",
|
|
25
|
-
"DASHBOARD-QUICKSTART.md",
|
|
26
25
|
"SSL.md",
|
|
27
|
-
"
|
|
26
|
+
"CONTRIBUTING.md"
|
|
28
27
|
],
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build": "tsc",
|
package/DASHBOARD-QUICKSTART.md
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
# Dashboard Quick Start Guide
|
|
2
|
-
|
|
3
|
-
Get your Que dashboard up and running in 5 minutes!
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Node.js 16+ installed
|
|
8
|
-
- PostgreSQL database with `que_jobs` table
|
|
9
|
-
- Express.js installed
|
|
10
|
-
|
|
11
|
-
## Step 1: Install Dependencies
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install que-ts express
|
|
15
|
-
npm install --save-dev @types/express # If using TypeScript
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Step 2: Create Dashboard Server
|
|
19
|
-
|
|
20
|
-
Create a file `dashboard.js` (or `dashboard.ts`):
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
const express = require('express');
|
|
24
|
-
const { Pool } = require('pg');
|
|
25
|
-
const { createDashboard } = require('que-ts/dashboard');
|
|
26
|
-
|
|
27
|
-
const app = express();
|
|
28
|
-
const pool = new Pool({
|
|
29
|
-
host: 'localhost',
|
|
30
|
-
port: 5432,
|
|
31
|
-
database: 'your_database',
|
|
32
|
-
user: 'your_user',
|
|
33
|
-
password: 'your_password',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Mount dashboard
|
|
37
|
-
app.use('/queue', createDashboard(pool, {
|
|
38
|
-
title: 'My Queue Dashboard',
|
|
39
|
-
refreshInterval: 3000, // Refresh every 3 seconds
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const PORT = process.env.PORT || 3000;
|
|
43
|
-
app.listen(PORT, () => {
|
|
44
|
-
console.log(`Dashboard running at http://localhost:${PORT}/queue`);
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Step 3: Run the Server
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
node dashboard.js
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Step 4: Open in Browser
|
|
55
|
-
|
|
56
|
-
Visit http://localhost:3000/queue
|
|
57
|
-
|
|
58
|
-
You should see:
|
|
59
|
-
- 📊 Real-time job statistics
|
|
60
|
-
- 📈 Charts showing distribution by queue and class
|
|
61
|
-
- 📋 Paginated job list with filters
|
|
62
|
-
- ⚠️ Recent failures section
|
|
63
|
-
|
|
64
|
-
## Step 5: Add Authentication (Production)
|
|
65
|
-
|
|
66
|
-
For production, always add authentication:
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
app.use('/queue', createDashboard(pool, {
|
|
70
|
-
title: 'Production Queue',
|
|
71
|
-
auth: (req, res, next) => {
|
|
72
|
-
// Check API key
|
|
73
|
-
const apiKey = req.headers['x-api-key'];
|
|
74
|
-
if (apiKey === process.env.DASHBOARD_API_KEY) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Or check session
|
|
79
|
-
if (req.session?.user?.isAdmin) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return false; // Deny access
|
|
84
|
-
}
|
|
85
|
-
}));
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## TypeScript Version
|
|
89
|
-
|
|
90
|
-
If using TypeScript:
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import express from 'express';
|
|
94
|
-
import { Pool } from 'pg';
|
|
95
|
-
import { createDashboard } from 'que-ts/dashboard';
|
|
96
|
-
|
|
97
|
-
const app = express();
|
|
98
|
-
const pool = new Pool({
|
|
99
|
-
host: 'localhost',
|
|
100
|
-
port: 5432,
|
|
101
|
-
database: 'your_database',
|
|
102
|
-
user: 'your_user',
|
|
103
|
-
password: 'your_password',
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
app.use('/queue', createDashboard(pool, {
|
|
107
|
-
title: 'My Queue Dashboard',
|
|
108
|
-
refreshInterval: 3000,
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
|
-
const PORT = process.env.PORT || 3000;
|
|
112
|
-
app.listen(PORT, () => {
|
|
113
|
-
console.log(`Dashboard: http://localhost:${PORT}/queue`);
|
|
114
|
-
});
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Complete Example with Worker
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import express from 'express';
|
|
121
|
-
import { Pool } from 'pg';
|
|
122
|
-
import { createDashboard } from 'que-ts/dashboard';
|
|
123
|
-
import { Client, Worker } from 'que-ts';
|
|
124
|
-
|
|
125
|
-
const dbConfig = {
|
|
126
|
-
host: 'localhost',
|
|
127
|
-
port: 5432,
|
|
128
|
-
database: 'myapp',
|
|
129
|
-
user: 'postgres',
|
|
130
|
-
password: 'password',
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Create Express app
|
|
134
|
-
const app = express();
|
|
135
|
-
const pool = new Pool(dbConfig);
|
|
136
|
-
|
|
137
|
-
// Add dashboard
|
|
138
|
-
app.use('/admin/queue', createDashboard(pool, {
|
|
139
|
-
title: 'My App Queue',
|
|
140
|
-
refreshInterval: 2000,
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
// Create worker
|
|
144
|
-
const worker = new Worker(dbConfig, { interval: 1000 });
|
|
145
|
-
|
|
146
|
-
worker.register('SendEmail', async (job) => {
|
|
147
|
-
const [emailData] = job.args;
|
|
148
|
-
console.log(`Sending email to ${emailData.to}`);
|
|
149
|
-
// Your email logic here
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
worker.register('ProcessPayment', async (job) => {
|
|
153
|
-
const [paymentData] = job.args;
|
|
154
|
-
console.log(`Processing payment: $${paymentData.amount}`);
|
|
155
|
-
// Your payment logic here
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Start server and worker
|
|
159
|
-
const PORT = 3000;
|
|
160
|
-
app.listen(PORT, () => {
|
|
161
|
-
console.log(`Server: http://localhost:${PORT}`);
|
|
162
|
-
console.log(`Dashboard: http://localhost:${PORT}/admin/queue`);
|
|
163
|
-
|
|
164
|
-
// Start worker
|
|
165
|
-
worker.work().catch(console.error);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Graceful shutdown
|
|
169
|
-
process.on('SIGINT', async () => {
|
|
170
|
-
await worker.shutdown();
|
|
171
|
-
await pool.end();
|
|
172
|
-
process.exit(0);
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Troubleshooting
|
|
177
|
-
|
|
178
|
-
### "Cannot find module 'que-ts/dashboard'"
|
|
179
|
-
|
|
180
|
-
Make sure you're importing from the compiled distribution:
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
// CommonJS
|
|
184
|
-
const { createDashboard } = require('que-ts/dist/dashboard');
|
|
185
|
-
|
|
186
|
-
// ES6
|
|
187
|
-
import { createDashboard } from 'que-ts/dist/dashboard';
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Or update your package.json exports (for library authors).
|
|
191
|
-
|
|
192
|
-
### Dashboard shows no data
|
|
193
|
-
|
|
194
|
-
1. Check that `que_jobs` table exists
|
|
195
|
-
2. Verify database connection is working
|
|
196
|
-
3. Check browser console for errors
|
|
197
|
-
4. Verify API routes are accessible (try `/queue/api/stats`)
|
|
198
|
-
|
|
199
|
-
### Authentication not working
|
|
200
|
-
|
|
201
|
-
1. Make sure auth function returns boolean (true/false)
|
|
202
|
-
2. For async auth, declare function as `async`
|
|
203
|
-
3. Check browser console for 403 errors
|
|
204
|
-
|
|
205
|
-
## Next Steps
|
|
206
|
-
|
|
207
|
-
- Read the full [DASHBOARD.md](DASHBOARD.md) documentation
|
|
208
|
-
- Explore API routes for programmatic access
|
|
209
|
-
- Add custom authentication
|
|
210
|
-
- Configure for production deployment
|
|
211
|
-
|
|
212
|
-
## Environment Variables
|
|
213
|
-
|
|
214
|
-
For production, use environment variables:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
# .env
|
|
218
|
-
DB_HOST=localhost
|
|
219
|
-
DB_PORT=5432
|
|
220
|
-
DB_NAME=myapp
|
|
221
|
-
DB_USER=postgres
|
|
222
|
-
DB_PASSWORD=secret
|
|
223
|
-
DASHBOARD_PATH=/admin/queue
|
|
224
|
-
DASHBOARD_TITLE=Production Queue
|
|
225
|
-
DASHBOARD_REFRESH_MS=5000
|
|
226
|
-
DASHBOARD_API_KEY=your-secret-key
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
```javascript
|
|
230
|
-
require('dotenv').config();
|
|
231
|
-
|
|
232
|
-
const pool = new Pool({
|
|
233
|
-
host: process.env.DB_HOST,
|
|
234
|
-
port: parseInt(process.env.DB_PORT),
|
|
235
|
-
database: process.env.DB_NAME,
|
|
236
|
-
user: process.env.DB_USER,
|
|
237
|
-
password: process.env.DB_PASSWORD,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
app.use(process.env.DASHBOARD_PATH, createDashboard(pool, {
|
|
241
|
-
title: process.env.DASHBOARD_TITLE,
|
|
242
|
-
refreshInterval: parseInt(process.env.DASHBOARD_REFRESH_MS),
|
|
243
|
-
auth: (req) => req.headers['x-api-key'] === process.env.DASHBOARD_API_KEY
|
|
244
|
-
}));
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
## Docker Deployment
|
|
248
|
-
|
|
249
|
-
```dockerfile
|
|
250
|
-
FROM node:18-alpine
|
|
251
|
-
|
|
252
|
-
WORKDIR /app
|
|
253
|
-
COPY package*.json ./
|
|
254
|
-
RUN npm ci --only=production
|
|
255
|
-
|
|
256
|
-
COPY . .
|
|
257
|
-
|
|
258
|
-
ENV NODE_ENV=production
|
|
259
|
-
ENV PORT=3000
|
|
260
|
-
|
|
261
|
-
EXPOSE 3000
|
|
262
|
-
|
|
263
|
-
CMD ["node", "dashboard.js"]
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
docker build -t my-queue-dashboard .
|
|
268
|
-
docker run -p 3000:3000 \
|
|
269
|
-
-e DB_HOST=postgres \
|
|
270
|
-
-e DB_NAME=myapp \
|
|
271
|
-
-e DB_USER=postgres \
|
|
272
|
-
-e DB_PASSWORD=secret \
|
|
273
|
-
my-queue-dashboard
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
**Need Help?** Check the full documentation at [DASHBOARD.md](DASHBOARD.md)
|
package/SSL-QUICK-REFERENCE.md
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
# SSL Quick Reference
|
|
2
|
-
|
|
3
|
-
## Quick SSL Setup Examples
|
|
4
|
-
|
|
5
|
-
### 1. Basic SSL (No Certificates)
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { Client } from 'que-ts';
|
|
9
|
-
|
|
10
|
-
const client = new Client({
|
|
11
|
-
host: 'db.example.com',
|
|
12
|
-
port: 5432,
|
|
13
|
-
database: 'mydb',
|
|
14
|
-
user: 'myuser',
|
|
15
|
-
password: 'mypass',
|
|
16
|
-
ssl: { rejectUnauthorized: true }
|
|
17
|
-
});
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### 2. SSL with Client Certificates
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import * as fs from 'fs';
|
|
24
|
-
|
|
25
|
-
const client = new Client({
|
|
26
|
-
host: 'db.example.com',
|
|
27
|
-
port: 5432,
|
|
28
|
-
database: 'mydb',
|
|
29
|
-
user: 'myuser',
|
|
30
|
-
password: 'mypass',
|
|
31
|
-
ssl: {
|
|
32
|
-
rejectUnauthorized: true,
|
|
33
|
-
cert: fs.readFileSync('./client-cert.pem'),
|
|
34
|
-
key: fs.readFileSync('./client-key.pem'),
|
|
35
|
-
ca: fs.readFileSync('./ca-cert.pem'),
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### 3. Using Environment Variables
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
// .env file:
|
|
44
|
-
// DB_SSL_CERT=/path/to/client-cert.pem
|
|
45
|
-
// DB_SSL_KEY=/path/to/client-key.pem
|
|
46
|
-
// DB_SSL_CA=/path/to/ca-cert.pem
|
|
47
|
-
|
|
48
|
-
import * as fs from 'fs';
|
|
49
|
-
import * as dotenv from 'dotenv';
|
|
50
|
-
dotenv.config();
|
|
51
|
-
|
|
52
|
-
const client = new Client({
|
|
53
|
-
host: process.env.DB_HOST,
|
|
54
|
-
port: parseInt(process.env.DB_PORT || '5432'),
|
|
55
|
-
database: process.env.DB_NAME,
|
|
56
|
-
user: process.env.DB_USER,
|
|
57
|
-
password: process.env.DB_PASSWORD,
|
|
58
|
-
ssl: {
|
|
59
|
-
rejectUnauthorized: true,
|
|
60
|
-
cert: fs.readFileSync(process.env.DB_SSL_CERT!),
|
|
61
|
-
key: fs.readFileSync(process.env.DB_SSL_KEY!),
|
|
62
|
-
ca: fs.readFileSync(process.env.DB_SSL_CA!),
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Cloud Providers
|
|
68
|
-
|
|
69
|
-
### AWS RDS
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
// Download CA bundle: https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
|
|
73
|
-
const client = new Client({
|
|
74
|
-
host: 'instance.region.rds.amazonaws.com',
|
|
75
|
-
ssl: {
|
|
76
|
-
rejectUnauthorized: true,
|
|
77
|
-
ca: fs.readFileSync('./rds-ca-bundle.pem'),
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Google Cloud SQL
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
const client = new Client({
|
|
86
|
-
host: 'instance-ip',
|
|
87
|
-
ssl: {
|
|
88
|
-
rejectUnauthorized: true,
|
|
89
|
-
ca: fs.readFileSync('./server-ca.pem'),
|
|
90
|
-
cert: fs.readFileSync('./client-cert.pem'),
|
|
91
|
-
key: fs.readFileSync('./client-key.pem'),
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Azure PostgreSQL
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
// Download cert: https://learn.microsoft.com/en-us/azure/postgresql/
|
|
100
|
-
const client = new Client({
|
|
101
|
-
host: 'server.postgres.database.azure.com',
|
|
102
|
-
user: 'user@server',
|
|
103
|
-
ssl: {
|
|
104
|
-
rejectUnauthorized: true,
|
|
105
|
-
ca: fs.readFileSync('./BaltimoreCyberTrustRoot.crt.pem'),
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Heroku Postgres
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
const client = new Client({
|
|
114
|
-
connectionString: process.env.DATABASE_URL,
|
|
115
|
-
ssl: { rejectUnauthorized: false } // Heroku uses self-signed
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Certificate File Permissions
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
chmod 600 client-key.pem # Private key (read/write owner only)
|
|
123
|
-
chmod 644 client-cert.pem # Certificate (readable by all)
|
|
124
|
-
chmod 644 ca-cert.pem # CA certificate (readable by all)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Generate Self-Signed Certificates (Dev/Testing)
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# CA certificate
|
|
131
|
-
openssl req -new -x509 -days 365 -nodes -text \
|
|
132
|
-
-out ca-cert.pem -keyout ca-key.pem
|
|
133
|
-
|
|
134
|
-
# Client certificate and key
|
|
135
|
-
openssl req -new -nodes -text \
|
|
136
|
-
-out client.csr -keyout client-key.pem
|
|
137
|
-
|
|
138
|
-
openssl x509 -req -in client.csr -text -days 365 \
|
|
139
|
-
-CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial \
|
|
140
|
-
-out client-cert.pem
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Troubleshooting
|
|
144
|
-
|
|
145
|
-
| Error | Solution |
|
|
146
|
-
|-------|----------|
|
|
147
|
-
| "self signed certificate" | Add `ca` certificate or set `rejectUnauthorized: false` (dev only) |
|
|
148
|
-
| "unable to verify first certificate" | Include complete certificate chain in `ca` |
|
|
149
|
-
| "certificate has expired" | Renew certificates |
|
|
150
|
-
| "ENOENT: no such file" | Check file paths are correct and files exist |
|
|
151
|
-
|
|
152
|
-
## Test SSL Connection
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
async function testConnection() {
|
|
156
|
-
const client = new Client({
|
|
157
|
-
host: 'your-host',
|
|
158
|
-
ssl: {
|
|
159
|
-
rejectUnauthorized: true,
|
|
160
|
-
cert: fs.readFileSync('./client-cert.pem'),
|
|
161
|
-
key: fs.readFileSync('./client-key.pem'),
|
|
162
|
-
ca: fs.readFileSync('./ca-cert.pem'),
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
const job = await client.enqueue('Test', []);
|
|
168
|
-
console.log('✓ Connected! Job ID:', job.id);
|
|
169
|
-
await client.close();
|
|
170
|
-
} catch (err) {
|
|
171
|
-
console.error('✗ Failed:', err.message);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Security Checklist
|
|
177
|
-
|
|
178
|
-
- [ ] Use `rejectUnauthorized: true` in production
|
|
179
|
-
- [ ] Never commit certificates to git
|
|
180
|
-
- [ ] Use environment variables for paths/secrets
|
|
181
|
-
- [ ] Set correct file permissions (600 for keys)
|
|
182
|
-
- [ ] Rotate certificates regularly
|
|
183
|
-
- [ ] Use strong key passphrases
|
|
184
|
-
- [ ] Add `*.pem`, `*.key`, `*.crt` to `.gitignore`
|
|
185
|
-
|
|
186
|
-
## Complete Example
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
// config.ts
|
|
190
|
-
import { Client, SSLConfig } from 'que-ts';
|
|
191
|
-
import * as fs from 'fs';
|
|
192
|
-
|
|
193
|
-
export function createSecureClient(): Client {
|
|
194
|
-
const sslConfig: SSLConfig = {
|
|
195
|
-
rejectUnauthorized: true,
|
|
196
|
-
cert: fs.readFileSync(process.env.DB_SSL_CERT || './certs/client-cert.pem'),
|
|
197
|
-
key: fs.readFileSync(process.env.DB_SSL_KEY || './certs/client-key.pem'),
|
|
198
|
-
ca: fs.readFileSync(process.env.DB_SSL_CA || './certs/ca-cert.pem'),
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
return new Client({
|
|
202
|
-
host: process.env.DB_HOST || 'localhost',
|
|
203
|
-
port: parseInt(process.env.DB_PORT || '5432'),
|
|
204
|
-
database: process.env.DB_NAME || 'mydb',
|
|
205
|
-
user: process.env.DB_USER || 'postgres',
|
|
206
|
-
password: process.env.DB_PASSWORD,
|
|
207
|
-
ssl: process.env.NODE_ENV === 'production' ? sslConfig : false,
|
|
208
|
-
maxConnections: 10,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// usage.ts
|
|
213
|
-
import { createSecureClient } from './config';
|
|
214
|
-
|
|
215
|
-
const client = createSecureClient();
|
|
216
|
-
|
|
217
|
-
async function main() {
|
|
218
|
-
await client.enqueue('SendEmail', ['user@example.com']);
|
|
219
|
-
await client.close();
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
---
|
|
224
|
-
|
|
225
|
-
For full documentation, see [SSL.md](SSL.md)
|