@hastehaul/common 2.16.0 → 2.17.0
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/build/connections-wrappers/emitter-wrapper.d.ts +8 -0
- package/build/connections-wrappers/emitter-wrapper.js +15 -0
- package/build/connections-wrappers/socket-connection-wrapper.d.ts +1 -1
- package/build/middlewares/current-user.js +4 -1
- package/build/utils/utils.js +0 -24
- package/package.json +1 -1
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.emitterWrapper = void 0;
|
4
|
+
const events_1 = require("events");
|
5
|
+
class SingletonEventEmitter {
|
6
|
+
get instance() {
|
7
|
+
if (!this._instance)
|
8
|
+
throw new Error("Can not access EVENT EMITTER client before connecting");
|
9
|
+
return this._instance;
|
10
|
+
}
|
11
|
+
init() {
|
12
|
+
this._instance = new events_1.EventEmitter();
|
13
|
+
}
|
14
|
+
}
|
15
|
+
exports.emitterWrapper = new SingletonEventEmitter();
|
@@ -4,7 +4,7 @@ import { Server } from 'socket.io';
|
|
4
4
|
* A wrapper class for the Socket.IO server to manage connections and provide a centralized server instance.
|
5
5
|
*/
|
6
6
|
export declare class SocketWrapper {
|
7
|
-
|
7
|
+
private _io?;
|
8
8
|
/**
|
9
9
|
* Get the Socket.IO server instance.
|
10
10
|
*
|
@@ -44,6 +44,7 @@ const jsonwebtoken_1 = __importStar(require("jsonwebtoken"));
|
|
44
44
|
* @returns {Promise<void>} - A Promise that resolves once the user extraction is complete, but it is not used directly.
|
45
45
|
*/
|
46
46
|
const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
47
|
+
var _a;
|
47
48
|
req.currentUser = null;
|
48
49
|
const bearerToken = req.headers['authorization'];
|
49
50
|
if (!bearerToken) {
|
@@ -52,7 +53,9 @@ const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, functi
|
|
52
53
|
try {
|
53
54
|
const token = bearerToken.split(' ')[1];
|
54
55
|
if (token) {
|
55
|
-
|
56
|
+
// ! over here we should get the JWT_KEY from the db or use the => kubectl create secret generic jwt-secret --from-literal=jwt=secret
|
57
|
+
const jwtKey = (_a = process.env.JWT_KEY) !== null && _a !== void 0 ? _a : "";
|
58
|
+
const result = jsonwebtoken_1.default.verify(token, jwtKey.split('-').join(''));
|
56
59
|
req.currentUser = result;
|
57
60
|
}
|
58
61
|
}
|
package/build/utils/utils.js
CHANGED
@@ -61,30 +61,6 @@ function loadAsset(relativePath) {
|
|
61
61
|
}
|
62
62
|
});
|
63
63
|
}
|
64
|
-
// export async function isPointInGeoJSON(latLng: string | any[], fileName: string) {
|
65
|
-
// try {
|
66
|
-
// if (!latLng || latLng.length === 0) return { isInside: false, properties: null };
|
67
|
-
// const geoJsonData = await loadAsset(fileName);
|
68
|
-
// const geojson = JSON.parse(geoJsonData!);
|
69
|
-
// const points = point([latLng[1], latLng[0]]);
|
70
|
-
// for (const feature of geojson.features) {
|
71
|
-
// const geometry = feature.geometry;
|
72
|
-
// if (geometry.type === 'Polygon') {
|
73
|
-
// if (booleanPointInPolygon(points, polygon(geometry.coordinates))) {
|
74
|
-
// return { isInside: true, properties: feature.properties };
|
75
|
-
// }
|
76
|
-
// } else if (geometry.type === 'MultiPolygon') {
|
77
|
-
// if (geometry.coordinates.some((poly: Position[][]) => booleanPointInPolygon(points, polygon(poly)))) {
|
78
|
-
// return { isInside: true, properties: feature.properties };
|
79
|
-
// }
|
80
|
-
// }
|
81
|
-
// }
|
82
|
-
// return { isInside: false, properties: null };
|
83
|
-
// } catch (error) {
|
84
|
-
// console.error(`Error checking point in GeoJSON: ${error}`);
|
85
|
-
// return { isInside: null, properties: null };
|
86
|
-
// }
|
87
|
-
// }
|
88
64
|
let cachedGeoJsonData = null;
|
89
65
|
function isPointInGeoJSON(latLng, fileName) {
|
90
66
|
return __awaiter(this, void 0, void 0, function* () {
|