equipped 4.4.6 → 5.0.0-alpha.2
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/CHANGELOG.md +152 -0
- package/lib/db/_instance.d.ts +3 -6
- package/lib/db/mongoose/changes.d.ts +2 -1
- package/lib/db/mongoose/index.d.ts +3 -2
- package/lib/db/mongoose/index.js +3 -1
- package/lib/db/mongoose/query.d.ts +1 -0
- package/lib/db/query.d.ts +12 -11
- package/lib/errors/customError.d.ts +0 -1
- package/lib/errors/customError.js +0 -1
- package/lib/errors/index.d.ts +0 -2
- package/lib/errors/index.js +0 -2
- package/lib/errors/types/refreshTokenMisusedError.d.ts +1 -1
- package/lib/errors/types/refreshTokenMisusedError.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/instance/index.d.ts +5 -4
- package/lib/instance/index.js +18 -4
- package/lib/instance/settings.d.ts +9 -1
- package/lib/instance/settings.js +10 -4
- package/lib/listeners/emitter.d.ts +3 -3
- package/lib/scripts/index.d.ts +1 -0
- package/lib/scripts/index.js +17 -0
- package/lib/scripts/json-schema.d.ts +6 -0
- package/lib/scripts/json-schema.js +110 -0
- package/lib/server/impls/base.d.ts +37 -0
- package/lib/server/impls/base.js +130 -0
- package/lib/server/impls/express.d.ts +16 -0
- package/lib/server/impls/express.js +176 -0
- package/lib/server/impls/fastify.d.ts +23 -0
- package/lib/server/impls/fastify.js +176 -0
- package/lib/server/index.d.ts +7 -6
- package/lib/server/index.js +10 -8
- package/lib/server/middlewares/errorHandler.d.ts +4 -1
- package/lib/server/middlewares/errorHandler.js +10 -11
- package/lib/server/middlewares/index.d.ts +1 -0
- package/lib/server/middlewares/index.js +1 -0
- package/lib/server/middlewares/notFoundHandler.d.ts +4 -1
- package/lib/server/middlewares/notFoundHandler.js +3 -3
- package/lib/server/middlewares/parseAuthUser.d.ts +4 -1
- package/lib/server/middlewares/parseAuthUser.js +2 -2
- package/lib/server/middlewares/requireAuthUser.d.ts +4 -2
- package/lib/server/middlewares/requireAuthUser.js +10 -3
- package/lib/server/middlewares/requireRefreshUser.d.ts +4 -2
- package/lib/server/middlewares/requireRefreshUser.js +9 -4
- package/lib/server/requests.d.ts +54 -0
- package/lib/server/requests.js +60 -0
- package/lib/server/routes.d.ts +9 -24
- package/lib/server/routes.js +51 -48
- package/lib/server/types.d.ts +88 -0
- package/lib/server/types.js +33 -0
- package/lib/structure/baseEntity.d.ts +4 -5
- package/lib/structure/baseEntity.js +21 -12
- package/lib/types/index.d.ts +20 -0
- package/lib/types/index.js +2 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +10 -1
- package/lib/validations/index.d.ts +13 -10
- package/lib/validations/index.js +4 -3
- package/package.json +39 -25
- package/lib/errors/types/accountNotVerifiedError.d.ts +0 -5
- package/lib/errors/types/accountNotVerifiedError.js +0 -12
- package/lib/errors/types/invalidToken.d.ts +0 -5
- package/lib/errors/types/invalidToken.js +0 -12
- package/lib/logger/index.d.ts +0 -13
- package/lib/logger/index.js +0 -41
- package/lib/server/app.d.ts +0 -12
- package/lib/server/app.js +0 -121
- package/lib/server/controllers/index.d.ts +0 -10
- package/lib/server/controllers/index.js +0 -46
- package/lib/server/controllers/request.d.ts +0 -40
- package/lib/server/controllers/request.js +0 -85
- package/lib/server/controllers/response.d.ts +0 -14
- package/lib/server/controllers/response.js +0 -16
- package/lib/server/statusCodes.d.ts +0 -16
- package/lib/server/statusCodes.js +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,158 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-alpha.2](https://github.com/kevinand11/equipped/compare/v5.0.0-alpha.1...v5.0.0-alpha.2) (2024-06-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* open api base url ([2a1becf](https://github.com/kevinand11/equipped/commit/2a1becf5f18f2b62ec5b2aada4c14db349e449bc))
|
|
11
|
+
|
|
12
|
+
## [5.0.0-alpha.1](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.17...v5.0.0-alpha.1) (2024-06-09)
|
|
13
|
+
|
|
14
|
+
## [5.0.0-beta.17](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.16...v5.0.0-beta.17) (2024-06-03)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* clean path ([b669329](https://github.com/kevinand11/equipped/commit/b669329136c319d827f9c6b5440342ef2b05c8ca))
|
|
20
|
+
|
|
21
|
+
## [5.0.0-beta.16](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.15...v5.0.0-beta.16) (2024-06-03)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* support headers in schema ([85a9319](https://github.com/kevinand11/equipped/commit/85a93195ffb9b97927dc22a61d5f118f49598926))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* error when cloning objects in toJSON ([1f4cf25](https://github.com/kevinand11/equipped/commit/1f4cf252a6924f0b2c329c11b41f5ac71c68f87b))
|
|
32
|
+
|
|
33
|
+
## [5.0.0-beta.15](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.14...v5.0.0-beta.15) (2024-06-02)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* remove slowdown to avoid esm ([414b2ef](https://github.com/kevinand11/equipped/commit/414b2ef3c047a0c9843ae828b21a1aeaa10925b9))
|
|
39
|
+
|
|
40
|
+
## [5.0.0-beta.14](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.13...v5.0.0-beta.14) (2024-06-02)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* use maps for registered maps for speed ([1882a24](https://github.com/kevinand11/equipped/commit/1882a24d02d666e7779212dbeb67e1022761c823))
|
|
46
|
+
|
|
47
|
+
## [5.0.0-beta.13](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.12...v5.0.0-beta.13) (2024-06-01)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* add description for each status code ([064a686](https://github.com/kevinand11/equipped/commit/064a68647ea91a5791aad75b1b95988accc38b32))
|
|
53
|
+
|
|
54
|
+
## [5.0.0-beta.12](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.11...v5.0.0-beta.12) (2024-06-01)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
59
|
+
* function overloading for validate function ([e1209ab](https://github.com/kevinand11/equipped/commit/e1209ab10f435514d7ac84c3c0af1788d7f3699d))
|
|
60
|
+
* references to BaseEntity ([071a07a](https://github.com/kevinand11/equipped/commit/071a07a827e6c4f73b5cf43ae462541c4518df21))
|
|
61
|
+
|
|
62
|
+
## [5.0.0-beta.11](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.10...v5.0.0-beta.11) (2024-06-01)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
|
|
67
|
+
* unique paths and keys for routes ([36d1776](https://github.com/kevinand11/equipped/commit/36d17762b6d31497e9f15883cc05073ff29a886e))
|
|
68
|
+
|
|
69
|
+
## [5.0.0-beta.10](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.9...v5.0.0-beta.10) (2024-05-31)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* generateJSONSchema ([062360b](https://github.com/kevinand11/equipped/commit/062360bb92ccdaa1ae8fa3d167f9bbb71f156f7c))
|
|
75
|
+
|
|
76
|
+
## [5.0.0-beta.9](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.8...v5.0.0-beta.9) (2024-05-31)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Bug Fixes
|
|
80
|
+
|
|
81
|
+
* generateJSONSchema ([39031fd](https://github.com/kevinand11/equipped/commit/39031fd7c8d0f18a93c55b3fc542fd33042e4e44))
|
|
82
|
+
|
|
83
|
+
## [5.0.0-beta.8](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.7...v5.0.0-beta.8) (2024-05-31)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Features
|
|
87
|
+
|
|
88
|
+
* route descriptions ([26b7323](https://github.com/kevinand11/equipped/commit/26b7323b523f83aedacd55096ae01f285fff1398))
|
|
89
|
+
|
|
90
|
+
## [5.0.0-beta.7](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-6...v5.0.0-beta.7) (2024-05-31)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
* schema for files ([13e8b80](https://github.com/kevinand11/equipped/commit/13e8b80d7893392994331416f769f4c50bc9b975))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Bug Fixes
|
|
99
|
+
|
|
100
|
+
* start server on 0.0.0.0 ([b654ee8](https://github.com/kevinand11/equipped/commit/b654ee88d1940fa5c89da8824240a62e727e99b8))
|
|
101
|
+
|
|
102
|
+
## [5.0.0-beta-6](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-5...v5.0.0-beta-6) (2024-05-30)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Bug Fixes
|
|
106
|
+
|
|
107
|
+
* res body defaults to any ([534b3a4](https://github.com/kevinand11/equipped/commit/534b3a4d20e832733a18b5f4735f9132d09669ad))
|
|
108
|
+
|
|
109
|
+
## [5.0.0-beta-5](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-4...v5.0.0-beta-5) (2024-05-30)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Bug Fixes
|
|
113
|
+
|
|
114
|
+
* more graceful defaults for Api ([a2d23f9](https://github.com/kevinand11/equipped/commit/a2d23f9ffcd0d4bcce73c7e3f8346afaea9baf55))
|
|
115
|
+
|
|
116
|
+
## [5.0.0-beta-4](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-3...v5.0.0-beta-4) (2024-05-30)
|
|
117
|
+
|
|
118
|
+
## [5.0.0-beta-3](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-2...v5.0.0-beta-3) (2024-05-30)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### Features
|
|
122
|
+
|
|
123
|
+
* allow custom validator in validate ([24a1d7a](https://github.com/kevinand11/equipped/commit/24a1d7a7cf69eabc73148dd9d36324d32ba95fc3))
|
|
124
|
+
|
|
125
|
+
## [5.0.0-beta-2](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-1...v5.0.0-beta-2) (2024-05-30)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Bug Fixes
|
|
129
|
+
|
|
130
|
+
* validate expects value of unknown not Record ([f3773f9](https://github.com/kevinand11/equipped/commit/f3773f905f6ccb5713fd30a0870d34fbd40c36fc))
|
|
131
|
+
|
|
132
|
+
## [5.0.0-beta-1](https://github.com/kevinand11/equipped/compare/v4.4.6...v5.0.0-beta-1) (2024-05-29)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Features
|
|
136
|
+
|
|
137
|
+
* add request type details on Request class ([d6c3752](https://github.com/kevinand11/equipped/commit/d6c37529e7eeac5a3c2ac20e0a205de49cb0465e))
|
|
138
|
+
* error handler per route ([0eccc21](https://github.com/kevinand11/equipped/commit/0eccc2129c559353efc65ae7ddf6bd0368e4031e))
|
|
139
|
+
* express server swagger ([95c811b](https://github.com/kevinand11/equipped/commit/95c811ba7a1086116c4327c37e1723b08b85059d))
|
|
140
|
+
* fastify swagger and custom schema validation error ([17b8710](https://github.com/kevinand11/equipped/commit/17b8710324c5c515daa8928d7028ef0150a6c30d))
|
|
141
|
+
* hide routes from schema ([304df23](https://github.com/kevinand11/equipped/commit/304df23a413f13cbd77f2eeeae00032d57dcea2c))
|
|
142
|
+
* new JsonValue and Ignored types ([ba73af4](https://github.com/kevinand11/equipped/commit/ba73af440f54549d10a974fd530c35ac912ec4dd))
|
|
143
|
+
* regustere schemas in server and reference by key ([7298bb0](https://github.com/kevinand11/equipped/commit/7298bb0ae6a908325bbef3cd308e2a7787147387))
|
|
144
|
+
* route securities ([a7b91a1](https://github.com/kevinand11/equipped/commit/a7b91a17acf15cc9013fe971b0adf2b96cd129da))
|
|
145
|
+
* schema for fastify ([990529c](https://github.com/kevinand11/equipped/commit/990529ce777d5fcfb6f4c11d634ecdc31aa2ea81))
|
|
146
|
+
* script to generate schemas ([2736ffa](https://github.com/kevinand11/equipped/commit/2736ffa68da13fb0b3ef96809a06be74754257ba))
|
|
147
|
+
* settings to toggle whether to schema validate ([6f64313](https://github.com/kevinand11/equipped/commit/6f643133632963cc5418259d3f97a9cf172bcdaf))
|
|
148
|
+
* throw ValidationError for failed schema validation in express app ([be30a5e](https://github.com/kevinand11/equipped/commit/be30a5e1ff7fe7016bf6effa9566a3a48acafd0e))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Bug Fixes
|
|
152
|
+
|
|
153
|
+
* catch errors in json schema ([02f4b0b](https://github.com/kevinand11/equipped/commit/02f4b0bb4c8eaa3fc0e1a25b14e2f531101d3d08))
|
|
154
|
+
* fix mongo createCollection command ([f0bfbfa](https://github.com/kevinand11/equipped/commit/f0bfbfa945d48741fbc56b6766483f12b35e0f7c))
|
|
155
|
+
* remove recursive type for QueryWhereBlock to prevent recursive errors in schema gen ([31e3af6](https://github.com/kevinand11/equipped/commit/31e3af64e6ead4b67e5a787df3c0b39671f8e39b))
|
|
156
|
+
|
|
5
157
|
### [4.4.6](https://github.com/kevinand11/equipped/compare/v4.4.5...v4.4.6) (2024-04-07)
|
|
6
158
|
|
|
7
159
|
### [4.4.5](https://github.com/kevinand11/equipped/compare/v4.4.4...v4.4.5) (2024-04-06)
|
package/lib/db/_instance.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { BaseEntity } from '../structure';
|
|
2
|
+
import { DeepPartial } from '../types';
|
|
2
3
|
import { DebeziumSetup } from './debezium';
|
|
3
4
|
import { QueryParams, QueryResults } from './query';
|
|
4
5
|
export declare abstract class Db {
|
|
5
6
|
#private;
|
|
6
|
-
abstract change<Model, Entity extends BaseEntity<any>>(collection: any, callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null): DbChange<Model, Entity>;
|
|
7
|
+
abstract change<Model, Entity extends BaseEntity<any, any>>(collection: any, callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null): DbChange<Model, Entity>;
|
|
7
8
|
abstract query<Model>(collection: any, params: QueryParams): Promise<QueryResults<Model>>;
|
|
8
9
|
protected _addToDbChanges(dbChange: DbChange<any, any>): this;
|
|
9
10
|
startAllDbChanges(): Promise<void>;
|
|
10
11
|
abstract start(): Promise<void>;
|
|
11
12
|
abstract close(): Promise<void>;
|
|
12
13
|
}
|
|
13
|
-
export declare abstract class DbChange<Model, Entity extends BaseEntity<any>> {
|
|
14
|
+
export declare abstract class DbChange<Model, Entity extends BaseEntity<any, any>> {
|
|
14
15
|
#private;
|
|
15
16
|
constructor(callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null);
|
|
16
17
|
abstract start(): Promise<void>;
|
|
@@ -18,9 +19,6 @@ export declare abstract class DbChange<Model, Entity extends BaseEntity<any>> {
|
|
|
18
19
|
get mapper(): (model: Model | null) => Entity | null;
|
|
19
20
|
protected _setup(key: string, data: DebeziumSetup): Promise<boolean>;
|
|
20
21
|
}
|
|
21
|
-
type DeepPartial<T> = {
|
|
22
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
23
|
-
};
|
|
24
22
|
export type DbChangeCallbacks<Model, Entity> = {
|
|
25
23
|
created?: (data: {
|
|
26
24
|
before: null;
|
|
@@ -36,4 +34,3 @@ export type DbChangeCallbacks<Model, Entity> = {
|
|
|
36
34
|
after: null;
|
|
37
35
|
}) => Promise<void>;
|
|
38
36
|
};
|
|
39
|
-
export {};
|
|
@@ -22,10 +22,11 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
25
26
|
import mongoose from 'mongoose';
|
|
26
27
|
import { BaseEntity } from '../../structure';
|
|
27
28
|
import { DbChange, DbChangeCallbacks } from '../_instance';
|
|
28
|
-
export declare class MongoDbChange<Model, Entity extends BaseEntity<any>> extends DbChange<Model, Entity> {
|
|
29
|
+
export declare class MongoDbChange<Model, Entity extends BaseEntity<any, any>> extends DbChange<Model, Entity> {
|
|
29
30
|
#private;
|
|
30
31
|
constructor(model: mongoose.Model<Model>, callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null);
|
|
31
32
|
start(): Promise<void>;
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
25
26
|
import mongoose from 'mongoose';
|
|
26
27
|
import { BaseEntity } from '../../structure';
|
|
27
|
-
import { QueryParams, QueryResults } from '../query';
|
|
28
28
|
import { Db, DbChangeCallbacks } from '../_instance';
|
|
29
|
+
import { QueryParams, QueryResults } from '../query';
|
|
29
30
|
import { MongoDbChange } from './changes';
|
|
30
31
|
export declare class MongoDb extends Db {
|
|
31
32
|
#private;
|
|
32
33
|
get Schema(): typeof mongoose.Schema;
|
|
33
34
|
get Id(): mongoose.Types.ObjectId;
|
|
34
35
|
use(dbName?: string): mongoose.Connection;
|
|
35
|
-
change<Model, Entity extends BaseEntity<any>>(model: mongoose.Model<Model>, callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null): MongoDbChange<Model, Entity>;
|
|
36
|
+
change<Model, Entity extends BaseEntity<any, any>>(model: mongoose.Model<Model>, callbacks: DbChangeCallbacks<Model, Entity>, mapper: (model: Model | null) => Entity | null): MongoDbChange<Model, Entity>;
|
|
36
37
|
query<Model>(model: mongoose.Model<Model>, params: QueryParams): Promise<QueryResults<Model>>;
|
|
37
38
|
start(): Promise<void>;
|
|
38
39
|
close(): Promise<void>;
|
package/lib/db/mongoose/index.js
CHANGED
|
@@ -58,7 +58,9 @@ class MongoDb extends _instance_1.Db {
|
|
|
58
58
|
await Promise.all([mongoose_1.default.connection, ...__classPrivateFieldGet(this, _MongoDb_instances, "a", _MongoDb_connections_get)].map((conn) => {
|
|
59
59
|
return Object.values(conn.models)
|
|
60
60
|
.map(async (model) => {
|
|
61
|
-
await conn.db.
|
|
61
|
+
await conn.db.createCollection(model.collection.name, {
|
|
62
|
+
changeStreamPreAndPostImages: { enabled: true }
|
|
63
|
+
});
|
|
62
64
|
});
|
|
63
65
|
}).flat());
|
|
64
66
|
}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
25
26
|
import mongoose from 'mongoose';
|
|
26
27
|
import { QueryParams, QueryResults } from '../query';
|
|
27
28
|
export declare const parseMongodbQueryParams: <Model>(model: mongoose.Model<Model>, params: QueryParams) => Promise<QueryResults<Model>>;
|
package/lib/db/query.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Paths } from '../types';
|
|
1
2
|
export type QueryResults<Model> = {
|
|
2
3
|
pages: {
|
|
3
4
|
start: number;
|
|
@@ -28,23 +29,23 @@ export declare enum Conditions {
|
|
|
28
29
|
nin = "nin",
|
|
29
30
|
exists = "exists"
|
|
30
31
|
}
|
|
31
|
-
export type QueryWhere = {
|
|
32
|
-
field: string
|
|
33
|
-
value:
|
|
32
|
+
export type QueryWhere<T> = {
|
|
33
|
+
field: Paths<T, string>;
|
|
34
|
+
value: unknown;
|
|
34
35
|
condition?: Conditions;
|
|
35
36
|
};
|
|
36
|
-
export type QueryWhereBlock = {
|
|
37
|
+
export type QueryWhereBlock<T> = {
|
|
37
38
|
condition: QueryKeys;
|
|
38
|
-
value:
|
|
39
|
+
value: QueryWhere<T>[];
|
|
39
40
|
};
|
|
40
|
-
export type QueryWhereClause = QueryWhere | QueryWhereBlock
|
|
41
|
-
export type QueryParams = {
|
|
42
|
-
where?: QueryWhereClause[];
|
|
43
|
-
auth?: QueryWhereClause[];
|
|
41
|
+
export type QueryWhereClause<T> = QueryWhere<T> | QueryWhereBlock<T>;
|
|
42
|
+
export type QueryParams<T = unknown> = {
|
|
43
|
+
where?: QueryWhereClause<T>[];
|
|
44
|
+
auth?: QueryWhereClause<T>[];
|
|
44
45
|
whereType?: QueryKeys;
|
|
45
46
|
authType?: QueryKeys;
|
|
46
47
|
sort?: {
|
|
47
|
-
field: string
|
|
48
|
+
field: Paths<T, string>;
|
|
48
49
|
desc?: boolean;
|
|
49
50
|
}[];
|
|
50
51
|
limit?: number;
|
|
@@ -52,6 +53,6 @@ export type QueryParams = {
|
|
|
52
53
|
page?: number;
|
|
53
54
|
search?: {
|
|
54
55
|
value: string;
|
|
55
|
-
fields: string[];
|
|
56
|
+
fields: Paths<T, string>[];
|
|
56
57
|
};
|
|
57
58
|
};
|
package/lib/errors/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './customError';
|
|
2
2
|
export * from './types/accessTokenExpired';
|
|
3
|
-
export * from './types/accountNotVerifiedError';
|
|
4
3
|
export * from './types/badRequestError';
|
|
5
|
-
export * from './types/invalidToken';
|
|
6
4
|
export * from './types/notAuthenticatedError';
|
|
7
5
|
export * from './types/notAuthorizedError';
|
|
8
6
|
export * from './types/notFoundError';
|
package/lib/errors/index.js
CHANGED
|
@@ -16,9 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./customError"), exports);
|
|
18
18
|
__exportStar(require("./types/accessTokenExpired"), exports);
|
|
19
|
-
__exportStar(require("./types/accountNotVerifiedError"), exports);
|
|
20
19
|
__exportStar(require("./types/badRequestError"), exports);
|
|
21
|
-
__exportStar(require("./types/invalidToken"), exports);
|
|
22
20
|
__exportStar(require("./types/notAuthenticatedError"), exports);
|
|
23
21
|
__exportStar(require("./types/notAuthorizedError"), exports);
|
|
24
22
|
__exportStar(require("./types/notFoundError"), exports);
|
|
@@ -6,7 +6,7 @@ const customError_1 = require("../customError");
|
|
|
6
6
|
class RefreshTokenMisusedError extends customError_1.CustomError {
|
|
7
7
|
constructor(message = 'Refresh token misused') {
|
|
8
8
|
super(message, [{ message }]);
|
|
9
|
-
this.statusCode = server_1.StatusCodes.
|
|
9
|
+
this.statusCode = server_1.StatusCodes.NotAuthenticated;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
exports.RefreshTokenMisusedError = RefreshTokenMisusedError;
|
package/lib/index.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export { Events } from './events/';
|
|
|
7
7
|
export * from './exit';
|
|
8
8
|
export * from './instance';
|
|
9
9
|
export * from './listeners';
|
|
10
|
+
export * from './scripts';
|
|
10
11
|
export * from './server';
|
|
11
12
|
export * from './storage';
|
|
12
13
|
export * from './structure';
|
|
14
|
+
export * from './types';
|
|
13
15
|
export * from './utils/auth';
|
|
14
16
|
export * from './utils/authUser';
|
|
15
17
|
export * from './utils/retry';
|
package/lib/index.js
CHANGED
|
@@ -28,9 +28,11 @@ __exportStar(require("./errors"), exports);
|
|
|
28
28
|
__exportStar(require("./exit"), exports);
|
|
29
29
|
__exportStar(require("./instance"), exports);
|
|
30
30
|
__exportStar(require("./listeners"), exports);
|
|
31
|
+
__exportStar(require("./scripts"), exports);
|
|
31
32
|
__exportStar(require("./server"), exports);
|
|
32
33
|
__exportStar(require("./storage"), exports);
|
|
33
34
|
__exportStar(require("./structure"), exports);
|
|
35
|
+
__exportStar(require("./types"), exports);
|
|
34
36
|
__exportStar(require("./utils/auth"), exports);
|
|
35
37
|
__exportStar(require("./utils/authUser"), exports);
|
|
36
38
|
__exportStar(require("./utils/retry"), exports);
|
package/lib/instance/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
1
2
|
import { BullJob } from '../bull';
|
|
2
3
|
import { Cache } from '../cache/cache';
|
|
3
4
|
import { MongoDb } from '../db/mongoose';
|
|
4
5
|
import { EventBus } from '../events/';
|
|
5
|
-
import {
|
|
6
|
-
import { Server } from '../server/app';
|
|
6
|
+
import { Server } from '../server';
|
|
7
7
|
import { Settings } from './settings';
|
|
8
8
|
export declare class Instance {
|
|
9
9
|
#private;
|
|
10
10
|
private constructor();
|
|
11
|
-
get logger(): Logger
|
|
11
|
+
get logger(): pino.Logger<any>;
|
|
12
12
|
get job(): BullJob;
|
|
13
13
|
get cache(): Cache;
|
|
14
14
|
get eventBus(): EventBus;
|
|
15
|
-
get server(): Server
|
|
15
|
+
get server(): Server<any, any>;
|
|
16
16
|
get dbs(): {
|
|
17
17
|
mongo: MongoDb;
|
|
18
18
|
};
|
|
19
19
|
get listener(): import("..").Listener;
|
|
20
20
|
get settings(): Settings;
|
|
21
|
+
static createLogger(): import("pino").Logger<any>;
|
|
21
22
|
static initialize(settings: Partial<Settings>): void;
|
|
22
23
|
static get(): Instance;
|
|
23
24
|
startConnections(): Promise<void>;
|
package/lib/instance/index.js
CHANGED
|
@@ -10,16 +10,19 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
13
16
|
var _a, _Instance_initialized, _Instance_instance, _Instance_settings, _Instance_logger, _Instance_job, _Instance_cache, _Instance_eventBus, _Instance_server, _Instance_dbs;
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.Instance = void 0;
|
|
19
|
+
const pino_1 = __importDefault(require("pino"));
|
|
16
20
|
const bull_1 = require("../bull");
|
|
17
21
|
const redis_cache_1 = require("../cache/types/redis-cache");
|
|
18
22
|
const mongoose_1 = require("../db/mongoose");
|
|
19
23
|
const kafka_1 = require("../events/kafka");
|
|
20
24
|
const exit_1 = require("../exit");
|
|
21
|
-
const
|
|
22
|
-
const app_1 = require("../server/app");
|
|
25
|
+
const server_1 = require("../server");
|
|
23
26
|
const settings_1 = require("./settings");
|
|
24
27
|
class Instance {
|
|
25
28
|
constructor() {
|
|
@@ -32,7 +35,7 @@ class Instance {
|
|
|
32
35
|
_Instance_dbs.set(this, null);
|
|
33
36
|
}
|
|
34
37
|
get logger() {
|
|
35
|
-
return __classPrivateFieldSet(this, _Instance_logger, __classPrivateFieldGet(this, _Instance_logger, "f") ||
|
|
38
|
+
return __classPrivateFieldSet(this, _Instance_logger, __classPrivateFieldGet(this, _Instance_logger, "f") || _a.createLogger(), "f");
|
|
36
39
|
}
|
|
37
40
|
get job() {
|
|
38
41
|
return __classPrivateFieldSet(this, _Instance_job, __classPrivateFieldGet(this, _Instance_job, "f") || new bull_1.BullJob(), "f");
|
|
@@ -44,7 +47,7 @@ class Instance {
|
|
|
44
47
|
return __classPrivateFieldSet(this, _Instance_eventBus, __classPrivateFieldGet(this, _Instance_eventBus, "f") || new kafka_1.KafkaEventBus(), "f");
|
|
45
48
|
}
|
|
46
49
|
get server() {
|
|
47
|
-
return __classPrivateFieldSet(this, _Instance_server, __classPrivateFieldGet(this, _Instance_server, "f") ||
|
|
50
|
+
return __classPrivateFieldSet(this, _Instance_server, __classPrivateFieldGet(this, _Instance_server, "f") || server_1.serverTypes[this.settings.server](), "f");
|
|
48
51
|
}
|
|
49
52
|
get dbs() {
|
|
50
53
|
return __classPrivateFieldSet(this, _Instance_dbs, __classPrivateFieldGet(this, _Instance_dbs, "f") || { mongo: new mongoose_1.MongoDb() }, "f");
|
|
@@ -55,6 +58,17 @@ class Instance {
|
|
|
55
58
|
get settings() {
|
|
56
59
|
return __classPrivateFieldGet(this, _Instance_settings, "f");
|
|
57
60
|
}
|
|
61
|
+
static createLogger() {
|
|
62
|
+
const defaultLogLevel = 'info';
|
|
63
|
+
return (0, pino_1.default)({
|
|
64
|
+
level: __classPrivateFieldGet(_a, _a, "f", _Instance_initialized) ? _a.get().settings?.logLevel ?? defaultLogLevel : defaultLogLevel,
|
|
65
|
+
serializers: {
|
|
66
|
+
err: pino_1.default.stdSerializers.err,
|
|
67
|
+
req: pino_1.default.stdSerializers.req,
|
|
68
|
+
res: pino_1.default.stdSerializers.res,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
58
72
|
static initialize(settings) {
|
|
59
73
|
__classPrivateFieldSet(_a, _a, true, "f", _Instance_initialized);
|
|
60
74
|
const instanceSettings = _a.get().settings;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Level } from 'pino';
|
|
2
|
+
import type { ServerTypes } from '../server';
|
|
1
3
|
export type Settings = {
|
|
2
|
-
isDev: boolean;
|
|
3
4
|
accessTokenKey: string;
|
|
4
5
|
accessTokenTTL: number;
|
|
5
6
|
refreshTokenKey: string;
|
|
@@ -22,5 +23,12 @@ export type Settings = {
|
|
|
22
23
|
slowDownDelayInMs: number;
|
|
23
24
|
hashSaltRounds: number;
|
|
24
25
|
paginationDefaultLimit: number;
|
|
26
|
+
server: ServerTypes;
|
|
27
|
+
openapiDocsVersion: string;
|
|
28
|
+
openapiDocsBaseUrl: string[];
|
|
29
|
+
openapiDocsPath: string;
|
|
30
|
+
logLevel: Level;
|
|
31
|
+
logRequests: boolean;
|
|
32
|
+
requestSchemaValidation: boolean;
|
|
25
33
|
};
|
|
26
34
|
export declare const defaulInstanceSetting: Settings;
|
package/lib/instance/settings.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaulInstanceSetting = void 0;
|
|
4
4
|
exports.defaulInstanceSetting = {
|
|
5
|
-
isDev: false,
|
|
6
5
|
accessTokenKey: 'accessTokenKey',
|
|
7
6
|
accessTokenTTL: 60 * 60,
|
|
8
7
|
refreshTokenKey: 'refreshTokenKey',
|
|
@@ -18,11 +17,18 @@ exports.defaulInstanceSetting = {
|
|
|
18
17
|
maxFileUploadSizeInMb: 500,
|
|
19
18
|
useRateLimit: false,
|
|
20
19
|
rateLimitPeriodInMs: 60 * 60 * 1000,
|
|
21
|
-
rateLimit:
|
|
20
|
+
rateLimit: 5000,
|
|
22
21
|
useSlowDown: false,
|
|
23
22
|
slowDownPeriodInMs: 10 * 60 * 1000,
|
|
24
|
-
slowDownAfter:
|
|
23
|
+
slowDownAfter: 2000,
|
|
25
24
|
slowDownDelayInMs: 500,
|
|
26
25
|
hashSaltRounds: 10,
|
|
27
|
-
paginationDefaultLimit: 100
|
|
26
|
+
paginationDefaultLimit: 100,
|
|
27
|
+
server: 'express',
|
|
28
|
+
openapiDocsVersion: '1.0.0',
|
|
29
|
+
openapiDocsBaseUrl: ['/'],
|
|
30
|
+
openapiDocsPath: '/__docs',
|
|
31
|
+
logLevel: 'info',
|
|
32
|
+
logRequests: true,
|
|
33
|
+
requestSchemaValidation: false,
|
|
28
34
|
};
|
|
@@ -13,9 +13,9 @@ export declare class Listener {
|
|
|
13
13
|
#private;
|
|
14
14
|
constructor(socket: io.Server, callers: SocketCallers);
|
|
15
15
|
start(): Promise<void>;
|
|
16
|
-
created(channels: string[], data:
|
|
17
|
-
updated(channels: string[], data:
|
|
18
|
-
deleted(channels: string[], data:
|
|
16
|
+
created<T extends BaseEntity<any, any>>(channels: string[], data: T): Promise<void>;
|
|
17
|
+
updated<T extends BaseEntity<any, any>>(channels: string[], data: T): Promise<void>;
|
|
18
|
+
deleted<T extends BaseEntity<any, any>>(channels: string[], data: T): Promise<void>;
|
|
19
19
|
set callers(callers: SocketCallers);
|
|
20
20
|
register(channel: string, onJoin?: OnJoinFn): this;
|
|
21
21
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './json-schema';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./json-schema"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Options } from 'ts-oas';
|
|
2
|
+
import { RouteSchema } from '../server';
|
|
3
|
+
export declare function generateJSONSchema(patterns: (string | RegExp)[], paths: string[], options?: {
|
|
4
|
+
tsConfigPath?: string | Record<string, unknown>;
|
|
5
|
+
options?: Options;
|
|
6
|
+
}): Record<string, RouteSchema>;
|