express-file-cluster 0.3.15 → 0.7.0
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/README.md +71 -33
- package/dist/auth/index.cjs +12 -2
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +13 -2
- package/dist/auth/index.d.ts +13 -2
- package/dist/auth/index.js +12 -2
- package/dist/chunk-277BSYVH.js +127 -0
- package/dist/chunk-277BSYVH.js.map +1 -0
- package/dist/chunk-6OGOVV57.js +3847 -0
- package/dist/chunk-6OGOVV57.js.map +1 -0
- package/dist/chunk-7YEX4MQV.cjs +38 -0
- package/dist/chunk-7YEX4MQV.cjs.map +1 -0
- package/dist/chunk-AZYXQU3Z.cjs +3847 -0
- package/dist/chunk-AZYXQU3Z.cjs.map +1 -0
- package/dist/chunk-BUBXO7WU.js +170 -0
- package/dist/chunk-BUBXO7WU.js.map +1 -0
- package/dist/chunk-LJNSJFOL.js +38 -0
- package/dist/chunk-LJNSJFOL.js.map +1 -0
- package/dist/chunk-MGH4VDV3.cjs +170 -0
- package/dist/chunk-MGH4VDV3.cjs.map +1 -0
- package/dist/chunk-R34R7QPD.cjs +116 -0
- package/dist/chunk-R34R7QPD.cjs.map +1 -0
- package/dist/chunk-RS4MXCPW.js +116 -0
- package/dist/chunk-RS4MXCPW.js.map +1 -0
- package/dist/chunk-T4OHFU5T.cjs +154 -0
- package/dist/chunk-T4OHFU5T.cjs.map +1 -0
- package/dist/chunk-TI24L4XE.cjs.map +1 -1
- package/dist/chunk-TRC4DUZB.js +438 -0
- package/dist/chunk-TRC4DUZB.js.map +1 -0
- package/dist/chunk-TYR2GZZE.cjs +196 -0
- package/dist/chunk-TYR2GZZE.cjs.map +1 -0
- package/dist/chunk-UBQYQPBU.js +154 -0
- package/dist/chunk-UBQYQPBU.js.map +1 -0
- package/dist/chunk-UTM4PEVG.js +196 -0
- package/dist/chunk-UTM4PEVG.js.map +1 -0
- package/dist/chunk-YL37D6KM.cjs +127 -0
- package/dist/chunk-YL37D6KM.cjs.map +1 -0
- package/dist/chunk-ZDM5JHVK.cjs +438 -0
- package/dist/chunk-ZDM5JHVK.cjs.map +1 -0
- package/dist/cli/db-runner.cjs +497 -0
- package/dist/cli/db-runner.cjs.map +1 -0
- package/dist/cli/db-runner.d.cts +2 -0
- package/dist/cli/db-runner.d.ts +2 -0
- package/dist/cli/db-runner.js +497 -0
- package/dist/cli/db-runner.js.map +1 -0
- package/dist/cli/index.cjs +447 -69
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +473 -95
- package/dist/cli/index.js.map +1 -1
- package/dist/docs/api-reference/auth.md +232 -0
- package/dist/docs/api-reference/compose.md +78 -0
- package/dist/docs/api-reference/db.md +351 -0
- package/dist/docs/api-reference/http-error.md +109 -0
- package/dist/docs/api-reference/ignite.md +326 -0
- package/dist/docs/api-reference/table.md +458 -0
- package/dist/docs/api-reference/tasks.md +140 -0
- package/dist/docs/cli/db.md +38 -0
- package/dist/docs/cli/diagnostics.md +145 -0
- package/dist/docs/cli/generate.md +120 -0
- package/dist/docs/cli/index.md +48 -0
- package/dist/docs/cli/start.md +112 -0
- package/dist/docs/contributing/index.md +139 -0
- package/dist/docs/core-concepts/background-tasks.md +228 -0
- package/dist/docs/core-concepts/clustering.md +114 -0
- package/dist/docs/core-concepts/file-based-routing.md +235 -0
- package/dist/docs/core-concepts/index.md +79 -0
- package/dist/docs/core-concepts/middleware.md +144 -0
- package/dist/docs/getting-started/index.md +91 -0
- package/dist/docs/getting-started/project-structure.md +154 -0
- package/dist/docs/guides/ai-agents.md +48 -0
- package/dist/docs/guides/authentication.md +196 -0
- package/dist/docs/guides/caching.md +124 -0
- package/dist/docs/guides/database.md +217 -0
- package/dist/docs/guides/deployment.md +171 -0
- package/dist/docs/guides/environment-variables.md +106 -0
- package/dist/docs/guides/error-handling.md +172 -0
- package/dist/docs/guides/generated-portals.md +115 -0
- package/dist/docs/guides/logging.md +108 -0
- package/dist/docs/guides/mailer.md +166 -0
- package/dist/docs/guides/migrations.md +106 -0
- package/dist/docs/guides/rbac.md +89 -0
- package/dist/docs/guides/validation.md +95 -0
- package/dist/docs/index.md +93 -0
- package/dist/docs/skills/SKILL.md +44 -0
- package/dist/docs/skills/api-surface.md +309 -0
- package/dist/docs/skills/auth-internals.md +141 -0
- package/dist/docs/skills/pre-flight.md +142 -0
- package/dist/docs/skills/routing-rules.md +114 -0
- package/dist/docs/skills/tasks-internals.md +172 -0
- package/dist/docs/skills/what-not-to-invent.md +251 -0
- package/dist/index.cjs +264 -391
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +699 -7
- package/dist/index.d.ts +699 -7
- package/dist/index.js +258 -385
- package/dist/index.js.map +1 -1
- package/dist/pgboss-backend-QKBXVJ6B.js +14 -0
- package/dist/pgboss-backend-QKBXVJ6B.js.map +1 -0
- package/dist/pgboss-backend-TCHI7CHM.cjs +14 -0
- package/dist/pgboss-backend-TCHI7CHM.cjs.map +1 -0
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.d.cts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/types-B6lVw4bj.d.cts +588 -0
- package/dist/types-B6lVw4bj.d.ts +588 -0
- package/package.json +28 -5
- package/dist/chunk-6522HS2J.cjs +0 -99
- package/dist/chunk-6522HS2J.cjs.map +0 -1
- package/dist/chunk-DGVOJNR6.cjs +0 -55
- package/dist/chunk-DGVOJNR6.cjs.map +0 -1
- package/dist/chunk-KOHLLUN7.js +0 -55
- package/dist/chunk-KOHLLUN7.js.map +0 -1
- package/dist/chunk-VIP3PFWZ.js +0 -99
- package/dist/chunk-VIP3PFWZ.js.map +0 -1
- package/dist/types-BusbSenn.d.cts +0 -162
- package/dist/types-BusbSenn.d.ts +0 -162
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
EFC is an opinionated backend framework built on Express. Drop files in `src/api/` and they become routes. Every CPU core serves traffic automatically. Heavy work goes to a queue-backed task subsystem so requests stay fast.
|
|
6
6
|
|
|
7
|
-
> **Status: v0.
|
|
7
|
+
> **Status: v0.7.0 (Beta).** Router (incl. catch-all/optional segments and request validation), clustering, auth, structured logging, `defineModel` on MongoDB and PostgreSQL (types inferred from the schema), PostgreSQL-native `defineTable` with Prisma-style queries and relations (foreign keys, many-to-many, `include`, relation filters, nested writes), query logging, BullMQ and pg-boss tasks with cron, and migrations are all implemented.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -142,22 +142,18 @@ Declare a typed model with a schema. EFC compiles it to a Mongoose model and wra
|
|
|
142
142
|
|
|
143
143
|
```ts
|
|
144
144
|
// src/model/User.ts
|
|
145
|
-
import { defineModel } from 'express-file-cluster';
|
|
145
|
+
import { defineModel, type InferRecord } from 'express-file-cluster';
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
name: string;
|
|
149
|
-
email: string;
|
|
150
|
-
role: 'admin' | 'user';
|
|
151
|
-
verifyToken: string;
|
|
152
|
-
createdAt?: Date;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const User = defineModel<UserDocument>('User', {
|
|
147
|
+
export const User = defineModel('User', {
|
|
156
148
|
name: { type: 'string', required: true },
|
|
157
149
|
email: { type: 'string', required: true, unique: true },
|
|
158
150
|
role: { type: 'string', enum: ['admin', 'user'], default: 'user' },
|
|
159
151
|
verifyToken: { type: 'string', default: '$uuid' }, // fresh UUID per document
|
|
160
152
|
});
|
|
153
|
+
|
|
154
|
+
// Types come from the schema — no interface to write:
|
|
155
|
+
export type User = InferRecord<typeof User>;
|
|
156
|
+
// { id: string; name: string; email: string; role: 'admin' | 'user'; verifyToken: string; createdAt: Date; ... }
|
|
161
157
|
```
|
|
162
158
|
|
|
163
159
|
### Schema default operator codes
|
|
@@ -179,7 +175,7 @@ Any other value is used as-is — only these exact strings are special-cased.
|
|
|
179
175
|
### Auto-increment (`sequence`)
|
|
180
176
|
|
|
181
177
|
```ts
|
|
182
|
-
export const Order = defineModel
|
|
178
|
+
export const Order = defineModel('Order', {
|
|
183
179
|
orderNumber: { type: 'number', sequence: true, required: true },
|
|
184
180
|
// sequence: 'global.orders' — explicit key to share a counter across models
|
|
185
181
|
});
|
|
@@ -191,34 +187,39 @@ export const Order = defineModel<OrderDocument>('Order', {
|
|
|
191
187
|
|
|
192
188
|
```ts
|
|
193
189
|
// Disable Mongoose's automatic createdAt/updatedAt (default: on)
|
|
194
|
-
export const Role = defineModel
|
|
190
|
+
export const Role = defineModel('Role', schema, {
|
|
195
191
|
timestamps: false,
|
|
196
192
|
});
|
|
197
193
|
|
|
198
194
|
// Or rename them
|
|
199
|
-
export const Audit = defineModel
|
|
195
|
+
export const Audit = defineModel('Audit', schema, {
|
|
200
196
|
timestamps: { createdAt: 'created_at', updatedAt: false },
|
|
201
197
|
});
|
|
202
198
|
```
|
|
203
199
|
|
|
204
|
-
###
|
|
200
|
+
### Model API — identical on MongoDB and PostgreSQL
|
|
205
201
|
|
|
206
202
|
```ts
|
|
207
|
-
await User.find({ role: 'admin' }
|
|
208
|
-
|
|
209
|
-
await User.
|
|
210
|
-
await User.
|
|
211
|
-
await User.
|
|
212
|
-
await User.
|
|
213
|
-
await User.
|
|
203
|
+
await User.find({ role: { $in: ['admin', 'editor'] }, 'address.city': 'Oslo' },
|
|
204
|
+
{ sort: { createdAt: -1 }, limit: 20, skip: 20, select: ['name'], populate: 'team' });
|
|
205
|
+
await User.findById(id); // malformed id → null
|
|
206
|
+
await User.findOne({ email: 'a@b.com' });
|
|
207
|
+
await User.create({ name: 'Alice' }); // validated (400 ModelValidationError / 409 duplicate)
|
|
208
|
+
await User.createMany([...]);
|
|
209
|
+
await User.update(id, { $inc: { logins: 1 } }); // validated too
|
|
210
|
+
await User.updateMany(filter, update); // → count
|
|
211
|
+
await User.delete(id);
|
|
212
|
+
await User.deleteMany(filter); // → count
|
|
213
|
+
await User.count(filter);
|
|
214
|
+
await User.exists(filter); // → boolean
|
|
215
|
+
await User.distinct('role', filter); // → sorted distinct values
|
|
216
|
+
await User.updateOne(filter, update); // first match, one statement → record | null
|
|
217
|
+
await User.deleteOne(filter); // → deleted record | null
|
|
218
|
+
await User.upsert(filter, create, update); // update the match, or create
|
|
219
|
+
await transaction(async () => { /* model calls here share one transaction */ });
|
|
214
220
|
```
|
|
215
221
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
await Post.find({}, { populate: 'author' });
|
|
220
|
-
await Post.findById(id, { populate: ['author', 'comments.user'] });
|
|
221
|
-
```
|
|
222
|
+
The engine follows `DATABASE_URL` (`mongodb://` → mongoose, `postgres://` → Drizzle; install `mongoose` or `pg drizzle-orm`). Tables and indexes are created and kept in step with the models automatically on first use (`autoSync`); `efc db sync --dry-run` shows pending changes. MongoDB-only extras: `aggregate()`, TTL indexes. `Model.raw()` returns the native mongoose model / Drizzle table.
|
|
222
223
|
|
|
223
224
|
---
|
|
224
225
|
|
|
@@ -266,12 +267,34 @@ Task options:
|
|
|
266
267
|
| Option | Default | Description |
|
|
267
268
|
|---|---|---|
|
|
268
269
|
| `thread` | `false` | Run in a `worker_threads` thread (CPU-bound work) |
|
|
269
|
-
| `retries` | `3` |
|
|
270
|
+
| `retries` | `3` | Re-runs after a failure (up to `retries + 1` attempts) before dead-lettering |
|
|
270
271
|
| `backoff` | `'exponential'` | Delay strategy between retries |
|
|
271
272
|
| `concurrency` | `tasks.concurrency` | Parallel jobs for this task |
|
|
272
|
-
| `schedule` | — | Cron
|
|
273
|
+
| `schedule` | — | Cron pattern for recurring runs (payload `{}`) |
|
|
274
|
+
| `timezone` | server time | IANA timezone for `schedule` |
|
|
275
|
+
|
|
276
|
+
Backends: `tasks: { backend: 'bullmq', redisUrl }` or `tasks: { backend: 'pg-boss' }` (jobs in your PostgreSQL). `enqueue()` rejects after `tasks.enqueueTimeout` (default 5 s) instead of hanging when the backend is down. Dead letters: `efc tasks failed | retry | purge`.
|
|
277
|
+
|
|
278
|
+
### PostgreSQL-native: `defineTable()`
|
|
273
279
|
|
|
274
|
-
|
|
280
|
+
On PostgreSQL, `defineTable` gives you Prisma's query API and SQL types on the same foundation:
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
import { defineTable } from 'express-file-cluster';
|
|
284
|
+
|
|
285
|
+
export const Order = defineTable('Order', {
|
|
286
|
+
number: { type: 'string', required: true, unique: true, maxLength: 20 }, // varchar(20)
|
|
287
|
+
total: { type: 'decimal', precision: 10, scale: 2, required: true }, // '19.99', exact
|
|
288
|
+
qty: { type: 'integer', required: true },
|
|
289
|
+
tags: { type: 'array', of: 'string', default: [] }, // text[]
|
|
290
|
+
}, { id: 'serial' });
|
|
291
|
+
|
|
292
|
+
await Order.findMany({ where: { total: { gte: '100' }, tags: { has: 'vip' } }, orderBy: { createdAt: 'desc' }, take: 20 });
|
|
293
|
+
await Order.upsert({ where: { number }, create: { number, total: '0', qty: 1 }, update: { qty: { increment: 1 } } });
|
|
294
|
+
await Order.groupBy({ by: ['qty'], _sum: { total: true } });
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
See [defineTable](https://github.com/siggold/express-file-cluster/blob/main/docs/api-reference/table.md).
|
|
275
298
|
|
|
276
299
|
---
|
|
277
300
|
|
|
@@ -314,6 +337,11 @@ export const POST = async (req, res) => {
|
|
|
314
337
|
// Role-gated route
|
|
315
338
|
export const middlewares = [requireAuth('admin')];
|
|
316
339
|
|
|
340
|
+
// Real logout (needs `cache` in ignite()): the token is rejected from now on.
|
|
341
|
+
import { revokeSession, revokeAllSessions } from 'express-file-cluster/auth';
|
|
342
|
+
await revokeSession(req, res); // this device
|
|
343
|
+
await revokeAllSessions(userId); // every device
|
|
344
|
+
|
|
317
345
|
// getCurrentUser() reads the same verified JWT payload from anywhere in the
|
|
318
346
|
// async call chain — not just where `req` is in scope. This is also what
|
|
319
347
|
// powers the '$currentUser' / '$currentUser.<key>' defineModel default codes.
|
|
@@ -380,6 +408,8 @@ ignite({
|
|
|
380
408
|
| `tasks` | `TaskConfig \| false` | `false` | Background task runtime |
|
|
381
409
|
| `cors` | `boolean \| CorsConfig` | `true` | CORS — pass `origin` explicitly, not auto-read from env |
|
|
382
410
|
| `requestTimeout` | `number` | — | Request timeout in ms (408 on exceed) |
|
|
411
|
+
| `logging` | `LoggingConfig \| false` | pretty in dev TTY, JSON otherwise | pino logging; every request gets an `X-Request-Id`; `queries` adds model operation, slow-query and N+1 logging |
|
|
412
|
+
| `cache` | `CacheConfig \| false` | — | `{ backend: 'redis', url }` or `{ backend: 'memory' }` — enables `cache`, `cacheResponse()` and session revocation |
|
|
383
413
|
| `globalMiddlewares` | `RequestHandler[]` | `[]` | Applied to every route |
|
|
384
414
|
| `dashboard` | `boolean` | `true` in dev | Dev route dashboard at `/` |
|
|
385
415
|
| `onWorkerReady` | `(id) => void` | — | Called when a worker boots |
|
|
@@ -395,8 +425,8 @@ ignite({
|
|
|
395
425
|
efc start dev # Hot-reload single process (tsx --watch), .env re-read on every restart
|
|
396
426
|
|
|
397
427
|
# Production
|
|
398
|
-
efc build prod # Type-check +
|
|
399
|
-
efc start prod # Run dist/ with clustering enabled
|
|
428
|
+
efc build prod # Type-check + transpile src/ → dist/src/ (tsup, unbundled)
|
|
429
|
+
efc start prod # Run dist/src/index.js with clustering enabled
|
|
400
430
|
|
|
401
431
|
# Tests
|
|
402
432
|
efc run tests # Vitest (--watch, --coverage passthrough)
|
|
@@ -405,10 +435,18 @@ efc run tests # Vitest (--watch, --coverage passthrough)
|
|
|
405
435
|
efc generate route users/[id] # → src/api/users/[id].ts
|
|
406
436
|
efc generate task ProcessPayment # → src/tasks/ProcessPayment.ts
|
|
407
437
|
efc generate middleware authorize # → src/middlewares/authorize.ts
|
|
438
|
+
efc generate migration add_orders # → src/migrations/<timestamp>_add_orders.ts
|
|
439
|
+
efc generate seed demo_users # → src/seeds/demo_users.ts
|
|
440
|
+
|
|
441
|
+
# Database
|
|
442
|
+
efc db migrate | rollback | status # Migrations
|
|
443
|
+
efc db seed [name] # Seeds
|
|
444
|
+
efc db studio # Read-only browser on 127.0.0.1
|
|
408
445
|
|
|
409
446
|
# Diagnostics
|
|
410
447
|
efc routes # Print resolved route table (path → file → methods)
|
|
411
448
|
efc tasks # List registered background tasks
|
|
449
|
+
efc tasks failed | retry | purge # Dead-letter queue
|
|
412
450
|
efc doctor # Validate project setup, package.json/tsconfig, .env vars
|
|
413
451
|
```
|
|
414
452
|
|
package/dist/auth/index.cjs
CHANGED
|
@@ -5,13 +5,23 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _chunk6522HS2Jcjs = require('../chunk-6522HS2J.cjs');
|
|
9
8
|
|
|
9
|
+
var _chunkZDM5JHVKcjs = require('../chunk-ZDM5JHVK.cjs');
|
|
10
|
+
require('../chunk-T4OHFU5T.cjs');
|
|
11
|
+
require('../chunk-MGH4VDV3.cjs');
|
|
12
|
+
require('../chunk-7YEX4MQV.cjs');
|
|
13
|
+
require('../chunk-TI24L4XE.cjs');
|
|
10
14
|
|
|
11
15
|
|
|
16
|
+
var _chunkYL37D6KMcjs = require('../chunk-YL37D6KM.cjs');
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.configureAuth = _chunkZDM5JHVKcjs.configureAuth; exports.getCurrentUser = _chunkYL37D6KMcjs.getCurrentUser; exports.issueToken = _chunkZDM5JHVKcjs.issueToken; exports.requireAuth = _chunkZDM5JHVKcjs.requireAuth; exports.revokeAllSessions = _chunkZDM5JHVKcjs.revokeAllSessions; exports.revokeSession = _chunkZDM5JHVKcjs.revokeSession; exports.revokeToken = _chunkZDM5JHVKcjs.revokeToken; exports.signToken = _chunkZDM5JHVKcjs.signToken;
|
|
17
27
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/auth/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2bAAC","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/auth/index.cjs"}
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
2
|
-
import { A as AuthStrategy } from '../types-
|
|
2
|
+
import { A as AuthStrategy } from '../types-B6lVw4bj.cjs';
|
|
3
3
|
|
|
4
4
|
declare function getCurrentUser(): Record<string, unknown> | undefined;
|
|
5
5
|
|
|
@@ -13,6 +13,17 @@ declare function configureAuth(config: AuthConfig): void;
|
|
|
13
13
|
declare function issueToken(res: Response, payload: Record<string, unknown>): Promise<void>;
|
|
14
14
|
declare function revokeToken(res: Response): void;
|
|
15
15
|
declare function signToken(payload: Record<string, unknown>): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Revokes the token the current request was authenticated with: `requireAuth` rejects
|
|
18
|
+
* it from now until it would have expired anyway. Pass `res` to also clear the cookie
|
|
19
|
+
* (http-only strategy). Throws if the cache is unreachable, so a failed logout is visible.
|
|
20
|
+
*/
|
|
21
|
+
declare function revokeSession(req: Request, res?: Response): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Revokes every token issued to `userId` (the JWT's `sub` or `id` claim) before now —
|
|
24
|
+
* "log out of all devices", or after a password change. Tokens issued afterwards work.
|
|
25
|
+
*/
|
|
26
|
+
declare function revokeAllSessions(userId: string | number): Promise<void>;
|
|
16
27
|
/**
|
|
17
28
|
* Used bare (`middlewares = [requireAuth]`) it just verifies the JWT.
|
|
18
29
|
* Called with role names (`middlewares = [requireAuth('admin')]`) it
|
|
@@ -24,4 +35,4 @@ interface RequireAuth {
|
|
|
24
35
|
}
|
|
25
36
|
declare const requireAuth: RequireAuth;
|
|
26
37
|
|
|
27
|
-
export { type RequireAuth, configureAuth, getCurrentUser, issueToken, requireAuth, revokeToken, signToken };
|
|
38
|
+
export { type RequireAuth, configureAuth, getCurrentUser, issueToken, requireAuth, revokeAllSessions, revokeSession, revokeToken, signToken };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
2
|
-
import { A as AuthStrategy } from '../types-
|
|
2
|
+
import { A as AuthStrategy } from '../types-B6lVw4bj.js';
|
|
3
3
|
|
|
4
4
|
declare function getCurrentUser(): Record<string, unknown> | undefined;
|
|
5
5
|
|
|
@@ -13,6 +13,17 @@ declare function configureAuth(config: AuthConfig): void;
|
|
|
13
13
|
declare function issueToken(res: Response, payload: Record<string, unknown>): Promise<void>;
|
|
14
14
|
declare function revokeToken(res: Response): void;
|
|
15
15
|
declare function signToken(payload: Record<string, unknown>): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Revokes the token the current request was authenticated with: `requireAuth` rejects
|
|
18
|
+
* it from now until it would have expired anyway. Pass `res` to also clear the cookie
|
|
19
|
+
* (http-only strategy). Throws if the cache is unreachable, so a failed logout is visible.
|
|
20
|
+
*/
|
|
21
|
+
declare function revokeSession(req: Request, res?: Response): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Revokes every token issued to `userId` (the JWT's `sub` or `id` claim) before now —
|
|
24
|
+
* "log out of all devices", or after a password change. Tokens issued afterwards work.
|
|
25
|
+
*/
|
|
26
|
+
declare function revokeAllSessions(userId: string | number): Promise<void>;
|
|
16
27
|
/**
|
|
17
28
|
* Used bare (`middlewares = [requireAuth]`) it just verifies the JWT.
|
|
18
29
|
* Called with role names (`middlewares = [requireAuth('admin')]`) it
|
|
@@ -24,4 +35,4 @@ interface RequireAuth {
|
|
|
24
35
|
}
|
|
25
36
|
declare const requireAuth: RequireAuth;
|
|
26
37
|
|
|
27
|
-
export { type RequireAuth, configureAuth, getCurrentUser, issueToken, requireAuth, revokeToken, signToken };
|
|
38
|
+
export { type RequireAuth, configureAuth, getCurrentUser, issueToken, requireAuth, revokeAllSessions, revokeSession, revokeToken, signToken };
|
package/dist/auth/index.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
configureAuth,
|
|
3
|
-
getCurrentUser,
|
|
4
3
|
issueToken,
|
|
5
4
|
requireAuth,
|
|
5
|
+
revokeAllSessions,
|
|
6
|
+
revokeSession,
|
|
6
7
|
revokeToken,
|
|
7
8
|
signToken
|
|
8
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-TRC4DUZB.js";
|
|
10
|
+
import "../chunk-UBQYQPBU.js";
|
|
11
|
+
import "../chunk-BUBXO7WU.js";
|
|
12
|
+
import "../chunk-LJNSJFOL.js";
|
|
13
|
+
import "../chunk-HBYSKULC.js";
|
|
14
|
+
import {
|
|
15
|
+
getCurrentUser
|
|
16
|
+
} from "../chunk-277BSYVH.js";
|
|
9
17
|
export {
|
|
10
18
|
configureAuth,
|
|
11
19
|
getCurrentUser,
|
|
12
20
|
issueToken,
|
|
13
21
|
requireAuth,
|
|
22
|
+
revokeAllSessions,
|
|
23
|
+
revokeSession,
|
|
14
24
|
revokeToken,
|
|
15
25
|
signToken
|
|
16
26
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// src/context.ts
|
|
2
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
var storage = new AsyncLocalStorage();
|
|
4
|
+
function runWithContext(ctx, fn) {
|
|
5
|
+
return storage.run(ctx, fn);
|
|
6
|
+
}
|
|
7
|
+
function getRequestContext() {
|
|
8
|
+
return storage.getStore();
|
|
9
|
+
}
|
|
10
|
+
function setCurrentUser(user) {
|
|
11
|
+
const store = storage.getStore();
|
|
12
|
+
if (store) store.user = user;
|
|
13
|
+
}
|
|
14
|
+
function getCurrentUser() {
|
|
15
|
+
return storage.getStore()?.user;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/logger.ts
|
|
19
|
+
import cluster from "cluster";
|
|
20
|
+
import { randomUUID } from "crypto";
|
|
21
|
+
import pc from "picocolors";
|
|
22
|
+
import { pino } from "pino";
|
|
23
|
+
var LEVEL_LABELS = {
|
|
24
|
+
10: pc.gray("TRACE"),
|
|
25
|
+
20: pc.blue("DEBUG"),
|
|
26
|
+
30: pc.green("INFO "),
|
|
27
|
+
40: pc.yellow("WARN "),
|
|
28
|
+
50: pc.red("ERROR"),
|
|
29
|
+
60: pc.bgRed("FATAL")
|
|
30
|
+
};
|
|
31
|
+
var OMIT = /* @__PURE__ */ new Set(["level", "time", "msg", "pid", "hostname", "worker", "reqId"]);
|
|
32
|
+
function prettyStream(out = process.stdout) {
|
|
33
|
+
return {
|
|
34
|
+
write(line) {
|
|
35
|
+
let rec;
|
|
36
|
+
try {
|
|
37
|
+
rec = JSON.parse(line);
|
|
38
|
+
} catch {
|
|
39
|
+
out.write(line);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const time = new Date(rec["time"]).toTimeString().slice(0, 8);
|
|
43
|
+
const level = LEVEL_LABELS[rec["level"]] ?? String(rec["level"]);
|
|
44
|
+
const worker = rec["worker"] !== void 0 ? pc.dim(`[${String(rec["worker"])}] `) : "";
|
|
45
|
+
const reqId = rec["reqId"] ? pc.magenta(String(rec["reqId"]).slice(0, 8)) + " " : "";
|
|
46
|
+
const extra = Object.entries(rec).filter(([k]) => !OMIT.has(k));
|
|
47
|
+
const err = rec["err"];
|
|
48
|
+
const fields = extra.filter(([k]) => k !== "err").map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
49
|
+
out.write(
|
|
50
|
+
`${pc.dim(time)} ${level} ${worker}${reqId}${String(rec["msg"] ?? "")}` + (fields ? " " + pc.dim(fields) : "") + (err?.stack ? "\n" + pc.red(err.stack) : "") + "\n"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function workerLabel() {
|
|
56
|
+
return cluster.isWorker ? `w${cluster.worker?.id ?? "?"}` : "primary";
|
|
57
|
+
}
|
|
58
|
+
function build(config) {
|
|
59
|
+
if (config === false) return pino({ level: "silent" });
|
|
60
|
+
const opts = config ?? {};
|
|
61
|
+
const pretty = opts.pretty ?? (process.env["NODE_ENV"] !== "production" && process.stdout.isTTY === true);
|
|
62
|
+
const base = { worker: workerLabel() };
|
|
63
|
+
const level = opts.level ?? "info";
|
|
64
|
+
return pretty ? pino({ level, base, errorKey: "err" }, prettyStream()) : pino({ level, base, errorKey: "err", timestamp: pino.stdTimeFunctions.isoTime });
|
|
65
|
+
}
|
|
66
|
+
var rootLogger = build(void 0);
|
|
67
|
+
var logRequests = true;
|
|
68
|
+
function configureLogger(config) {
|
|
69
|
+
rootLogger = build(config);
|
|
70
|
+
logRequests = config !== false && (config?.requests ?? true);
|
|
71
|
+
}
|
|
72
|
+
function getLogger() {
|
|
73
|
+
return getRequestContext()?.log ?? rootLogger;
|
|
74
|
+
}
|
|
75
|
+
var logger = new Proxy({}, {
|
|
76
|
+
get(_t, prop) {
|
|
77
|
+
const target = getLogger();
|
|
78
|
+
const value = target[prop];
|
|
79
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var SAFE_REQUEST_ID = /^[\w.:-]{1,128}$/;
|
|
83
|
+
function requestLogger() {
|
|
84
|
+
return (req, res, next) => {
|
|
85
|
+
const incoming = req.get("x-request-id");
|
|
86
|
+
const id = incoming && SAFE_REQUEST_ID.test(incoming) ? incoming : randomUUID();
|
|
87
|
+
const log = rootLogger.child({ reqId: id });
|
|
88
|
+
req.id = id;
|
|
89
|
+
req.log = log;
|
|
90
|
+
res.setHeader("X-Request-Id", id);
|
|
91
|
+
const ctx = getRequestContext();
|
|
92
|
+
if (ctx) {
|
|
93
|
+
ctx.requestId = id;
|
|
94
|
+
ctx.log = log;
|
|
95
|
+
}
|
|
96
|
+
if (logRequests) {
|
|
97
|
+
const start = process.hrtime.bigint();
|
|
98
|
+
res.on("finish", () => {
|
|
99
|
+
const durationMs = Number(process.hrtime.bigint() - start) / 1e6;
|
|
100
|
+
const status = res.statusCode;
|
|
101
|
+
const line = {
|
|
102
|
+
method: req.method,
|
|
103
|
+
url: req.originalUrl,
|
|
104
|
+
status,
|
|
105
|
+
durationMs: Math.round(durationMs * 10) / 10
|
|
106
|
+
};
|
|
107
|
+
const msg = `${req.method} ${req.originalUrl} ${status}`;
|
|
108
|
+
if (status >= 500) log.error(line, msg);
|
|
109
|
+
else if (status >= 400) log.warn(line, msg);
|
|
110
|
+
else log.info(line, msg);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
next();
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
runWithContext,
|
|
119
|
+
getRequestContext,
|
|
120
|
+
setCurrentUser,
|
|
121
|
+
getCurrentUser,
|
|
122
|
+
configureLogger,
|
|
123
|
+
getLogger,
|
|
124
|
+
logger,
|
|
125
|
+
requestLogger
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=chunk-277BSYVH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/logger.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Logger } from 'pino';\n\nexport interface RequestContext {\n user?: Record<string, unknown> | undefined;\n requestId?: string;\n log?: Logger;\n /** Model operations run so far in this request, by `Model.op` (N+1 detection). */\n queryCounts?: Map<string, number>;\n}\n\nconst storage = new AsyncLocalStorage<RequestContext>();\n\n// Wraps one request's lifecycle in an AsyncLocalStorage context. Node propagates\n// the store through the async chain the callback initiates (awaits, .then, etc.),\n// so anything running as part of the same request — including a `$currentUser`\n// default resolved deep inside a mongoose `.create()` call — can read it back.\nexport function runWithContext<T>(ctx: RequestContext, fn: () => T): T {\n return storage.run(ctx, fn);\n}\n\nexport function getRequestContext(): RequestContext | undefined {\n return storage.getStore();\n}\n\nexport function setCurrentUser(user: Record<string, unknown> | undefined): void {\n const store = storage.getStore();\n if (store) store.user = user;\n}\n\nexport function getCurrentUser(): Record<string, unknown> | undefined {\n return storage.getStore()?.user;\n}\n","import cluster from 'node:cluster';\nimport { randomUUID } from 'node:crypto';\nimport type { RequestHandler } from 'express';\nimport pc from 'picocolors';\nimport { pino, type Logger, type DestinationStream } from 'pino';\nimport type { LoggingConfig } from './types.js';\nimport { getRequestContext } from './context.js';\n\nexport type { Logger };\n\nconst LEVEL_LABELS: Record<number, string> = {\n 10: pc.gray('TRACE'),\n 20: pc.blue('DEBUG'),\n 30: pc.green('INFO '),\n 40: pc.yellow('WARN '),\n 50: pc.red('ERROR'),\n 60: pc.bgRed('FATAL'),\n};\n\nconst OMIT = new Set(['level', 'time', 'msg', 'pid', 'hostname', 'worker', 'reqId']);\n\n// Dev-friendly one-line renderer, so readable output doesn't need pino-pretty or a\n// transport worker thread: `12:00:01 INFO [w2] a1b2c3d4 GET /users 200 (3ms)`.\nfunction prettyStream(out: NodeJS.WritableStream = process.stdout): DestinationStream {\n return {\n write(line: string) {\n let rec: Record<string, unknown>;\n try {\n rec = JSON.parse(line) as Record<string, unknown>;\n } catch {\n out.write(line);\n return;\n }\n const time = new Date(rec['time'] as number).toTimeString().slice(0, 8);\n const level = LEVEL_LABELS[rec['level'] as number] ?? String(rec['level']);\n const worker = rec['worker'] !== undefined ? pc.dim(`[${String(rec['worker'])}] `) : '';\n const reqId = rec['reqId'] ? pc.magenta(String(rec['reqId']).slice(0, 8)) + ' ' : '';\n const extra = Object.entries(rec).filter(([k]) => !OMIT.has(k));\n const err = rec['err'] as { stack?: string } | undefined;\n const fields = extra\n .filter(([k]) => k !== 'err')\n .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)\n .join(' ');\n out.write(\n `${pc.dim(time)} ${level} ${worker}${reqId}${String(rec['msg'] ?? '')}` +\n (fields ? ' ' + pc.dim(fields) : '') +\n (err?.stack ? '\\n' + pc.red(err.stack) : '') +\n '\\n',\n );\n },\n };\n}\n\nfunction workerLabel(): string {\n return cluster.isWorker ? `w${cluster.worker?.id ?? '?'}` : 'primary';\n}\n\nfunction build(config: LoggingConfig | false | undefined): Logger {\n if (config === false) return pino({ level: 'silent' });\n const opts = config ?? {};\n const pretty =\n opts.pretty ?? (process.env['NODE_ENV'] !== 'production' && process.stdout.isTTY === true);\n const base = { worker: workerLabel() };\n const level = opts.level ?? 'info';\n return pretty\n ? pino({ level, base, errorKey: 'err' }, prettyStream())\n : pino({ level, base, errorKey: 'err', timestamp: pino.stdTimeFunctions.isoTime });\n}\n\nlet rootLogger: Logger = build(undefined);\nlet logRequests = true;\n\n/** Called by ignite() during Pre-Flight; before that the defaults apply. */\nexport function configureLogger(config: LoggingConfig | false | undefined): void {\n rootLogger = build(config);\n logRequests = config !== false && (config?.requests ?? true);\n}\n\n/**\n * The logger for the current scope: inside a request it is a child carrying that\n * request's `reqId`, so everything logged while handling it can be correlated;\n * elsewhere (startup, task handlers, timers) it is the root logger.\n */\nexport function getLogger(): Logger {\n return getRequestContext()?.log ?? rootLogger;\n}\n\n/** Root logger proxy — always reflects the latest configureLogger() call. */\nexport const logger: Logger = new Proxy({} as Logger, {\n get(_t, prop) {\n const target = getLogger() as unknown as Record<PropertyKey, unknown>;\n const value = target[prop];\n return typeof value === 'function'\n ? (value as (...a: unknown[]) => unknown).bind(target)\n : value;\n },\n});\n\nconst SAFE_REQUEST_ID = /^[\\w.:-]{1,128}$/;\n\n/**\n * Assigns the request ID (trusting a well-formed incoming `X-Request-Id`, e.g. from\n * a load balancer), echoes it back, attaches `req.id` / `req.log`, and logs one\n * line per completed request. Must run inside the request's context.\n */\nexport function requestLogger(): RequestHandler {\n return (req, res, next) => {\n const incoming = req.get('x-request-id');\n const id = incoming && SAFE_REQUEST_ID.test(incoming) ? incoming : randomUUID();\n const log = rootLogger.child({ reqId: id });\n\n req.id = id;\n req.log = log;\n res.setHeader('X-Request-Id', id);\n const ctx = getRequestContext();\n if (ctx) {\n ctx.requestId = id;\n ctx.log = log;\n }\n\n if (logRequests) {\n const start = process.hrtime.bigint();\n res.on('finish', () => {\n const durationMs = Number(process.hrtime.bigint() - start) / 1e6;\n const status = res.statusCode;\n const line = {\n method: req.method,\n url: req.originalUrl,\n status,\n durationMs: Math.round(durationMs * 10) / 10,\n };\n const msg = `${req.method} ${req.originalUrl} ${status}`;\n if (status >= 500) log.error(line, msg);\n else if (status >= 400) log.warn(line, msg);\n else log.info(line, msg);\n });\n }\n next();\n };\n}\n\ndeclare module 'express-serve-static-core' {\n interface Request {\n /** Request ID — the incoming `X-Request-Id` if well-formed, else a UUID. */\n id: string;\n /** Logger bound to this request's ID. */\n log: Logger;\n }\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAWlC,IAAM,UAAU,IAAI,kBAAkC;AAM/C,SAAS,eAAkB,KAAqB,IAAgB;AACrE,SAAO,QAAQ,IAAI,KAAK,EAAE;AAC5B;AAEO,SAAS,oBAAgD;AAC9D,SAAO,QAAQ,SAAS;AAC1B;AAEO,SAAS,eAAe,MAAiD;AAC9E,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,MAAO,OAAM,OAAO;AAC1B;AAEO,SAAS,iBAAsD;AACpE,SAAO,QAAQ,SAAS,GAAG;AAC7B;;;AChCA,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAE3B,OAAO,QAAQ;AACf,SAAS,YAAiD;AAM1D,IAAM,eAAuC;AAAA,EAC3C,IAAI,GAAG,KAAK,OAAO;AAAA,EACnB,IAAI,GAAG,KAAK,OAAO;AAAA,EACnB,IAAI,GAAG,MAAM,OAAO;AAAA,EACpB,IAAI,GAAG,O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