tango-app-api-audit 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/app.js +0 -180
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "audit & audit metrics apis",
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"
package/app.js DELETED
@@ -1,180 +0,0 @@
1
-
2
- import express from 'express';
3
- import { auditRouter } from './index.js';
4
-
5
- import dotenv from 'dotenv';
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 pkg from 'body-parser';
11
- import { auditMetricsRouter } from './index.js';
12
-
13
- const { json, urlencoded } = pkg;
14
- const env=dotenv.config();
15
-
16
- const app = express();
17
- const PORT = process.env.PORT || 3000;
18
-
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
-
29
- if ( env.error ) {
30
- logger.error( '.env not found' );
31
- process.exit( 1 );
32
- }
33
-
34
- module.exports.cameraupdate = async () => {
35
- try {
36
- console.log("cameraMigrate===============<>");
37
- const targetUrl =
38
- "mongodb+srv://tango-api-production:5TdxKKSkZiRVtjta@production.qc4rw.mongodb.net/tango-api-prod?retryWrites=true&w=majority";
39
- // const targetUrl =
40
- // "mongodb+srv://tangoeye:SUTONQosEUijJKWC@non-prod.jaups.mongodb.net/prod-dump?retryWrites=true&w=majority";
41
-
42
- const sourceUrl =
43
- "mongodb+srv://tango-api-production:5TdxKKSkZiRVtjta@production.qc4rw.mongodb.net/tango-retail?retryWrites=true&w=majority";
44
-
45
- const sourceClient = await MongoClient.connect(sourceUrl, {
46
- useNewUrlParser: true,
47
- useUnifiedTopology: true,
48
- });
49
-
50
- const sourceDB = sourceClient.db("tango-api-prod");
51
- const sourceCollection = sourceDB.collection("cameras");
52
- const data = await sourceCollection
53
- .find({
54
- storeId: {
55
- $in: [
56
- "11-982",
57
- "11-1256",
58
- "11-892",
59
- "11-1023",
60
- "11-1110",
61
- "11-1022",
62
- "11-1075",
63
- "11-931",
64
- "11-1003",
65
- "11-1136",
66
- "11-1169",
67
- "11-1428",
68
- "11-1300",
69
- "11-1505",
70
- "11-1376",
71
- "11-1271",
72
- "11-1286",
73
- "11-1419",
74
- "11-411",
75
- "11-1514",
76
- "11-1569",
77
- "11-1458",
78
- "11-1551",
79
- "11-1531",
80
- "11-1601",
81
- "11-1762",
82
- "11-1678",
83
- "11-1608",
84
- "11-1652",
85
- "11-1680",
86
- "11-1829",
87
- "11-1775",
88
- "11-1814",
89
- "11-198",
90
- "11-448",
91
- "11-404",
92
- "11-628",
93
- "11-809",
94
- "11-757",
95
- "11-525",
96
- "11-744",
97
- "11-690",
98
- "11-748",
99
- "11-663",
100
- "11-778",
101
- "11-806",
102
- "11-1179",
103
- "11-867",
104
- "11-872"
105
- ],
106
- },
107
- })
108
- .toArray();
109
-
110
- // // // Connect to the target database
111
- const targetClient = await MongoClient.connect(targetUrl, {
112
- useNewUrlParser: true,
113
- useUnifiedTopology: true,
114
- });
115
- const targetDB = targetClient.db("tango-retail");
116
- const targetCollection = targetDB.collection("cameras");
117
-
118
- for (const cameraData of data) {
119
- console.log(cameraData, "!!!!!!!!!");
120
- const inputData = {
121
- storeId: cameraData.storeId,
122
- masterServer:
123
- cameraData?.masterServer == null || undefined
124
- ? null
125
- : cameraData?.masterServer,
126
- client_id: cameraData.clientId,
127
- ip: cameraData.ip,
128
- manufacturer:
129
- cameraData.manufacturer == undefined ? "" : cameraData.manufacturer,
130
- cameraNumber: cameraData.no,
131
- userName: cameraData.username,
132
- password: cameraData.password,
133
- subType: cameraData.subType == undefined ? 0 : cameraData.subType,
134
- RTSP: cameraData.RTSP,
135
- retentionPeriod: cameraData?.retentionPeriod || 0,
136
- streamName: cameraData.streamName,
137
- isActivated: cameraData.isActivated,
138
- isUp: cameraData.isUp,
139
- macId: cameraData.macId == undefined ? "" : "",
140
- timeElapsed: cameraData.timeElapsed,
141
- filters: {
142
- yolo: cameraData.filters["yolo"],
143
- yoloProcess: cameraData.filters["yoloProcess"],
144
- },
145
- isVideoStream:
146
- cameraData?.IsVideoStream == undefined ||
147
- cameraData?.IsVideoStream == null ||
148
- cameraData?.IsVideoStream == false
149
- ? false
150
- : true,
151
- width: cameraData.width == undefined ? 0 : 0,
152
- height: cameraData.height == undefined ? 0 : 0,
153
- createdAt: cameraData.createdAt,
154
- updatedAt: cameraData.updatedAt,
155
- productModule: null,
156
- thumbnailImage: cameraData.thumbnailImage,
157
- };
158
- console.log(inputData, "***********<>");
159
-
160
- const result = await targetCollection.update(
161
- { streamName: cameraData.streamName },
162
- { $set: inputData },
163
- { upsert: true, setDefaultsOnInsert: true }
164
- );
165
- console.log( result );
166
- }
167
- } catch (error) {
168
- console.error(error);
169
- }
170
- };
171
-
172
-
173
- app.use( '/audit', auditRouter );
174
- app.use( '/audit-metrics', auditMetricsRouter );
175
-
176
- app.listen( PORT, () => {
177
- logger.info( `server is running on port= ${PORT} ` );
178
- connectdb();
179
- } );
180
-