Skip to content

Commit 214258a

Browse files
authored
Merge pull request #218 from import-ai/fix/interceptor
fix(bug): bug fix
2 parents 9c205e9 + a21670e commit 214258a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/interceptor/snake-case.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ import {
1111
@Injectable()
1212
export class SnakeCaseInterceptor implements NestInterceptor {
1313
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
14-
return next.handle().pipe(map((data) => transformKeysToSnakeCase(data)));
14+
return next.handle().pipe(
15+
map((response) => {
16+
// Skip transformation for Express Response objects
17+
if (this.isNativeExpressResponse(response)) {
18+
return response;
19+
}
20+
return transformKeysToSnakeCase(response);
21+
}),
22+
);
23+
}
24+
25+
private isNativeExpressResponse(response: any): boolean {
26+
if (!response || typeof response !== 'object') {
27+
return false;
28+
}
29+
30+
// Check if it's a ServerResponse (Node.js HTTP response)
31+
if (response.constructor?.name === 'ServerResponse') {
32+
return true;
33+
}
34+
35+
// Check for common Express Response properties
36+
return ['statusCode', 'send', 'getHeader', 'req'].every(
37+
(feat) => feat in response,
38+
);
1539
}
1640
}

src/namespaces/namespaces.controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ export class NamespacesController {
8181
return await this.namespacesService.getRoot(namespaceId, userId);
8282
}
8383

84+
@Get(':namespaceId/private')
85+
async getPrivateRoot(
86+
@Param('namespaceId') namespaceId: string,
87+
@UserId() userId: string,
88+
) {
89+
return await this.namespacesService.getPrivateRoot(userId, namespaceId);
90+
}
91+
8492
@Post()
8593
async create(@Req() req, @Body() createDto: CreateNamespaceDto) {
8694
return await this.namespacesService.createAndJoinNamespace(

0 commit comments

Comments
 (0)