@flusys/nestjs-shared 1.0.1 → 1.1.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 +10 -11
- package/cjs/utils/request.util.js +2 -1
- package/fesm/utils/request.util.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Shared Package Guide
|
|
2
2
|
|
|
3
3
|
> **Package:** `@flusys/nestjs-shared`
|
|
4
|
+
> **Version:** 1.1.0
|
|
4
5
|
> **Type:** Shared NestJS utilities, classes, decorators, guards, and modules
|
|
5
6
|
|
|
6
7
|
This comprehensive guide covers the shared package - the shared NestJS infrastructure layer.
|
|
@@ -63,23 +64,22 @@ nestjs-shared/
|
|
|
63
64
|
├── src/
|
|
64
65
|
│ ├── classes/ # Base classes
|
|
65
66
|
│ │ ├── api-service.class.ts # Generic CRUD service
|
|
66
|
-
│ │ ├── api-controller.class.ts # Generic CRUD controller factory
|
|
67
|
+
│ │ ├── api-controller.class.ts # Generic CRUD controller factory (createApiController)
|
|
67
68
|
│ │ ├── request-scoped-api.service.ts # REQUEST-scoped service base
|
|
68
69
|
│ │ ├── hybrid-cache.class.ts # Two-tier caching
|
|
69
70
|
│ │ ├── winston.logger.class.ts # Winston logger config
|
|
70
|
-
│ │
|
|
71
|
-
│ │ └── nest-logger-adapter.class.ts
|
|
71
|
+
│ │ └── winston-logger-adapter.class.ts
|
|
72
72
|
│ │
|
|
73
73
|
│ ├── constants/ # Injection tokens & constants
|
|
74
|
-
│ │ ├── permissions.ts # Permission constants
|
|
74
|
+
│ │ ├── permissions.ts # Permission constants (PERMISSIONS)
|
|
75
75
|
│ │ └── index.ts
|
|
76
76
|
│ │
|
|
77
77
|
│ ├── decorators/ # Custom decorators
|
|
78
78
|
│ │ ├── api-response.decorator.ts # @ApiResponseDto
|
|
79
79
|
│ │ ├── current-user.decorator.ts # @CurrentUser
|
|
80
80
|
│ │ ├── public.decorator.ts # @Public
|
|
81
|
-
│ │ ├── require-permission.decorator.ts # @RequirePermission
|
|
82
|
-
│ │ ├── sanitize.decorator.ts
|
|
81
|
+
│ │ ├── require-permission.decorator.ts # @RequirePermission, @RequireAnyPermission, @RequirePermissionCondition
|
|
82
|
+
│ │ ├── sanitize-html.decorator.ts # @SanitizeHtml, @SanitizeAndTrim
|
|
83
83
|
│ │ └── index.ts
|
|
84
84
|
│ │
|
|
85
85
|
│ ├── dtos/ # Shared DTOs
|
|
@@ -107,18 +107,17 @@ nestjs-shared/
|
|
|
107
107
|
│ │ ├── idempotency.interceptor.ts
|
|
108
108
|
│ │ ├── query-performance.interceptor.ts
|
|
109
109
|
│ │ ├── response-meta.interceptor.ts
|
|
110
|
-
│ │ ├── set-
|
|
111
|
-
│ │ ├── set-delete-by-on-body.interceptor.ts
|
|
112
|
-
│ │ ├── set-update-by-on-body.interceptor.ts
|
|
110
|
+
│ │ ├── set-user-field-on-body.interceptor.ts # SetCreatedByOnBody, SetUpdateByOnBody, SetDeletedByOnBody
|
|
113
111
|
│ │ └── slug.interceptor.ts
|
|
114
112
|
│ │
|
|
115
113
|
│ ├── interfaces/ # TypeScript interfaces
|
|
116
114
|
│ │ ├── api.interface.ts # IService interface
|
|
115
|
+
│ │ ├── datasource.interface.ts # IDataSourceProvider
|
|
117
116
|
│ │ ├── identity.interface.ts
|
|
118
117
|
│ │ ├── logged-user-info.interface.ts # ILoggedUserInfo
|
|
119
118
|
│ │ ├── logger.interface.ts # ILogger
|
|
120
|
-
│ │ ├──
|
|
121
|
-
│ │ └──
|
|
119
|
+
│ │ ├── module-config.interface.ts # IModuleConfigService
|
|
120
|
+
│ │ └── permission.interface.ts # PermissionCondition, PermissionOperator
|
|
122
121
|
│ │
|
|
123
122
|
│ ├── middlewares/ # Middleware
|
|
124
123
|
│ │ └── logger.middleware.ts # Request logging & correlation
|
|
@@ -19,6 +19,7 @@ _export(exports, {
|
|
|
19
19
|
return parseDurationToMs;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
+
const _config = require("@flusys/nestjs-core/config");
|
|
22
23
|
const _constants = require("../constants");
|
|
23
24
|
/** Time unit multipliers in milliseconds */ const TIME_UNIT_MS = {
|
|
24
25
|
s: 1000,
|
|
@@ -45,7 +46,7 @@ function isBrowserRequest(req) {
|
|
|
45
46
|
function buildCookieOptions(req) {
|
|
46
47
|
const hostname = req.hostname || '';
|
|
47
48
|
const origin = req.headers.origin || '';
|
|
48
|
-
const isProduction =
|
|
49
|
+
const isProduction = _config.envConfig.isProduction();
|
|
49
50
|
const forwardedProto = req.headers['x-forwarded-proto'];
|
|
50
51
|
const isHttps = isProduction || forwardedProto === 'https' || origin.startsWith('https://') || req.secure;
|
|
51
52
|
let domain;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { envConfig } from '@flusys/nestjs-core/config';
|
|
1
2
|
import { CLIENT_TYPE_HEADER } from '../constants';
|
|
2
3
|
/** Time unit multipliers in milliseconds */ const TIME_UNIT_MS = {
|
|
3
4
|
s: 1000,
|
|
@@ -30,7 +31,7 @@ import { CLIENT_TYPE_HEADER } from '../constants';
|
|
|
30
31
|
*/ export function buildCookieOptions(req) {
|
|
31
32
|
const hostname = req.hostname || '';
|
|
32
33
|
const origin = req.headers.origin || '';
|
|
33
|
-
const isProduction =
|
|
34
|
+
const isProduction = envConfig.isProduction();
|
|
34
35
|
const forwardedProto = req.headers['x-forwarded-proto'];
|
|
35
36
|
const isHttps = isProduction || forwardedProto === 'https' || origin.startsWith('https://') || req.secure;
|
|
36
37
|
let domain;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-shared",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Common shared utilities for Flusys NestJS applications",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -105,6 +105,6 @@
|
|
|
105
105
|
"winston-daily-rotate-file": "^5.0.0"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@flusys/nestjs-core": "1.0
|
|
108
|
+
"@flusys/nestjs-core": "1.1.0"
|
|
109
109
|
}
|
|
110
110
|
}
|