@@ -12,6 +12,8 @@ import {
12
12
UseInterceptors ,
13
13
UsePipes ,
14
14
ValidationPipe ,
15
+ All ,
16
+ Req ,
15
17
} from '@nestjs/common' ;
16
18
import {
17
19
SignupResponse ,
@@ -36,6 +38,7 @@ import { Throttle, SkipThrottle} from '@nestjs/throttler';
36
38
import { ConfigService } from '@nestjs/config' ;
37
39
import { v4 as uuidv4 } from 'uuid' ;
38
40
import { VerifyJWTDto } from './dto/verify-jwt.dto' ;
41
+ import { Request } from 'express' ;
39
42
// eslint-disable-next-line @typescript-eslint/no-var-requires
40
43
const CryptoJS = require ( 'crypto-js' ) ;
41
44
@@ -272,21 +275,21 @@ export class ApiController {
272
275
) ;
273
276
}
274
277
275
- @Get ( 'user/:userId' )
276
- async searchUserbyId (
277
- @Param ( 'userId' ) userId : string ,
278
- @Headers ( 'authorization' ) authHeader ,
279
- @Headers ( 'x-application-id' ) applicationId ,
280
- ) : Promise < UsersResponse > {
281
- const queryString = `(id: ${ userId } )` ; // pass the strict user ID filter
282
- return await this . apiService . fetchUsersByString (
283
- queryString ,
284
- undefined ,
285
- undefined ,
286
- applicationId ,
287
- authHeader ,
288
- ) ;
289
- }
278
+ // @Get ('user/:userId')
279
+ // async searchUserbyId(
280
+ // @Param ('userId') userId: string,
281
+ // @Headers ('authorization') authHeader,
282
+ // @Headers ('x-application-id') applicationId,
283
+ // ): Promise<UsersResponse> {
284
+ // const queryString = `(id: ${userId})`; // pass the strict user ID filter
285
+ // return await this.apiService.fetchUsersByString(
286
+ // queryString,
287
+ // undefined,
288
+ // undefined,
289
+ // applicationId,
290
+ // authHeader,
291
+ // );
292
+ // }
290
293
291
294
@Post ( 'refresh-token' )
292
295
async refreshToken (
@@ -301,33 +304,33 @@ export class ApiController {
301
304
) ;
302
305
}
303
306
304
- @Patch ( '/user/:userId/deactivate' )
305
- async deactivateUserById (
306
- @Param ( 'userId' ) userId : string ,
307
- @Query ( 'hardDelete' ) hardDelete = false ,
308
- @Headers ( 'authorization' ) authHeader ,
309
- @Headers ( 'x-application-id' ) applicationId ,
310
- ) : Promise < UsersResponse > {
311
- return await this . apiService . deactivateUserById (
312
- userId ,
313
- hardDelete ,
314
- applicationId ,
315
- authHeader ,
316
- ) ;
317
- }
307
+ // @Patch ('/user/:userId/deactivate')
308
+ // async deactivateUserById(
309
+ // @Param ('userId') userId: string,
310
+ // @Query ('hardDelete') hardDelete = false,
311
+ // @Headers ('authorization') authHeader,
312
+ // @Headers ('x-application-id') applicationId,
313
+ // ): Promise<UsersResponse> {
314
+ // return await this.apiService.deactivateUserById(
315
+ // userId,
316
+ // hardDelete,
317
+ // applicationId,
318
+ // authHeader,
319
+ // );
320
+ // }
318
321
319
- @Patch ( '/user/:userId/activate' )
320
- async activateUserById (
321
- @Param ( 'userId' ) userId : string ,
322
- @Headers ( 'authorization' ) authHeader ,
323
- @Headers ( 'x-application-id' ) applicationId ,
324
- ) : Promise < UsersResponse > {
325
- return await this . apiService . activateUserById (
326
- userId ,
327
- applicationId ,
328
- authHeader ,
329
- ) ;
330
- }
322
+ // @Patch ('/user/:userId/activate')
323
+ // async activateUserById(
324
+ // @Param ('userId') userId: string,
325
+ // @Headers ('authorization') authHeader,
326
+ // @Headers ('x-application-id') applicationId,
327
+ // ): Promise<UsersResponse> {
328
+ // return await this.apiService.activateUserById(
329
+ // userId,
330
+ // applicationId,
331
+ // authHeader,
332
+ // );
333
+ // }
331
334
332
335
@Post ( '/changePassword/sendOTP' )
333
336
async changePasswordOTP (
@@ -398,4 +401,43 @@ export class ApiController {
398
401
) : Promise < any > {
399
402
return await this . apiService . logout ( body . token ) ;
400
403
}
404
+
405
+ @All ( '*' )
406
+ async defaultRoute (
407
+ @Req ( ) request : Request ,
408
+ @Headers ( 'authorization' ) authHeader ,
409
+ @Headers ( 'x-application-id' ) applicationId ,
410
+ @Body ( ) body : any ,
411
+ @Query ( ) query : any ,
412
+ @Param ( ) params : any ,
413
+ ) : Promise < any > {
414
+ const fusionAuthBaseUrl = this . configService . get ( 'FUSIONAUTH_BASE_URL' ) ;
415
+ const url = new URL ( `${ fusionAuthBaseUrl } ${ request . url } ` ) ;
416
+
417
+ // Add query params to URL
418
+ if ( query ) {
419
+ Object . keys ( query ) . forEach ( key => {
420
+ url . searchParams . append ( key , query [ key ] ) ;
421
+ } ) ;
422
+ }
423
+
424
+ // Add params to URL
425
+ if ( params ) {
426
+ Object . keys ( params ) . forEach ( key => {
427
+ url . searchParams . append ( key , params [ key ] ) ;
428
+ } ) ;
429
+ }
430
+
431
+ const response = await fetch ( url , {
432
+ method : request . method ,
433
+ body : Object . keys ( body ) . length ? JSON . stringify ( body ) : undefined ,
434
+ headers : {
435
+ 'Authorization' : authHeader ,
436
+ 'x-application-id' : applicationId ,
437
+ 'Content-Type' : 'application/json'
438
+ }
439
+ } ) ;
440
+
441
+ return await response . json ( ) ;
442
+ }
401
443
}
0 commit comments