1- import {
2- Controller ,
3- Get ,
1+ import {
2+ Controller ,
3+ Get ,
44 Post ,
55 Patch ,
66 Delete ,
77 Body ,
88 Param ,
9- UseGuards
9+ UseGuards ,
1010} from '@nestjs/common' ;
1111import {
1212 ApiBody ,
@@ -17,10 +17,7 @@ import {
1717 ApiSecurity ,
1818 ApiTags ,
1919} from '@nestjs/swagger' ;
20- import {
21- AuthContext ,
22- OrganizationId ,
23- } from '../auth/auth-context.decorator' ;
20+ import { AuthContext , OrganizationId } from '../auth/auth-context.decorator' ;
2421import { HybridAuthGuard } from '../auth/hybrid-auth.guard' ;
2522import type { AuthContext as AuthContextType } from '../auth/types' ;
2623import { CreateContextDto } from './dto/create-context.dto' ;
@@ -58,18 +55,20 @@ export class ContextController {
5855 @OrganizationId ( ) organizationId : string ,
5956 @AuthContext ( ) authContext : AuthContextType ,
6057 ) {
61- const contextEntries = await this . contextService . findAllByOrganization ( organizationId ) ;
58+ const contextEntries =
59+ await this . contextService . findAllByOrganization ( organizationId ) ;
6260
6361 return {
6462 data : contextEntries ,
6563 count : contextEntries . length ,
6664 authType : authContext . authType ,
67- ...( authContext . userId && authContext . userEmail && {
68- authenticatedUser : {
69- id : authContext . userId ,
70- email : authContext . userEmail ,
71- } ,
72- } ) ,
65+ ...( authContext . userId &&
66+ authContext . userEmail && {
67+ authenticatedUser : {
68+ id : authContext . userId ,
69+ email : authContext . userEmail ,
70+ } ,
71+ } ) ,
7372 } ;
7473 }
7574
@@ -85,17 +84,21 @@ export class ContextController {
8584 @OrganizationId ( ) organizationId : string ,
8685 @AuthContext ( ) authContext : AuthContextType ,
8786 ) {
88- const contextEntry = await this . contextService . findById ( contextId , organizationId ) ;
87+ const contextEntry = await this . contextService . findById (
88+ contextId ,
89+ organizationId ,
90+ ) ;
8991
9092 return {
9193 ...contextEntry ,
9294 authType : authContext . authType ,
93- ...( authContext . userId && authContext . userEmail && {
94- authenticatedUser : {
95- id : authContext . userId ,
96- email : authContext . userEmail ,
97- } ,
98- } ) ,
95+ ...( authContext . userId &&
96+ authContext . userEmail && {
97+ authenticatedUser : {
98+ id : authContext . userId ,
99+ email : authContext . userEmail ,
100+ } ,
101+ } ) ,
99102 } ;
100103 }
101104
@@ -112,17 +115,21 @@ export class ContextController {
112115 @OrganizationId ( ) organizationId : string ,
113116 @AuthContext ( ) authContext : AuthContextType ,
114117 ) {
115- const contextEntry = await this . contextService . create ( organizationId , createContextDto ) ;
118+ const contextEntry = await this . contextService . create (
119+ organizationId ,
120+ createContextDto ,
121+ ) ;
116122
117123 return {
118124 ...contextEntry ,
119125 authType : authContext . authType ,
120- ...( authContext . userId && authContext . userEmail && {
121- authenticatedUser : {
122- id : authContext . userId ,
123- email : authContext . userEmail ,
124- } ,
125- } ) ,
126+ ...( authContext . userId &&
127+ authContext . userEmail && {
128+ authenticatedUser : {
129+ id : authContext . userId ,
130+ email : authContext . userEmail ,
131+ } ,
132+ } ) ,
126133 } ;
127134 }
128135
@@ -150,12 +157,13 @@ export class ContextController {
150157 return {
151158 ...updatedContextEntry ,
152159 authType : authContext . authType ,
153- ...( authContext . userId && authContext . userEmail && {
154- authenticatedUser : {
155- id : authContext . userId ,
156- email : authContext . userEmail ,
157- } ,
158- } ) ,
160+ ...( authContext . userId &&
161+ authContext . userEmail && {
162+ authenticatedUser : {
163+ id : authContext . userId ,
164+ email : authContext . userEmail ,
165+ } ,
166+ } ) ,
159167 } ;
160168 }
161169
@@ -171,17 +179,21 @@ export class ContextController {
171179 @OrganizationId ( ) organizationId : string ,
172180 @AuthContext ( ) authContext : AuthContextType ,
173181 ) {
174- const result = await this . contextService . deleteById ( contextId , organizationId ) ;
182+ const result = await this . contextService . deleteById (
183+ contextId ,
184+ organizationId ,
185+ ) ;
175186
176187 return {
177188 ...result ,
178189 authType : authContext . authType ,
179- ...( authContext . userId && authContext . userEmail && {
180- authenticatedUser : {
181- id : authContext . userId ,
182- email : authContext . userEmail ,
183- } ,
184- } ) ,
190+ ...( authContext . userId &&
191+ authContext . userEmail && {
192+ authenticatedUser : {
193+ id : authContext . userId ,
194+ email : authContext . userEmail ,
195+ } ,
196+ } ) ,
185197 } ;
186198 }
187199}
0 commit comments