elseware-nodejs 1.11.6 → 1.11.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.
- package/LICENSE +20 -20
- package/README.md +49 -49
- package/dist/index.cjs +43 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -7
- package/dist/index.js.map +1 -1
- package/package.json +78 -78
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 elseware Technology
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 elseware Technology
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# elseware-nodejs
|
|
2
|
-
|
|
3
|
-
A modern Node.js utility and application framework powering the Elseware ecosystem.
|
|
4
|
-
|
|
5
|
-
`elseware-nodejs` provides a collection of reusable components, utilities, middleware, abstractions, and development patterns for building scalable Node.js applications and microservices.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- TypeScript-first development
|
|
10
|
-
- Express.js integration
|
|
11
|
-
- Repository pattern abstractions
|
|
12
|
-
- Service layer architecture
|
|
13
|
-
- Request context management
|
|
14
|
-
- Structured error handling
|
|
15
|
-
- Validation utilities
|
|
16
|
-
- Logging and observability support
|
|
17
|
-
- Microservice-friendly design
|
|
18
|
-
- Reusable application building blocks
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install elseware-nodejs
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
import { AppError } from "elseware-nodejs";
|
|
30
|
-
|
|
31
|
-
throw new AppError("Something went wrong");
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Documentation
|
|
35
|
-
|
|
36
|
-
Documentation, guides, and usage examples are available in the official repository.
|
|
37
|
-
|
|
38
|
-
## About elseware Technology
|
|
39
|
-
|
|
40
|
-
elseware Technology builds tools, frameworks, and solutions for software engineering, cloud computing, game development, and developer productivity.
|
|
41
|
-
|
|
42
|
-
## Contributing
|
|
43
|
-
|
|
44
|
-
Contributions, issues, and feature requests are welcome.
|
|
45
|
-
|
|
46
|
-
## License
|
|
47
|
-
|
|
48
|
-
This project is licensed under the MIT License.
|
|
49
|
-
|
|
1
|
+
# elseware-nodejs
|
|
2
|
+
|
|
3
|
+
A modern Node.js utility and application framework powering the Elseware ecosystem.
|
|
4
|
+
|
|
5
|
+
`elseware-nodejs` provides a collection of reusable components, utilities, middleware, abstractions, and development patterns for building scalable Node.js applications and microservices.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- TypeScript-first development
|
|
10
|
+
- Express.js integration
|
|
11
|
+
- Repository pattern abstractions
|
|
12
|
+
- Service layer architecture
|
|
13
|
+
- Request context management
|
|
14
|
+
- Structured error handling
|
|
15
|
+
- Validation utilities
|
|
16
|
+
- Logging and observability support
|
|
17
|
+
- Microservice-friendly design
|
|
18
|
+
- Reusable application building blocks
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install elseware-nodejs
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { AppError } from "elseware-nodejs";
|
|
30
|
+
|
|
31
|
+
throw new AppError("Something went wrong");
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
Documentation, guides, and usage examples are available in the official repository.
|
|
37
|
+
|
|
38
|
+
## About elseware Technology
|
|
39
|
+
|
|
40
|
+
elseware Technology builds tools, frameworks, and solutions for software engineering, cloud computing, game development, and developer productivity.
|
|
41
|
+
|
|
42
|
+
## Contributing
|
|
43
|
+
|
|
44
|
+
Contributions, issues, and feature requests are welcome.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
This project is licensed under the MIT License.
|
|
49
|
+
|
|
50
50
|
Copyright © 2026 elseware Technology.
|
package/dist/index.cjs
CHANGED
|
@@ -1942,6 +1942,7 @@ var CircularQueue = class {
|
|
|
1942
1942
|
}
|
|
1943
1943
|
this.data = new Array(capacity);
|
|
1944
1944
|
}
|
|
1945
|
+
capacity;
|
|
1945
1946
|
data;
|
|
1946
1947
|
head = 0;
|
|
1947
1948
|
tail = 0;
|
|
@@ -4919,6 +4920,8 @@ var DatabaseManager = class {
|
|
|
4919
4920
|
this.provider = provider;
|
|
4920
4921
|
this.options = options;
|
|
4921
4922
|
}
|
|
4923
|
+
provider;
|
|
4924
|
+
options;
|
|
4922
4925
|
async connect() {
|
|
4923
4926
|
try {
|
|
4924
4927
|
await this.provider.connect();
|
|
@@ -4969,6 +4972,7 @@ var MongoDatabaseProvider = class {
|
|
|
4969
4972
|
constructor(config) {
|
|
4970
4973
|
this.config = config;
|
|
4971
4974
|
}
|
|
4975
|
+
config;
|
|
4972
4976
|
async connect() {
|
|
4973
4977
|
mongoose__default.default.set("strictQuery", this.config.strictQuery ?? true);
|
|
4974
4978
|
await mongoose__default.default.connect(this.config.uri);
|
|
@@ -5383,6 +5387,7 @@ var JoiValidator = class {
|
|
|
5383
5387
|
constructor(schema) {
|
|
5384
5388
|
this.schema = schema;
|
|
5385
5389
|
}
|
|
5390
|
+
schema;
|
|
5386
5391
|
validate(data) {
|
|
5387
5392
|
const result = this.schema.validate(data, {
|
|
5388
5393
|
abortEarly: false,
|
|
@@ -5411,6 +5416,7 @@ var ZodValidator = class {
|
|
|
5411
5416
|
constructor(schema) {
|
|
5412
5417
|
this.schema = schema;
|
|
5413
5418
|
}
|
|
5419
|
+
schema;
|
|
5414
5420
|
validate(data) {
|
|
5415
5421
|
const result = this.schema.safeParse(data);
|
|
5416
5422
|
if (!result.success) {
|
|
@@ -5599,6 +5605,7 @@ var BearerTokenStrategy = class {
|
|
|
5599
5605
|
constructor(tokenProvider) {
|
|
5600
5606
|
this.tokenProvider = tokenProvider;
|
|
5601
5607
|
}
|
|
5608
|
+
tokenProvider;
|
|
5602
5609
|
async getHeaders() {
|
|
5603
5610
|
const token = await this.tokenProvider.getToken();
|
|
5604
5611
|
return {
|
|
@@ -5612,6 +5619,7 @@ var StaticTokenProvider = class {
|
|
|
5612
5619
|
constructor(token) {
|
|
5613
5620
|
this.token = token;
|
|
5614
5621
|
}
|
|
5622
|
+
token;
|
|
5615
5623
|
getToken() {
|
|
5616
5624
|
return this.token;
|
|
5617
5625
|
}
|
|
@@ -5655,9 +5663,9 @@ var HttpClient = class {
|
|
|
5655
5663
|
let attempt = 0;
|
|
5656
5664
|
let lastError;
|
|
5657
5665
|
while (true) {
|
|
5666
|
+
const controller = new AbortController();
|
|
5667
|
+
const timeout = setTimeout(() => controller.abort(), this.timeout);
|
|
5658
5668
|
try {
|
|
5659
|
-
const controller = new AbortController();
|
|
5660
|
-
const timeout = setTimeout(() => controller.abort(), this.timeout);
|
|
5661
5669
|
const authHeaders = await this.authStrategy?.getHeaders();
|
|
5662
5670
|
const response = await fetch(`${this.baseUrl}${path2}`, {
|
|
5663
5671
|
method,
|
|
@@ -5671,17 +5679,19 @@ var HttpClient = class {
|
|
|
5671
5679
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
5672
5680
|
});
|
|
5673
5681
|
clearTimeout(timeout);
|
|
5674
|
-
const
|
|
5682
|
+
const parsedBody = await this.parseResponseBody(response);
|
|
5675
5683
|
if (!response.ok) {
|
|
5684
|
+
const payload = parsedBody;
|
|
5676
5685
|
throw new AppError(
|
|
5677
|
-
|
|
5686
|
+
payload?.message ?? response.statusText ?? "HTTP request failed",
|
|
5678
5687
|
response.status,
|
|
5679
5688
|
{
|
|
5680
|
-
code:
|
|
5689
|
+
code: payload?.code ?? "HTTP_REQUEST_FAILED",
|
|
5681
5690
|
details: {
|
|
5682
5691
|
service: this.serviceName,
|
|
5683
5692
|
method,
|
|
5684
|
-
path: path2
|
|
5693
|
+
path: path2,
|
|
5694
|
+
status: response.status
|
|
5685
5695
|
}
|
|
5686
5696
|
}
|
|
5687
5697
|
);
|
|
@@ -5690,8 +5700,9 @@ var HttpClient = class {
|
|
|
5690
5700
|
logger.info(
|
|
5691
5701
|
`[${this.serviceName}]` + (correlationId2 ? ` [${correlationId2}]` : "") + ` ${method} ${path2}`
|
|
5692
5702
|
);
|
|
5693
|
-
return
|
|
5703
|
+
return parsedBody;
|
|
5694
5704
|
} catch (error) {
|
|
5705
|
+
clearTimeout(timeout);
|
|
5695
5706
|
lastError = error;
|
|
5696
5707
|
if (this.retryPolicy.shouldRetry(attempt, error)) {
|
|
5697
5708
|
const delay = this.retryPolicy.getDelay(attempt, error);
|
|
@@ -5712,6 +5723,31 @@ var HttpClient = class {
|
|
|
5712
5723
|
);
|
|
5713
5724
|
throw lastError;
|
|
5714
5725
|
}
|
|
5726
|
+
async parseResponseBody(response) {
|
|
5727
|
+
if (response.status === 204) {
|
|
5728
|
+
return null;
|
|
5729
|
+
}
|
|
5730
|
+
const responseLike = response;
|
|
5731
|
+
const contentType = response.headers?.get?.("content-type") ?? "";
|
|
5732
|
+
if (contentType.includes("application/json") && typeof responseLike.json === "function") {
|
|
5733
|
+
return responseLike.json();
|
|
5734
|
+
}
|
|
5735
|
+
if (typeof responseLike.json === "function") {
|
|
5736
|
+
try {
|
|
5737
|
+
return await responseLike.json();
|
|
5738
|
+
} catch {
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5741
|
+
if (typeof responseLike.text === "function") {
|
|
5742
|
+
const text = await responseLike.text();
|
|
5743
|
+
return {
|
|
5744
|
+
message: text || response.statusText || "HTTP request failed"
|
|
5745
|
+
};
|
|
5746
|
+
}
|
|
5747
|
+
return {
|
|
5748
|
+
message: response.statusText || "HTTP request failed"
|
|
5749
|
+
};
|
|
5750
|
+
}
|
|
5715
5751
|
sleep(ms) {
|
|
5716
5752
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5717
5753
|
}
|