tango-app-api-trax 3.7.5-halfshutter-1 → 3.7.5-halfshutter-3

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
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.7.5-halfshutter-1",
3
+ "version": "3.7.5-halfshutter-3",
4
4
  "description": "Trax",
5
- "main": "app.js",
5
+ "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node app.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node index.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -302,7 +302,7 @@ export async function PCLconfigCreation( req, res ) {
302
302
  },
303
303
  } );
304
304
  let getSections = await CLquestions.aggregate( sectionQuery );
305
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
305
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
306
306
  if ( getSections.length ) {
307
307
  for ( let element3 of getSections ) {
308
308
  let collectQuestions = {};
@@ -600,11 +600,11 @@ export async function PCLconfigCreation( req, res ) {
600
600
  // }
601
601
  }
602
602
  } else {
603
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
603
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
604
604
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
605
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
605
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
606
606
  let storeList = storeDetails.map( ( store ) => store.storeId );
607
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
607
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
608
608
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
609
609
  } else {
610
610
  allQuestion = storeDetails.map( ( item ) => {
@@ -638,7 +638,7 @@ export async function PCLconfigCreation( req, res ) {
638
638
  client_id: getCLconfig.client_id,
639
639
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
640
640
  };
641
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
641
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
642
642
  let processData = {
643
643
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
644
644
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -878,7 +878,7 @@ async function insertData( requestData ) {
878
878
  },
879
879
  } );
880
880
  let getSections = await CLquestions.aggregate( sectionQuery );
881
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
881
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
882
882
  if ( getSections.length ) {
883
883
  for ( let element3 of getSections ) {
884
884
  let collectQuestions = {};
@@ -1172,11 +1172,11 @@ async function insertData( requestData ) {
1172
1172
  // }
1173
1173
  }
1174
1174
  } else {
1175
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
1175
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
1176
1176
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
1177
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1177
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1178
1178
  let storeList = storeDetails.map( ( store ) => store.storeId );
1179
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
1179
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
1180
1180
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
1181
1181
  } else {
1182
1182
  allQuestion = storeDetails.map( ( item ) => {
@@ -1210,7 +1210,7 @@ async function insertData( requestData ) {
1210
1210
  client_id: getCLconfig.client_id,
1211
1211
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
1212
1212
  };
1213
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking' ].includes( getCLconfig.checkListType ) ) {
1213
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter' ].includes( getCLconfig.checkListType ) ) {
1214
1214
  let processData = {
1215
1215
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
1216
1216
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -606,7 +606,7 @@ export const flagCardsV1 = async ( req, res ) => {
606
606
  {
607
607
  client_id: clientId,
608
608
  publish: true,
609
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] },
609
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter' ] },
610
610
  },
611
611
  { checkListType: 1 },
612
612
  );
@@ -2584,7 +2584,6 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2584
2584
  // let LamdaURL = 'https://vpcejaftccr3jzqf5wrdkks7yy0krqix.lambda-url.ap-south-1.on.aws/'; // Prod
2585
2585
  let LamdaURL = url.flagChecklistTableV1; // test
2586
2586
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
2587
- // console.log( 'resultData =>', resultData );
2588
2587
  if ( resultData ) {
2589
2588
  if ( resultData.status_code == '200' ) {
2590
2589
  if ( reqestData?.filter === 'runAI' ) {
@@ -2739,7 +2738,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
2739
2738
  $or: [
2740
2739
  { questionFlag: { $gte: 1 } },
2741
2740
  { timeFlag: { $gte: 1 } },
2742
- { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] } },
2741
+ { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter' ] } },
2743
2742
  {
2744
2743
  runAIQuestionCount: { $gte: 1 },
2745
2744
  },
@@ -2941,7 +2940,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2941
2940
  {
2942
2941
  client_id: requestData.clientId,
2943
2942
  publish: true,
2944
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] },
2943
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter' ] },
2945
2944
  },
2946
2945
  { checkListType: 1 },
2947
2946
  );
@@ -3033,7 +3032,8 @@ export const flagTablesV2 = async ( req, res ) => {
3033
3032
  );
3034
3033
  if ( requestData.clientId == '11' ) {
3035
3034
  findAndQuery.push(
3036
- { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
3035
+ // { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
3036
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ] },
3037
3037
  );
3038
3038
  } else {
3039
3039
  findAndQuery.push(
@@ -3042,7 +3042,7 @@ export const flagTablesV2 = async ( req, res ) => {
3042
3042
  }
3043
3043
 
3044
3044
  if ( requestData?.filter === 'all' ) {
3045
- findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] } } ] } );
3045
+ findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter' ] } } ] } );
3046
3046
  } else if ( requestData?.filter === 'question' ) {
3047
3047
  findAndQuery.push( { checkListType: 'custom' } );
3048
3048
  findAndQuery.push( { questionFlag: { $gte: 1 } } );
@@ -3050,7 +3050,7 @@ export const flagTablesV2 = async ( req, res ) => {
3050
3050
  findAndQuery.push( { checkListType: 'custom' } );
3051
3051
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
3052
3052
  } else if ( requestData?.filter === 'detection' ) {
3053
- findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] } } );
3053
+ findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter' ] } } );
3054
3054
  } else if ( requestData?.filter === 'runAI' ) {
3055
3055
  if ( req.body.runAIChecklistName ) {
3056
3056
  findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
@@ -3239,7 +3239,8 @@ export const flagTablesV2 = async ( req, res ) => {
3239
3239
  } else {
3240
3240
  if ( requestData?.filter == 'all' ) {
3241
3241
  getChecklistPerformanceData[index].runAIFlag = 0;
3242
- getChecklistPerformanceData[index].flaggedStores = 0;
3242
+ getChecklistPerformanceData[index].flagCount = resultData?.[getChecklistPerformanceData[index]?.checkListType] || 0;
3243
+ getChecklistPerformanceData[index].flaggedStores = resultData?.[`${getChecklistPerformanceData[index]?.checkListType}_flaggedstores`] || 0;
3243
3244
  } else {
3244
3245
  getChecklistPerformanceData[index].flagCount = 0;
3245
3246
  getChecklistPerformanceData[index].flaggedStores = 0;
@@ -25,6 +25,7 @@ import * as clusterServices from '../services/cluster.service.js';
25
25
  import * as teamsServices from '../services/teams.service.js';
26
26
  import * as runAIFeatureServices from '../services/runAIFeatures.services.js';
27
27
  import * as runAIRequestServices from '../services/runAIRequest.services.js';
28
+ import * as processedTaskService from '../services/processedTaskList.service.js';
28
29
 
29
30
 
30
31
  export const checklist = async ( req, res ) => {
@@ -4868,3 +4869,53 @@ export async function updateRunAIFeatures( req, res ) {
4868
4869
  return res.sendError( error, 500 );
4869
4870
  }
4870
4871
  }
4872
+
4873
+
4874
+ export async function updateOSProcessedData( req, res ) {
4875
+ try {
4876
+ let requestData = req.body;
4877
+ let findQuery = [ {
4878
+ $match: {
4879
+ $and: [
4880
+ { _id: new ObjectId( requestData._id ) },
4881
+ ],
4882
+ },
4883
+ } ];
4884
+ if ( requestData.type && requestData.type=='checklist' ) {
4885
+ let getchecklist = await processedchecklist.aggregate( findQuery );
4886
+ if ( getchecklist && getchecklist.length > 0 ) {
4887
+ const requestOptions = {
4888
+ method: 'POST',
4889
+ headers: {
4890
+ 'Content-Type': 'application/json',
4891
+ },
4892
+ body: JSON.stringify( { doc: { ...getchecklist[0] } } ),
4893
+ };
4894
+ let url = JSON.parse( process.env.LAMBDAURL );
4895
+ let searchResponse = await fetch( url.submitChecklist, requestOptions );
4896
+ return res.sendSuccess( searchResponse );
4897
+ } else {
4898
+ return res.sendError( { message: 'invalid _id' }, 400 );
4899
+ }
4900
+ } else if ( requestData.type && requestData.type=='task' ) {
4901
+ let gettask = await processedTaskService.aggregate( findQuery );
4902
+ if ( gettask && gettask.length > 0 ) {
4903
+ const requestOptions = {
4904
+ method: 'POST',
4905
+ headers: {
4906
+ 'Content-Type': 'application/json',
4907
+ },
4908
+ body: JSON.stringify( { doc: { ...gettask[0] } } ),
4909
+ };
4910
+ let url = JSON.parse( process.env.LAMBDAURL );
4911
+ let searchResponse = await fetch( url.submitTask, requestOptions );
4912
+ return res.sendSuccess( searchResponse );
4913
+ } else {
4914
+ return res.sendError( { message: 'invalid _id' }, 400 );
4915
+ }
4916
+ }
4917
+ } catch ( e ) {
4918
+ logger.error( { functionName: 'updateCurlData', error: e } );
4919
+ return res.sendError( error, 500 );
4920
+ }
4921
+ }
@@ -185,4 +185,11 @@ export const runAIRequestValidation = {
185
185
  body: runAIRequestSchema,
186
186
  };
187
187
 
188
+ export const updateOSDataSchema = joi.object( {
189
+ _id: joi.string().required(),
190
+ type: joi.string().required(),
191
+ } );
188
192
 
193
+ export const updateOSDataValidation = {
194
+ body: updateOSDataSchema,
195
+ };
@@ -1,6 +1,6 @@
1
1
  import express from 'express';
2
- import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
3
- import { checklistValidation, checklistDetailsValidation, runaiValidation, checklistPageSchema, duplicateValidation, updateChecklistValidation, uploadUserValidation, aichecklistValidation, publishValidation, selectAssign, createChecklistNameValidation, runAIRequestValidation } from '../dtos/validation.dtos.js';
2
+ import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
3
+ import { checklistValidation, checklistDetailsValidation, runaiValidation, checklistPageSchema, duplicateValidation, updateChecklistValidation, uploadUserValidation, aichecklistValidation, publishValidation, selectAssign, createChecklistNameValidation, runAIRequestValidation, updateOSDataValidation } from '../dtos/validation.dtos.js';
4
4
  import * as traxController from '../controllers/trax.controller.js';
5
5
 
6
6
  export const traxRouter = express.Router();
@@ -34,6 +34,7 @@ traxRouter
34
34
  .post( '/getRunAIFeatures', isAllowedSessionHandler, traxController.getRunAIFeatures )
35
35
  .post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
36
36
  .post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
37
- .post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName );
37
+ .post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName )
38
+ .post( '/updateOSProcessedData', isAllowedInternalAPIHandler, validate( updateOSDataValidation ), traxController.updateOSProcessedData );
38
39
 
39
40
  // isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),
package/app.js DELETED
@@ -1,56 +0,0 @@
1
- import express from 'express';
2
- import { traxDashboardRouter, traxFlagRouter, traxRouter, downloadRouter, mobileRouter, locusOrderRouter, internalTraxRouter, traxActivityLogRouter, galleryRouter } from './index.js';
3
- import dotenv from 'dotenv';
4
- import pkg from 'body-parser';
5
- const { json, urlencoded } = pkg;
6
- import { logger } from 'tango-app-api-middleware';
7
- import { connectdb } from './config/database/database.js';
8
- import responseMiddleware from './config/response/response.js';
9
- import errorMiddleware from './config/response/error.js';
10
- import cors from 'cors';
11
- import admin from 'firebase-admin';
12
- import fileupload from 'express-fileupload';
13
-
14
-
15
- const serviceAccountPath = JSON.parse( process.env.FIREBASE );
16
- admin.initializeApp( {
17
- credential: admin.credential.cert( serviceAccountPath ),
18
- } );
19
-
20
- const env=dotenv.config();
21
-
22
- const app = express();
23
- const PORT = process.env.PORT || 3000;
24
- app.use( cors() );
25
-
26
-
27
- if ( env.error ) {
28
- logger.error( '.env not found' );
29
- process.exit( 1 );
30
- }
31
-
32
- app.use( json( { limit: '500mb' } ) );
33
- app.use( fileupload() );
34
- app.use(
35
- urlencoded( {
36
- extended: true,
37
- } ),
38
- );
39
-
40
- app.use( responseMiddleware );
41
- app.use( errorMiddleware );
42
-
43
- app.use( '/trax/dashboard', traxDashboardRouter );
44
- app.use( '/trax', traxRouter );
45
- app.use( '/trax/flag', traxFlagRouter );
46
- app.use( '/trax/downloads', downloadRouter );
47
- app.use( '/trax/mobileAPI', mobileRouter );
48
- app.use( '/trax/locusorder', locusOrderRouter );
49
- app.use( '/trax/internalAPI', internalTraxRouter );
50
- app.use( '/trax/activityLog', traxActivityLogRouter );
51
- app.use( '/trax/gallery', galleryRouter );
52
-
53
- app.listen( PORT, () => {
54
- console.log( `server is running on port= ${PORT} ` );
55
- connectdb();
56
- } );