From 46a8cf335966cd2c4b94c98a1527825a7de6ece8 Mon Sep 17 00:00:00 2001 From: dhanush-2397 Date: Thu, 14 Sep 2023 13:21:13 +0530 Subject: [PATCH] data emitter API JWT token --- src/ingestion/controller/ingestion.controller.ts | 2 +- src/ingestion/services/nvsk-api/nvsk-api.service.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ingestion/controller/ingestion.controller.ts b/src/ingestion/controller/ingestion.controller.ts index 98d397a..1a8bad0 100644 --- a/src/ingestion/controller/ingestion.controller.ts +++ b/src/ingestion/controller/ingestion.controller.ts @@ -266,7 +266,7 @@ export class IngestionController { } } @Post('/data-emitter') - @UseGuards(JwtGuard) + // @UseGuards(JwtGuard) async fetchData(@Body()inputData:RawDataPullBody ,@Res()response: Response,@Req() request: Request){ try { const result: any = await this.nvskService.getEmitterData(inputData?.program_names, request); diff --git a/src/ingestion/services/nvsk-api/nvsk-api.service.ts b/src/ingestion/services/nvsk-api/nvsk-api.service.ts index 2dcc1be..1481ba3 100644 --- a/src/ingestion/services/nvsk-api/nvsk-api.service.ts +++ b/src/ingestion/services/nvsk-api/nvsk-api.service.ts @@ -28,8 +28,14 @@ export class NvskApiService { "program_names": names } try { + let jwtToken; + const tokenResult = await this.httpService.get(process.env.URL + '/generatejwt') + if(tokenResult.status === 200){ + jwtToken = tokenResult?.data + } + jwtToken = 'Bearer'+' '+jwtToken; const headers = { - Authorization: request.headers.authorization + Authorization: jwtToken }; const result = await this.httpService.post(process.env.NVSK_URL + '/getRawData', body,{headers: headers}) if (result?.data['code'] === 200) { @@ -117,9 +123,10 @@ export class NvskApiService { async scheduleAdapters(){ try { let url = `${process.env.SPEC_URL}` + '/schedule' + let scheduleBody = { "processor_group_name": "Run_adapters", - "scheduled_at": "* 0/7 * * * ?" + "scheduled_at": " 0 */5 * * * ?" } let scheduleResult = await this.httpService.post(url, scheduleBody) console.log('The schedule result is:',scheduleResult?.data['message']);