@zola_do/interceptors 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/README.md +85 -0
  2. package/package.json +7 -4
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @zola_do/interceptors
2
+
3
+ Tenant and transaction interceptors for NestJS applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install individually
9
+ npm install @zola_do/interceptors
10
+
11
+ # Or via meta package
12
+ npm install @zola_do/nestjs-shared
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### TenantInterceptor
18
+
19
+ Automatically injects `tenantId` and `organizationId` into the query string for multi-tenant data isolation. Reads user from `req.user` (requires JWT auth).
20
+
21
+ ```typescript
22
+ import { Module } from '@nestjs/common';
23
+ import { APP_INTERCEPTOR } from '@nestjs/core';
24
+ import { TenantInterceptor } from '@zola_do/interceptors';
25
+
26
+ @Module({
27
+ providers: [
28
+ {
29
+ provide: APP_INTERCEPTOR,
30
+ useClass: TenantInterceptor,
31
+ },
32
+ ],
33
+ })
34
+ export class AppModule {}
35
+ ```
36
+
37
+ Or apply to specific controllers:
38
+
39
+ ```typescript
40
+ import { Controller, UseInterceptors } from '@nestjs/common';
41
+ import { TenantInterceptor } from '@zola_do/interceptors';
42
+
43
+ @Controller('orders')
44
+ @UseInterceptors(TenantInterceptor)
45
+ export class OrdersController {}
46
+ ```
47
+
48
+ Skip tenant filtering on specific routes using `@IgnoreTenantInterceptor()` from `@zola_do/core`:
49
+
50
+ ```typescript
51
+ import { IgnoreTenantInterceptor } from '@zola_do/core';
52
+
53
+ @Get('global-stats')
54
+ @IgnoreTenantInterceptor()
55
+ getGlobalStats() {}
56
+ ```
57
+
58
+ ### TransactionInterceptor
59
+
60
+ Wraps request handlers in a database transaction. Use for routes that must commit or rollback atomically:
61
+
62
+ ```typescript
63
+ import { Controller, UseInterceptors } from '@nestjs/common';
64
+ import { TransactionInterceptor } from '@zola_do/interceptors';
65
+
66
+ @Controller('payments')
67
+ @UseInterceptors(TransactionInterceptor)
68
+ export class PaymentsController {
69
+ @Post('process')
70
+ async processPayment() {
71
+ // All DB operations in this handler run in a single transaction
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## Exports
77
+
78
+ - `TenantInterceptor` — Injects tenant/organization filters into queries
79
+ - `TransactionInterceptor` — Wraps handlers in DB transactions
80
+
81
+ ## Related Packages
82
+
83
+ - [@zola_do/core](../core) — `@IgnoreTenantInterceptor` decorator
84
+ - [@zola_do/collection-query](../collection-query) — Query format used by TenantInterceptor
85
+ - [@zola_do/authorization](../authorization) — JWT auth populates `req.user` for TenantInterceptor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zola_do/interceptors",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Tenant and transaction interceptors for NestJS",
5
5
  "author": "zolaDO",
6
6
  "license": "ISC",
@@ -15,7 +15,10 @@
15
15
  "default": "./dist/index.js"
16
16
  }
17
17
  },
18
- "files": ["dist", "README.md"],
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
19
22
  "scripts": {
20
23
  "build": "rimraf dist && tsc",
21
24
  "prepublishOnly": "npm run build"
@@ -27,8 +30,8 @@
27
30
  "typeorm": "^0.3.0"
28
31
  },
29
32
  "dependencies": {
30
- "@zola_do/core": "file:../core",
31
- "@zola_do/collection-query": "file:../collection-query"
33
+ "@zola_do/core": "^0.1.9",
34
+ "@zola_do/collection-query": "^0.1.9"
32
35
  },
33
36
  "devDependencies": {
34
37
  "rimraf": "^6.1.0",