blixify-server 0.2.6 → 0.2.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.
@@ -0,0 +1,18 @@
1
+ import type { WrapperLib } from "./mongoWrapper";
2
+ export declare class TrackVisionWrapper {
3
+ static readonly BASE_URL: string;
4
+ username: string;
5
+ password: string;
6
+ lib: WrapperLib;
7
+ constructor(username: string, password: string, lib: WrapperLib);
8
+ handleSafeTruckRequest: (endpoint: string, data: any) => Promise<any>;
9
+ initGetVehiclesPositionData: () => Promise<any>;
10
+ initGetVehiclePositionDataByPlateNo: (plateNo: string) => Promise<any>;
11
+ initGetVehicleHistoricalPlayback: (plateNo: string, fromDateTime?: string, toDateTime?: string) => Promise<any>;
12
+ initGetVehicleListing: () => Promise<any>;
13
+ initGetVehicleLicenseDocuments: () => Promise<any>;
14
+ initGetGeofenceListing: () => Promise<any>;
15
+ initGetGeofenceNotification: (fromDateTime: string, toDateTime: string) => Promise<any>;
16
+ init: () => any;
17
+ }
18
+ //# sourceMappingURL=trackVisionWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackVisionWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/trackVisionWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAkC;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,UAAU,CAAC;gBAEJ,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU;IAM/D,sBAAsB,aAAoB,MAAM,QAAQ,GAAG,kBAoBzD;IAEF,2BAA2B,qBAEzB;IAEF,mCAAmC,YAAa,MAAM,kBAOpD;IAEF,gCAAgC,YACrB,MAAM,iBACA,MAAM,eACR,MAAM,kBAOnB;IAEF,qBAAqB,qBAKnB;IAEF,8BAA8B,qBAK5B;IAEF,sBAAsB,qBAEpB;IAEF,2BAA2B,iBAAkB,MAAM,cAAc,MAAM,kBAKrE;IAEF,IAAI,YAwHF;CACH"}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TrackVisionWrapper = void 0;
13
+ class TrackVisionWrapper {
14
+ constructor(username, password, lib) {
15
+ this.handleSafeTruckRequest = (endpoint, data) => __awaiter(this, void 0, void 0, function* () {
16
+ const response = yield fetch(`${TrackVisionWrapper.BASE_URL}${endpoint}`, {
17
+ method: "POST",
18
+ headers: {
19
+ "Content-Type": "application/json",
20
+ },
21
+ body: JSON.stringify(Object.assign({ username: this.username, password: this.password }, data)),
22
+ });
23
+ const result = yield response.json();
24
+ if (result.isERROR) {
25
+ throw new Error(result.errorMessage);
26
+ }
27
+ return result;
28
+ });
29
+ this.initGetVehiclesPositionData = () => {
30
+ return this.handleSafeTruckRequest("/api2/gps/getVehiclePositionData", {});
31
+ };
32
+ this.initGetVehiclePositionDataByPlateNo = (plateNo) => {
33
+ return this.handleSafeTruckRequest("/api2/gps/getVehiclePositionDataByPlateNo", {
34
+ plateNo,
35
+ });
36
+ };
37
+ this.initGetVehicleHistoricalPlayback = (plateNo, fromDateTime, toDateTime) => {
38
+ return this.handleSafeTruckRequest("/api2/gps/getHistoricalPB", {
39
+ plateNo,
40
+ fromDateTime,
41
+ toDateTime,
42
+ });
43
+ };
44
+ this.initGetVehicleListing = () => {
45
+ return this.handleSafeTruckRequest("/api2/vehicle/getVehicleListingData", {});
46
+ };
47
+ this.initGetVehicleLicenseDocuments = () => {
48
+ return this.handleSafeTruckRequest("/api2/vehicle/getVehiclesLicenseDocumentsData", {});
49
+ };
50
+ this.initGetGeofenceListing = () => {
51
+ return this.handleSafeTruckRequest("/api2/gps/getGeofence", {});
52
+ };
53
+ this.initGetGeofenceNotification = (fromDateTime, toDateTime) => {
54
+ return this.handleSafeTruckRequest("/api2/gps/getGeofenceNotification", {
55
+ fromDateTime,
56
+ toDateTime,
57
+ });
58
+ };
59
+ this.init = () => {
60
+ const router = this.lib.express.Router();
61
+ /**
62
+ * @Input :
63
+ * None
64
+ */
65
+ router.post("/getVehiclesPositionData", (_req, res) => __awaiter(this, void 0, void 0, function* () {
66
+ try {
67
+ const result = yield this.initGetVehiclesPositionData();
68
+ res.json(result);
69
+ }
70
+ catch (err) {
71
+ if (err.message)
72
+ res.status(400).json({ err: err.message });
73
+ else
74
+ res.status(400).json({ err: err });
75
+ }
76
+ }));
77
+ /**
78
+ * @Input :
79
+ * plateNo - string
80
+ */
81
+ router.post("/getVehiclePositionDataByPlateNo", (req, res) => __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ const { plateNo } = req.body;
84
+ const result = yield this.initGetVehiclePositionDataByPlateNo(plateNo);
85
+ res.json(result);
86
+ }
87
+ catch (err) {
88
+ if (err.message)
89
+ res.status(400).json({ err: err.message });
90
+ else
91
+ res.status(400).json({ err: err });
92
+ }
93
+ }));
94
+ /**
95
+ * @Input :
96
+ * plateNo - string
97
+ * fromDateTime - string (Optional)
98
+ * toDateTime - string (Optional)
99
+ */
100
+ router.post("/getVehicleHistoricalPlayback", (req, res) => __awaiter(this, void 0, void 0, function* () {
101
+ try {
102
+ const { plateNo, fromDateTime, toDateTime } = req.body;
103
+ const result = yield this.initGetVehicleHistoricalPlayback(plateNo, fromDateTime, toDateTime);
104
+ res.json(result);
105
+ }
106
+ catch (err) {
107
+ if (err.message)
108
+ res.status(400).json({ err: err.message });
109
+ else
110
+ res.status(400).json({ err: err });
111
+ }
112
+ }));
113
+ /**
114
+ * @Input :
115
+ * None
116
+ */
117
+ router.post("/getVehicleListing", (_req, res) => __awaiter(this, void 0, void 0, function* () {
118
+ try {
119
+ const result = yield this.initGetVehicleListing();
120
+ res.json(result);
121
+ }
122
+ catch (err) {
123
+ if (err.message)
124
+ res.status(400).json({ err: err.message });
125
+ else
126
+ res.status(400).json({ err: err });
127
+ }
128
+ }));
129
+ /**
130
+ * @Input :
131
+ * None
132
+ */
133
+ router.post("/getVehicleLicenseDocuments", (_req, res) => __awaiter(this, void 0, void 0, function* () {
134
+ try {
135
+ const result = yield this.initGetVehicleLicenseDocuments();
136
+ res.json(result);
137
+ }
138
+ catch (err) {
139
+ if (err.message)
140
+ res.status(400).json({ err: err.message });
141
+ else
142
+ res.status(400).json({ err: err });
143
+ }
144
+ }));
145
+ /**
146
+ * @Input :
147
+ * None
148
+ */
149
+ router.post("/getGeofenceListing", (_req, res) => __awaiter(this, void 0, void 0, function* () {
150
+ try {
151
+ const result = yield this.initGetGeofenceListing();
152
+ res.json(result);
153
+ }
154
+ catch (err) {
155
+ if (err.message)
156
+ res.status(400).json({ err: err.message });
157
+ else
158
+ res.status(400).json({ err: err });
159
+ }
160
+ }));
161
+ /**
162
+ * @Input :
163
+ * fromDateTime - string
164
+ * toDateTime - string
165
+ */
166
+ router.post("/getGeofenceNotification", (req, res) => __awaiter(this, void 0, void 0, function* () {
167
+ try {
168
+ const { fromDateTime, toDateTime } = req.body;
169
+ const result = yield this.initGetGeofenceNotification(fromDateTime, toDateTime);
170
+ res.json(result);
171
+ }
172
+ catch (err) {
173
+ if (err.message)
174
+ res.status(400).json({ err: err.message });
175
+ else
176
+ res.status(400).json({ err: err });
177
+ }
178
+ }));
179
+ return router;
180
+ };
181
+ this.username = username;
182
+ this.password = password;
183
+ this.lib = lib;
184
+ }
185
+ }
186
+ exports.TrackVisionWrapper = TrackVisionWrapper;
187
+ TrackVisionWrapper.BASE_URL = "http://trackvision2.ddns.net";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,
@@ -27,6 +27,7 @@
27
27
  "start:auth": "cd dist && node authServer.js",
28
28
  "start:aws": "cd dist && node awsServer.js",
29
29
  "start:monday": "cd dist && node mondayServer.js",
30
+ "start:trackVision": "cd dist && node trackVisionServer.js",
30
31
  "install:husky": "yarn husky install"
31
32
  },
32
33
  "config": {