tango-app-api-audit 3.4.65 → 3.4.67
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/README.md +28 -28
- package/app.js +40 -0
- package/package.json +3 -3
- package/src/controllers/traxAudit.controllers.js +29 -4
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# README #
|
|
2
|
-
|
|
3
|
-
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
-
|
|
5
|
-
### What is this repository for? ###
|
|
6
|
-
|
|
7
|
-
* Quick summary
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
-
|
|
11
|
-
### How do I get set up? ###
|
|
12
|
-
|
|
13
|
-
* Summary of set up
|
|
14
|
-
* Configuration
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
19
|
-
|
|
20
|
-
### Contribution guidelines ###
|
|
21
|
-
|
|
22
|
-
* Writing tests
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
25
|
-
|
|
26
|
-
### Who do I talk to? ###
|
|
27
|
-
|
|
28
|
-
* Repo owner or admin
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
29
|
* Other community or team contact
|
package/app.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { auditRouter } from './index.js';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import { logger } from 'tango-app-api-middleware';
|
|
5
|
+
import { connectdb } from './config/database/database.js';
|
|
6
|
+
import responseMiddleware from './config/response/response.js';
|
|
7
|
+
import errorMiddleware from './config/response/error.js';
|
|
8
|
+
import pkg from 'body-parser';
|
|
9
|
+
import { swaggerConfig } from './config/swagger/swagger.js';
|
|
10
|
+
import swagger from 'swagger-ui-express';
|
|
11
|
+
import { traxAuditRouter } from './src/routes/traxAudit.routes.js';
|
|
12
|
+
import cors from 'cors';
|
|
13
|
+
const { json, urlencoded } = pkg;
|
|
14
|
+
const env=dotenv.config();
|
|
15
|
+
|
|
16
|
+
const app = express();
|
|
17
|
+
const PORT = process.env.PORT || 3000;
|
|
18
|
+
app.use( cors() );
|
|
19
|
+
|
|
20
|
+
app.use( json( { limit: '500mb' } ) );
|
|
21
|
+
app.use(
|
|
22
|
+
urlencoded( {
|
|
23
|
+
extended: true,
|
|
24
|
+
} ),
|
|
25
|
+
);
|
|
26
|
+
app.use( responseMiddleware );
|
|
27
|
+
app.use( errorMiddleware );
|
|
28
|
+
if ( env.error ) {
|
|
29
|
+
logger.error( '.env not found' );
|
|
30
|
+
process.exit( 1 );
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
|
|
34
|
+
app.use( '/v3/audit', auditRouter );
|
|
35
|
+
app.use( '/trax-audit', traxAuditRouter );
|
|
36
|
+
|
|
37
|
+
app.listen( PORT, async () => {
|
|
38
|
+
connectdb();
|
|
39
|
+
logger.info( `server is running on port= ${PORT} ` );
|
|
40
|
+
} );
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.67",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "app.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node app.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -1739,6 +1739,26 @@ export async function saveBinary( req, res ) {
|
|
|
1739
1739
|
} else {
|
|
1740
1740
|
await insertOpenSearchData( openSearch.traxDetectionOutput, anomalyOutput );
|
|
1741
1741
|
}
|
|
1742
|
+
if ( inputData.answer==='approved' ) {
|
|
1743
|
+
let usersList=JSON.parse( process.env.SES );
|
|
1744
|
+
let emails =usersList.suspeciousEmails.split( ',' );
|
|
1745
|
+
|
|
1746
|
+
for ( let user of emails ) {
|
|
1747
|
+
let notificationData= {
|
|
1748
|
+
'title': 'Suspecious Activity Detected',
|
|
1749
|
+
'description': `${getData?.sqs?.Body?.zone_name} at ${getStore2?.storeName}- Immediate action required`,
|
|
1750
|
+
'storeId': inputData.storeId,
|
|
1751
|
+
'type': 'suspiciousactivity',
|
|
1752
|
+
'date': inputData.fileDate,
|
|
1753
|
+
'clientId': req.userAudit?.clientId,
|
|
1754
|
+
'email': user,
|
|
1755
|
+
};
|
|
1756
|
+
await axios.post( `${url.apiDomain}/v3/trax/internalAPI/sendAiPushNotification`, notificationData, { headers: {
|
|
1757
|
+
'Content-Type': 'application/json',
|
|
1758
|
+
'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f55' },
|
|
1759
|
+
} );
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1742
1762
|
|
|
1743
1763
|
const logData4 = {
|
|
1744
1764
|
userId: req.user._id,
|
|
@@ -4640,7 +4660,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4640
4660
|
let filterQuery ={};
|
|
4641
4661
|
let filter=[];
|
|
4642
4662
|
switch ( inputData.moduleType ) {
|
|
4643
|
-
case 'mobile-
|
|
4663
|
+
case 'mobile-detection':
|
|
4644
4664
|
case 'uniform-detection':
|
|
4645
4665
|
case 'open-time':
|
|
4646
4666
|
case 'close-time':
|
|
@@ -4672,8 +4692,9 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4672
4692
|
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
4673
4693
|
};
|
|
4674
4694
|
break;
|
|
4695
|
+
default:
|
|
4696
|
+
return res.sendError( 'Please give valid module type', 400 );
|
|
4675
4697
|
}
|
|
4676
|
-
|
|
4677
4698
|
const userQuery = [
|
|
4678
4699
|
{
|
|
4679
4700
|
$match: {
|
|
@@ -4869,7 +4890,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4869
4890
|
const bucketCDN = url.traxAuditInput;
|
|
4870
4891
|
if ( folderPath?.length > 0 ) {
|
|
4871
4892
|
switch ( inputData.moduleType ) {
|
|
4872
|
-
case 'mobile-
|
|
4893
|
+
case 'mobile-detection':
|
|
4873
4894
|
case 'uniform-detection':
|
|
4874
4895
|
case 'hygiene':
|
|
4875
4896
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
@@ -4921,6 +4942,8 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4921
4942
|
} );
|
|
4922
4943
|
}
|
|
4923
4944
|
break;
|
|
4945
|
+
default:
|
|
4946
|
+
return res.sendError( 'Please give valid module type', 400 );
|
|
4924
4947
|
}
|
|
4925
4948
|
|
|
4926
4949
|
if ( userDetails.length === 0 ) {
|
|
@@ -4971,6 +4994,8 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4971
4994
|
moduleType: inputData.moduleType,
|
|
4972
4995
|
};
|
|
4973
4996
|
break;
|
|
4997
|
+
default:
|
|
4998
|
+
return res.sendError( 'Please give valid module type', 400 );
|
|
4974
4999
|
}
|
|
4975
5000
|
|
|
4976
5001
|
const storeRecord = {
|
|
@@ -5404,7 +5429,7 @@ export async function reTrigger( req, res ) {
|
|
|
5404
5429
|
queueName=getQueueName?.auditConfigs?.traxQueueName?.openClose;
|
|
5405
5430
|
break;
|
|
5406
5431
|
default:
|
|
5407
|
-
return res.sendError( 'Please give valid module type' );
|
|
5432
|
+
return res.sendError( 'Please give valid module type', 400 );
|
|
5408
5433
|
}
|
|
5409
5434
|
if ( !getQueueName || [ null, '', undefined ].includes( queueName ) ) {
|
|
5410
5435
|
return res.sendError( `The queueName ${queueName} does not create`, 400 );
|