@tndhuy/create-app 1.2.8 → 1.2.9
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/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nes
|
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { map } from 'rxjs/operators';
|
|
5
|
+
import { PUBLIC_API_KEY } from '../decorators/public-api.decorator';
|
|
5
6
|
|
|
6
7
|
export const RAW_RESPONSE_KEY = 'raw_response';
|
|
7
8
|
|
|
@@ -19,7 +20,18 @@ export class TransformInterceptor<T> implements NestInterceptor<T, unknown> {
|
|
|
19
20
|
return next.handle();
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
const isPublic = this.reflector.getAllAndOverride<boolean>(PUBLIC_API_KEY, [
|
|
24
|
+
context.getHandler(),
|
|
25
|
+
context.getClass(),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
// If not explicitly marked as Public API (or similar decorator), return RAW data
|
|
29
|
+
// This allows internal/system calls to remain untouched while Public APIs are standardized.
|
|
30
|
+
if (!isPublic) {
|
|
31
|
+
return next.handle();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Public API: Wrap response in a standardized success object
|
|
23
35
|
return next.handle().pipe(
|
|
24
36
|
map((data) => {
|
|
25
37
|
// Handle paginated results: { items: [], meta: {} }
|
|
@@ -2,6 +2,7 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nes
|
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { map } from 'rxjs/operators';
|
|
5
|
+
import { PUBLIC_API_KEY } from '../decorators/public-api.decorator';
|
|
5
6
|
|
|
6
7
|
export const RAW_RESPONSE_KEY = 'raw_response';
|
|
7
8
|
|
|
@@ -19,7 +20,18 @@ export class TransformInterceptor<T> implements NestInterceptor<T, unknown> {
|
|
|
19
20
|
return next.handle();
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
const isPublic = this.reflector.getAllAndOverride<boolean>(PUBLIC_API_KEY, [
|
|
24
|
+
context.getHandler(),
|
|
25
|
+
context.getClass(),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
// If not explicitly marked as Public API (or similar decorator), return RAW data
|
|
29
|
+
// This allows internal/system calls to remain untouched while Public APIs are standardized.
|
|
30
|
+
if (!isPublic) {
|
|
31
|
+
return next.handle();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Public API: Wrap response in a standardized success object
|
|
23
35
|
return next.handle().pipe(
|
|
24
36
|
map((data) => {
|
|
25
37
|
// Handle paginated results: { items: [], meta: {} }
|