tango-app-api-audit 3.4.68-beta.14 → 3.4.68-beta.16
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/.eslintrc.cjs +1 -1
- package/README.md +28 -28
- package/app.js +47 -0
- package/package.json +3 -3
- package/src/controllers/eyeTestAudit.controllers.js +5 -4
- package/src/dtos/eyeTestAudit.dtos.js +16 -3
package/.eslintrc.cjs
CHANGED
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,47 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import { logger } from 'tango-app-api-middleware';
|
|
4
|
+
import { connectdb } from './config/database/database.js';
|
|
5
|
+
import responseMiddleware from './config/response/response.js';
|
|
6
|
+
import errorMiddleware from './config/response/error.js';
|
|
7
|
+
import pkg from 'body-parser';
|
|
8
|
+
import { swaggerConfig } from './config/swagger/swagger.js';
|
|
9
|
+
import swagger from 'swagger-ui-express';
|
|
10
|
+
import traxAuditRouter from './src/routes/traxAudit.routes.js';
|
|
11
|
+
import auditWalletRouter from './src/routes/auditWallet.routes.js';
|
|
12
|
+
import auditRouter from './src/routes/audit.routes.js';
|
|
13
|
+
import cors from 'cors';
|
|
14
|
+
import eyeTestAuditRouter from './src/routes/eyeTestAudit.routes.js';
|
|
15
|
+
|
|
16
|
+
const { json, urlencoded } = pkg;
|
|
17
|
+
const env=dotenv.config();
|
|
18
|
+
|
|
19
|
+
const app = express();
|
|
20
|
+
const PORT = process.env.PORT || 3000;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
app.use( json( { limit: '500mb' } ) );
|
|
24
|
+
app.use(
|
|
25
|
+
urlencoded( {
|
|
26
|
+
extended: true,
|
|
27
|
+
} ),
|
|
28
|
+
);
|
|
29
|
+
app.use( cors() );
|
|
30
|
+
app.use( responseMiddleware );
|
|
31
|
+
app.use( errorMiddleware );
|
|
32
|
+
|
|
33
|
+
if ( env.error ) {
|
|
34
|
+
logger.error( '.env not found' );
|
|
35
|
+
process.exit( 1 );
|
|
36
|
+
}
|
|
37
|
+
app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
|
|
38
|
+
|
|
39
|
+
app.use( '/v3/audit', auditRouter );
|
|
40
|
+
app.use( '/v3/trax-audit', traxAuditRouter );
|
|
41
|
+
app.use( '/v3/audit-wallet', auditWalletRouter );
|
|
42
|
+
app.use( '/v3/eye-test-audit', eyeTestAuditRouter );
|
|
43
|
+
|
|
44
|
+
app.listen( PORT, () => {
|
|
45
|
+
logger.info( `server is running on port= ${PORT} ` );
|
|
46
|
+
connectdb();
|
|
47
|
+
} );
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.68-beta.
|
|
3
|
+
"version": "3.4.68-beta.16",
|
|
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"
|
|
@@ -12,6 +12,9 @@ dayjs.extend( timezone );
|
|
|
12
12
|
export async function getList( req, res ) {
|
|
13
13
|
try {
|
|
14
14
|
const inputData = req.body;
|
|
15
|
+
if ( inputData.clientId !== '11' ) {
|
|
16
|
+
return res.sendError( 'No data found', 204 );
|
|
17
|
+
}
|
|
15
18
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
16
19
|
const limit = inputData.limit || 10;
|
|
17
20
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
@@ -197,7 +200,6 @@ export async function getList( req, res ) {
|
|
|
197
200
|
'Engagement ID': element?._source?.engagementId,
|
|
198
201
|
'Compliance Score': element?._source?.complianceScore || 0,
|
|
199
202
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
200
|
-
'Visitor Type': element?._source?.visitorsType,
|
|
201
203
|
'Test Duration': duration || '',
|
|
202
204
|
'Audit Status': element?._source?.auditStatus || '',
|
|
203
205
|
'Audited By': userName?.userName || '',
|
|
@@ -483,7 +485,7 @@ export async function getFile( req, res ) {
|
|
|
483
485
|
|
|
484
486
|
};
|
|
485
487
|
await insertOpenSearchData( openSearch.EyeTestOutput, newRecord );
|
|
486
|
-
await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { auditStatus: 'In-Progress', auditType: 'Re-Audit' } } );
|
|
488
|
+
await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { auditStatus: 'In-Progress', auditType: 'Re-Audit', userId: req?.user?._id } } );
|
|
487
489
|
|
|
488
490
|
break;
|
|
489
491
|
default:
|
|
@@ -561,7 +563,7 @@ export async function save( req, res ) {
|
|
|
561
563
|
logger.info( { getOutput: getOutput } );
|
|
562
564
|
const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
|
|
563
565
|
if ( !output ) {
|
|
564
|
-
return res.sendError( '
|
|
566
|
+
return res.sendError( 'This file is currently being audited by another user. Any actions you perform will not be saved.', 400 );
|
|
565
567
|
}
|
|
566
568
|
const record ={
|
|
567
569
|
steps: inputData?.steps,
|
|
@@ -773,7 +775,6 @@ export async function getFileHistory( req, res ) {
|
|
|
773
775
|
let sourcesArray = resposnse.body.hits.hits.map( ( hit ) => hit );
|
|
774
776
|
let outputData=[];
|
|
775
777
|
for ( let data of sourcesArray ) {
|
|
776
|
-
// console.log( data._source.endTime );
|
|
777
778
|
let findUser= await findOneUser( { _id: new mongoose.Types.ObjectId( data._source.userId ) } );
|
|
778
779
|
outputData.push( {
|
|
779
780
|
_id: data._id,
|
|
@@ -2,10 +2,23 @@ import joi from 'joi';
|
|
|
2
2
|
|
|
3
3
|
export const getListSchema = joi.object(
|
|
4
4
|
{
|
|
5
|
-
fromDate: joi.string().required()
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
fromDate: joi.string().required().messages( {
|
|
6
|
+
'any.required': 'From Date is required',
|
|
7
|
+
'string.empty': 'From Date cannot be empty',
|
|
8
|
+
} ),
|
|
9
|
+
toDate: joi.string().required().messages( {
|
|
10
|
+
'any.required': 'To Date is required',
|
|
11
|
+
'string.empty': 'To Date cannot be empty',
|
|
12
|
+
} ),
|
|
13
|
+
type: joi.string().required().messages( {
|
|
14
|
+
'any.required': 'Type is required',
|
|
15
|
+
'string.empty': 'Type cannot be empty',
|
|
16
|
+
} ),
|
|
8
17
|
demographics: joi.array().optional(),
|
|
18
|
+
clientId: joi.string().required().messages( {
|
|
19
|
+
'any.required': 'Client ID is required',
|
|
20
|
+
'string.empty': 'Client ID cannot be empty',
|
|
21
|
+
} ),
|
|
9
22
|
storeId: joi.array().optional(),
|
|
10
23
|
limit: joi.number().optional(),
|
|
11
24
|
offset: joi.number().optional(),
|