tango-app-api-report 3.4.0-beta.3 → 3.4.0-beta.5
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 +3 -3
- package/src/controllers/report.controllers.js +6 -5
- package/app.js +0 -42
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-report",
|
|
3
|
-
"version": "3.4.0-beta.
|
|
3
|
+
"version": "3.4.0-beta.5",
|
|
4
4
|
"description": "report",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -266,10 +266,10 @@ export async function clientReportList( req, res ) {
|
|
|
266
266
|
return res.sendError( 'No Data Found', 204 );
|
|
267
267
|
}
|
|
268
268
|
let paginatedData = count;
|
|
269
|
+
|
|
269
270
|
if ( inputData?.reportStatus==='' ) {
|
|
270
271
|
paginatedData = await paginate( count, offset, limit );
|
|
271
272
|
}
|
|
272
|
-
|
|
273
273
|
if ( inputData.reportStatus&&inputData.reportStatus!=='' ) {
|
|
274
274
|
paginatedData = await splitArray( paginatedData );
|
|
275
275
|
paginatedData= paginatedData.filter( ( ele ) => {
|
|
@@ -291,7 +291,7 @@ export async function clientReportList( req, res ) {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
export async function mapFunction( array ) {
|
|
294
|
-
for ( let
|
|
294
|
+
for ( let client of array ) {
|
|
295
295
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
296
296
|
const reportLog = await getOpenSearchData( openSearch.auditLog,
|
|
297
297
|
{
|
|
@@ -326,8 +326,10 @@ export async function mapFunction( array ) {
|
|
|
326
326
|
},
|
|
327
327
|
|
|
328
328
|
} );
|
|
329
|
+
|
|
329
330
|
client.reportStatus='notsent';
|
|
330
|
-
|
|
331
|
+
|
|
332
|
+
if ( reportLog?.body?.hits?.hits?.length > 0 ) {
|
|
331
333
|
const sourcesArray = reportLog.body.hits.hits.map( ( hit ) => hit._source );
|
|
332
334
|
if ( sourcesArray.length>0 ) {
|
|
333
335
|
client.reportStatus='sent';
|
|
@@ -349,9 +351,8 @@ export async function splitArray( array ) {
|
|
|
349
351
|
}
|
|
350
352
|
|
|
351
353
|
export async function paginate( array, pageNumber, pageSize ) {
|
|
352
|
-
const startIndex = pageNumber
|
|
354
|
+
const startIndex = pageNumber;
|
|
353
355
|
const endIndex = startIndex + pageSize;
|
|
354
|
-
|
|
355
356
|
return array.slice( startIndex, endIndex );
|
|
356
357
|
}
|
|
357
358
|
|
package/app.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { reportRouter } from './index.js';
|
|
3
|
-
|
|
4
|
-
import dotenv from 'dotenv';
|
|
5
|
-
import { logger } from 'tango-app-api-middleware';
|
|
6
|
-
import { connectdb } from './config/database/database.js';
|
|
7
|
-
import responseMiddleware from './config/response/response.js';
|
|
8
|
-
import errorMiddleware from './config/response/error.js';
|
|
9
|
-
import pkg from 'body-parser';
|
|
10
|
-
import { swaggerConfig } from './config/swagger/swagger.js';
|
|
11
|
-
import swagger from 'swagger-ui-express';
|
|
12
|
-
import cors from 'cors';
|
|
13
|
-
|
|
14
|
-
const { json, urlencoded } = pkg;
|
|
15
|
-
const env=dotenv.config();
|
|
16
|
-
|
|
17
|
-
const app = express();
|
|
18
|
-
const PORT = process.env.PORT || 3000;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
app.use( json( { limit: '500mb' } ) );
|
|
22
|
-
app.use(
|
|
23
|
-
urlencoded( {
|
|
24
|
-
extended: true,
|
|
25
|
-
} ),
|
|
26
|
-
);
|
|
27
|
-
app.use( responseMiddleware );
|
|
28
|
-
app.use( errorMiddleware );
|
|
29
|
-
app.use( cors() );
|
|
30
|
-
|
|
31
|
-
if ( env.error ) {
|
|
32
|
-
logger.error( '.env not found' );
|
|
33
|
-
process.exit( 1 );
|
|
34
|
-
}
|
|
35
|
-
app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
|
|
36
|
-
|
|
37
|
-
app.use( '/report', reportRouter );
|
|
38
|
-
|
|
39
|
-
app.listen( PORT, () => {
|
|
40
|
-
logger.info( `server is running on port= ${PORT} ` );
|
|
41
|
-
connectdb();
|
|
42
|
-
} );
|