@samuelaj1/eazisend-service-kit 1.0.2 → 1.0.3
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/dist/index.cjs +2 -35
- package/dist/index.d.cts +1 -24
- package/dist/index.d.ts +1 -24
- package/dist/index.js +2 -33
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,8 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
LogLevelTypes: () => LogLevelTypes,
|
|
34
|
-
elasticSearchRepo: () => elasticSearchRepo,
|
|
35
|
-
loggerRepo: () => loggerRepo,
|
|
36
34
|
registerErrorMiddleware: () => registerErrorMiddleware,
|
|
37
35
|
registerSecurityMiddleware: () => registerSecurityMiddleware,
|
|
38
36
|
registerStandardMiddleware: () => registerStandardMiddleware,
|
|
@@ -87,10 +85,6 @@ function registerSecurityMiddleware(app, args) {
|
|
|
87
85
|
}));
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
// src/repositories/logger.repo.ts
|
|
91
|
-
var import_winston = __toESM(require("winston"), 1);
|
|
92
|
-
var import_winston_elasticsearch = require("winston-elasticsearch");
|
|
93
|
-
|
|
94
88
|
// src/types/log.level.types.ts
|
|
95
89
|
var LogLevelTypes = /* @__PURE__ */ ((LogLevelTypes2) => {
|
|
96
90
|
LogLevelTypes2["DEBUG"] = "debug";
|
|
@@ -100,6 +94,8 @@ var LogLevelTypes = /* @__PURE__ */ ((LogLevelTypes2) => {
|
|
|
100
94
|
})(LogLevelTypes || {});
|
|
101
95
|
|
|
102
96
|
// src/repositories/logger.repo.ts
|
|
97
|
+
var import_winston = __toESM(require("winston"), 1);
|
|
98
|
+
var import_winston_elasticsearch = require("winston-elasticsearch");
|
|
103
99
|
var LoggerRepo = class {
|
|
104
100
|
logger;
|
|
105
101
|
esTransformer = (logData) => {
|
|
@@ -164,33 +160,6 @@ function runServer(app) {
|
|
|
164
160
|
}
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
// src/repositories/elasticsearch.repo.ts
|
|
168
|
-
var import_elasticsearch = require("@elastic/elasticsearch");
|
|
169
|
-
var ElasticsearchRepo = class {
|
|
170
|
-
elasticSearchClient;
|
|
171
|
-
/** Creates an Elasticsearch client using the configured cluster URL. */
|
|
172
|
-
constructor() {
|
|
173
|
-
this.elasticSearchClient = new import_elasticsearch.Client({
|
|
174
|
-
node: libConfig.ELASTIC_SEARCH_NODE_URL
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/** Elasticsearch connection is established. */
|
|
178
|
-
async establishElasticSearchConnection(args) {
|
|
179
|
-
let isConnected = false;
|
|
180
|
-
while (!isConnected) {
|
|
181
|
-
try {
|
|
182
|
-
const health = await this.elasticSearchClient.cluster.health({});
|
|
183
|
-
console.log("debug" /* DEBUG */, `${args.serviceName} Elasticsearch health status - ${health.status}`);
|
|
184
|
-
isConnected = true;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
console.log("error" /* ERROR */, "Connection to Elasticsearch failed. Retrying...");
|
|
187
|
-
console.log("error" /* ERROR */, `${args.serviceName} checkConnection() method:`, error);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
var elasticSearchRepo = new ElasticsearchRepo();
|
|
193
|
-
|
|
194
163
|
// src/middlewares/gateway.middleware.ts
|
|
195
164
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
196
165
|
function verifyGatewayRequest(serviceId) {
|
|
@@ -225,8 +194,6 @@ function registerErrorMiddleware(app) {
|
|
|
225
194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
226
195
|
0 && (module.exports = {
|
|
227
196
|
LogLevelTypes,
|
|
228
|
-
elasticSearchRepo,
|
|
229
|
-
loggerRepo,
|
|
230
197
|
registerErrorMiddleware,
|
|
231
198
|
registerSecurityMiddleware,
|
|
232
199
|
registerStandardMiddleware,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Express, Request, Response, NextFunction, Application } from 'express';
|
|
2
|
-
import { LogEntry } from 'winston';
|
|
3
2
|
|
|
4
3
|
declare function registerStandardMiddleware(app: Express): void;
|
|
5
4
|
|
|
@@ -13,32 +12,10 @@ declare enum LogLevelTypes {
|
|
|
13
12
|
ERROR = "error"
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
declare class LoggerRepo {
|
|
17
|
-
private logger?;
|
|
18
|
-
private esTransformer;
|
|
19
|
-
getInstance: (identifier: string, level?: LogLevelTypes) => LoggerRepo;
|
|
20
|
-
log(entry: LogEntry): void;
|
|
21
|
-
log(level: string, message: string, ...meta: unknown[]): void;
|
|
22
|
-
log(level: string, message: unknown): void;
|
|
23
|
-
}
|
|
24
|
-
declare const loggerRepo: LoggerRepo;
|
|
25
|
-
|
|
26
15
|
declare function runServer(app: Express): void;
|
|
27
16
|
|
|
28
|
-
/** Configured Elasticsearch cluster */
|
|
29
|
-
declare class ElasticsearchRepo {
|
|
30
|
-
private elasticSearchClient;
|
|
31
|
-
/** Creates an Elasticsearch client using the configured cluster URL. */
|
|
32
|
-
constructor();
|
|
33
|
-
/** Elasticsearch connection is established. */
|
|
34
|
-
establishElasticSearchConnection(args: {
|
|
35
|
-
serviceName: string;
|
|
36
|
-
}): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
declare const elasticSearchRepo: ElasticsearchRepo;
|
|
39
|
-
|
|
40
17
|
declare function verifyGatewayRequest(serviceId: string): (req: Request, _res: Response, next: NextFunction) => void;
|
|
41
18
|
|
|
42
19
|
declare function registerErrorMiddleware(app: Application): (err: Error, _req: Request, res: Response, _next: NextFunction) => void;
|
|
43
20
|
|
|
44
|
-
export { LogLevelTypes,
|
|
21
|
+
export { LogLevelTypes, registerErrorMiddleware, registerSecurityMiddleware, registerStandardMiddleware, runServer, verifyGatewayRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Express, Request, Response, NextFunction, Application } from 'express';
|
|
2
|
-
import { LogEntry } from 'winston';
|
|
3
2
|
|
|
4
3
|
declare function registerStandardMiddleware(app: Express): void;
|
|
5
4
|
|
|
@@ -13,32 +12,10 @@ declare enum LogLevelTypes {
|
|
|
13
12
|
ERROR = "error"
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
declare class LoggerRepo {
|
|
17
|
-
private logger?;
|
|
18
|
-
private esTransformer;
|
|
19
|
-
getInstance: (identifier: string, level?: LogLevelTypes) => LoggerRepo;
|
|
20
|
-
log(entry: LogEntry): void;
|
|
21
|
-
log(level: string, message: string, ...meta: unknown[]): void;
|
|
22
|
-
log(level: string, message: unknown): void;
|
|
23
|
-
}
|
|
24
|
-
declare const loggerRepo: LoggerRepo;
|
|
25
|
-
|
|
26
15
|
declare function runServer(app: Express): void;
|
|
27
16
|
|
|
28
|
-
/** Configured Elasticsearch cluster */
|
|
29
|
-
declare class ElasticsearchRepo {
|
|
30
|
-
private elasticSearchClient;
|
|
31
|
-
/** Creates an Elasticsearch client using the configured cluster URL. */
|
|
32
|
-
constructor();
|
|
33
|
-
/** Elasticsearch connection is established. */
|
|
34
|
-
establishElasticSearchConnection(args: {
|
|
35
|
-
serviceName: string;
|
|
36
|
-
}): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
declare const elasticSearchRepo: ElasticsearchRepo;
|
|
39
|
-
|
|
40
17
|
declare function verifyGatewayRequest(serviceId: string): (req: Request, _res: Response, next: NextFunction) => void;
|
|
41
18
|
|
|
42
19
|
declare function registerErrorMiddleware(app: Application): (err: Error, _req: Request, res: Response, _next: NextFunction) => void;
|
|
43
20
|
|
|
44
|
-
export { LogLevelTypes,
|
|
21
|
+
export { LogLevelTypes, registerErrorMiddleware, registerSecurityMiddleware, registerStandardMiddleware, runServer, verifyGatewayRequest };
|
package/dist/index.js
CHANGED
|
@@ -40,10 +40,6 @@ function registerSecurityMiddleware(app, args) {
|
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// src/repositories/logger.repo.ts
|
|
44
|
-
import winston from "winston";
|
|
45
|
-
import { ElasticsearchTransformer, ElasticsearchTransport } from "winston-elasticsearch";
|
|
46
|
-
|
|
47
43
|
// src/types/log.level.types.ts
|
|
48
44
|
var LogLevelTypes = /* @__PURE__ */ ((LogLevelTypes2) => {
|
|
49
45
|
LogLevelTypes2["DEBUG"] = "debug";
|
|
@@ -53,6 +49,8 @@ var LogLevelTypes = /* @__PURE__ */ ((LogLevelTypes2) => {
|
|
|
53
49
|
})(LogLevelTypes || {});
|
|
54
50
|
|
|
55
51
|
// src/repositories/logger.repo.ts
|
|
52
|
+
import winston from "winston";
|
|
53
|
+
import { ElasticsearchTransformer, ElasticsearchTransport } from "winston-elasticsearch";
|
|
56
54
|
var LoggerRepo = class {
|
|
57
55
|
logger;
|
|
58
56
|
esTransformer = (logData) => {
|
|
@@ -117,33 +115,6 @@ function runServer(app) {
|
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
|
|
120
|
-
// src/repositories/elasticsearch.repo.ts
|
|
121
|
-
import { Client } from "@elastic/elasticsearch";
|
|
122
|
-
var ElasticsearchRepo = class {
|
|
123
|
-
elasticSearchClient;
|
|
124
|
-
/** Creates an Elasticsearch client using the configured cluster URL. */
|
|
125
|
-
constructor() {
|
|
126
|
-
this.elasticSearchClient = new Client({
|
|
127
|
-
node: libConfig.ELASTIC_SEARCH_NODE_URL
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
/** Elasticsearch connection is established. */
|
|
131
|
-
async establishElasticSearchConnection(args) {
|
|
132
|
-
let isConnected = false;
|
|
133
|
-
while (!isConnected) {
|
|
134
|
-
try {
|
|
135
|
-
const health = await this.elasticSearchClient.cluster.health({});
|
|
136
|
-
console.log("debug" /* DEBUG */, `${args.serviceName} Elasticsearch health status - ${health.status}`);
|
|
137
|
-
isConnected = true;
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.log("error" /* ERROR */, "Connection to Elasticsearch failed. Retrying...");
|
|
140
|
-
console.log("error" /* ERROR */, `${args.serviceName} checkConnection() method:`, error);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
var elasticSearchRepo = new ElasticsearchRepo();
|
|
146
|
-
|
|
147
118
|
// src/middlewares/gateway.middleware.ts
|
|
148
119
|
import jwt from "jsonwebtoken";
|
|
149
120
|
function verifyGatewayRequest(serviceId) {
|
|
@@ -177,8 +148,6 @@ function registerErrorMiddleware(app) {
|
|
|
177
148
|
}
|
|
178
149
|
export {
|
|
179
150
|
LogLevelTypes,
|
|
180
|
-
elasticSearchRepo,
|
|
181
|
-
loggerRepo,
|
|
182
151
|
registerErrorMiddleware,
|
|
183
152
|
registerSecurityMiddleware,
|
|
184
153
|
registerStandardMiddleware,
|