tango-app-api-audit 3.3.0-alpha.6 → 3.3.0-alpha.7
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/app.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
12
|
+
const { json, urlencoded } = pkg;
|
|
13
|
+
const env=dotenv.config();
|
|
14
|
+
|
|
15
|
+
const app = express();
|
|
16
|
+
const PORT = process.env.PORT || 3000;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
app.use( json( { limit: '500mb' } ) );
|
|
20
|
+
app.use(
|
|
21
|
+
urlencoded( {
|
|
22
|
+
extended: true,
|
|
23
|
+
} ),
|
|
24
|
+
);
|
|
25
|
+
app.use( responseMiddleware );
|
|
26
|
+
app.use( errorMiddleware );
|
|
27
|
+
if ( env.error ) {
|
|
28
|
+
logger.error( '.env not found' );
|
|
29
|
+
process.exit( 1 );
|
|
30
|
+
}
|
|
31
|
+
app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
|
|
32
|
+
app.use( '/v3/audit', auditRouter );
|
|
33
|
+
|
|
34
|
+
app.listen( PORT, () => {
|
|
35
|
+
logger.info( `server is running on port= ${PORT} ` );
|
|
36
|
+
connectdb();
|
|
37
|
+
} );
|
|
38
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.7",
|
|
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"
|
|
@@ -717,8 +717,6 @@ export async function getAuditImage( msg ) {
|
|
|
717
717
|
|
|
718
718
|
export const getReauditImg = async ( filter, image ) => {
|
|
719
719
|
const chunkedMappingData = await chunkArray( image, 10 );
|
|
720
|
-
logger.info( { chunkedMappingData: chunkedMappingData, level: 5 } );
|
|
721
|
-
|
|
722
720
|
const promises = chunkedMappingData.map( async ( chunk ) => {
|
|
723
721
|
return mapFunction( chunk, filter );
|
|
724
722
|
} );
|
|
@@ -3099,6 +3097,7 @@ export async function auditImages( req, res ) {
|
|
|
3099
3097
|
}
|
|
3100
3098
|
|
|
3101
3099
|
const reauditImg = await getReauditImg( filterData, auditImageAC );
|
|
3100
|
+
logger.info( { reauditImg: reauditImg } );
|
|
3102
3101
|
if ( reauditImg?.length == 0 ) {
|
|
3103
3102
|
return res.sendError( 'No Data Found', 204 );
|
|
3104
3103
|
}
|
|
@@ -212,9 +212,10 @@ export async function getAuditImageData( data ) {
|
|
|
212
212
|
const fileDate = data.fileDate;
|
|
213
213
|
const files = [];
|
|
214
214
|
const fetchData = {
|
|
215
|
-
Bucket: `${bucket.
|
|
215
|
+
Bucket: `${bucket.auditInput}`,
|
|
216
216
|
filePath: `${fileDate}/${storeId}/${data.zoneName}/`,
|
|
217
217
|
};
|
|
218
|
+
|
|
218
219
|
const folderPath = await listFileWithoutLimit( fetchData );
|
|
219
220
|
if ( folderPath.statusCode == 404 ) {
|
|
220
221
|
return folderPath;
|
|
@@ -233,11 +234,10 @@ export async function getAuditImageData( data ) {
|
|
|
233
234
|
};
|
|
234
235
|
const data = await signedUrl( params );
|
|
235
236
|
files.push( {
|
|
236
|
-
|
|
237
|
-
imgName: indexes[1],
|
|
238
|
-
imgId: image[0],
|
|
237
|
+
img_path: data,
|
|
239
238
|
img_name: indexes[1],
|
|
240
|
-
|
|
239
|
+
img_id: image[0],
|
|
240
|
+
imgFile: auditImages[i],
|
|
241
241
|
} );
|
|
242
242
|
}
|
|
243
243
|
return files;
|
|
@@ -254,9 +254,8 @@ export async function getAuditImageData( data ) {
|
|
|
254
254
|
};
|
|
255
255
|
const data = await signedUrl( params );
|
|
256
256
|
files.push( {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
imgId: image[0],
|
|
257
|
+
img_path: data,
|
|
258
|
+
img_id: image[0],
|
|
260
259
|
imgFile: auditImages[i],
|
|
261
260
|
img_name: indexes[1],
|
|
262
261
|
} );
|
|
@@ -272,6 +271,7 @@ export async function getAuditImageData( data ) {
|
|
|
272
271
|
|
|
273
272
|
export async function zipDownloadImage( data ) {
|
|
274
273
|
try {
|
|
274
|
+
logger.info( { zipDownloadImage: data } );
|
|
275
275
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
276
276
|
const zip = new AdmZip();
|
|
277
277
|
const split = await chunkArray( data, 10 );
|
|
@@ -281,6 +281,7 @@ export async function zipDownloadImage( data ) {
|
|
|
281
281
|
Bucket: `${bucket.auditInput}`,
|
|
282
282
|
Key: chunk[i].imgFile.Key,
|
|
283
283
|
};
|
|
284
|
+
logger.info( { params: params } );
|
|
284
285
|
const fileBuffer = await getObject( params );
|
|
285
286
|
zip.addFile( chunk[i].imgFile.Key, fileBuffer.Body );
|
|
286
287
|
}
|