speedly 1.2.48 → 2.0.5
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/cjs/auth/auth2.d.ts +18 -0
- package/dist/cjs/auth/auth2.js +93 -0
- package/dist/cjs/config/init.d.ts +15 -0
- package/dist/cjs/config/init.js +58 -0
- package/dist/cjs/db/db.d.ts +65 -66
- package/dist/cjs/db/db.js +15 -22
- package/dist/cjs/document/index.d.ts +2 -0
- package/dist/cjs/document/index.js +7 -0
- package/dist/cjs/index.d.ts +3 -53
- package/dist/cjs/index.js +7 -22
- package/dist/cjs/kit/auth/auth.d.ts +3 -0
- package/dist/cjs/kit/auth/auth.js +38 -0
- package/dist/cjs/kit/auth/types.d.ts +19 -0
- package/dist/cjs/kit/auth/types.js +2 -0
- package/dist/cjs/kit/db/db.d.ts +182 -0
- package/dist/cjs/kit/db/db.js +594 -0
- package/dist/cjs/kit/db/utils.d.ts +3 -0
- package/dist/cjs/kit/db/utils.js +15 -0
- package/dist/cjs/kit/index.d.ts +5 -0
- package/dist/cjs/kit/index.js +14 -0
- package/dist/cjs/kit/uploader/uploader.d.ts +24 -0
- package/dist/cjs/kit/uploader/uploader.js +148 -0
- package/dist/cjs/kit/validator/validator.d.ts +9 -0
- package/dist/cjs/kit/validator/validator.js +36 -0
- package/dist/cjs/model/index.d.ts +2 -0
- package/dist/cjs/model/index.js +8 -0
- package/dist/cjs/model/translation.d.ts +24 -6
- package/dist/cjs/modules/index.d.ts +2 -0
- package/dist/cjs/modules/index.js +8 -0
- package/dist/cjs/modules/translation/translation.routes.js +12 -8
- package/dist/cjs/util/index.d.ts +2 -0
- package/dist/cjs/util/index.js +8 -0
- package/dist/cjs/util/makeOptional.js +17 -7
- package/dist/cjs/yup.config.d.ts +2 -0
- package/dist/cjs/yup.config.js +24 -0
- package/dist/esm/config/init.d.ts +15 -0
- package/dist/esm/config/init.js +58 -0
- package/dist/esm/db/db.d.ts +65 -66
- package/dist/esm/db/db.js +15 -22
- package/dist/esm/document/index.d.ts +2 -0
- package/dist/esm/document/index.js +7 -0
- package/dist/esm/index.d.ts +3 -53
- package/dist/esm/index.js +7 -22
- package/dist/esm/kit/auth/auth.d.ts +3 -0
- package/dist/esm/kit/auth/auth.js +38 -0
- package/dist/esm/kit/auth/types.d.ts +19 -0
- package/dist/esm/kit/auth/types.js +2 -0
- package/dist/esm/kit/db/db.d.ts +182 -0
- package/dist/esm/kit/db/db.js +594 -0
- package/dist/esm/kit/db/utils.d.ts +3 -0
- package/dist/esm/kit/db/utils.js +15 -0
- package/dist/esm/kit/index.d.ts +5 -0
- package/dist/esm/kit/index.js +14 -0
- package/dist/esm/kit/uploader/uploader.d.ts +24 -0
- package/dist/esm/kit/uploader/uploader.js +148 -0
- package/dist/esm/kit/validator/validator.d.ts +9 -0
- package/dist/esm/kit/validator/validator.js +36 -0
- package/dist/esm/model/index.d.ts +2 -0
- package/dist/esm/model/index.js +8 -0
- package/dist/esm/model/translation.d.ts +24 -6
- package/dist/esm/modules/index.d.ts +2 -0
- package/dist/esm/modules/index.js +8 -0
- package/dist/esm/modules/translation/translation.routes.js +12 -8
- package/dist/esm/util/index.d.ts +2 -0
- package/dist/esm/util/index.js +8 -0
- package/dist/esm/util/makeOptional.js +17 -7
- package/package.json +1 -1
package/dist/esm/db/db.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ type ConfigsType = {
|
|
|
13
13
|
dbType?: string;
|
|
14
14
|
path?: string;
|
|
15
15
|
dbEnv?: string;
|
|
16
|
-
response?: boolean;
|
|
17
16
|
type: "internal" | "external";
|
|
18
17
|
pagination?: {
|
|
19
18
|
quantity?: number;
|
|
@@ -27,157 +26,157 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
|
27
26
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
28
27
|
select(value: string | {
|
|
29
28
|
[key: string]: -1 | 1;
|
|
30
|
-
}): any;
|
|
29
|
+
}): /*elided*/ any;
|
|
31
30
|
sort(value: string | {
|
|
32
31
|
[key: string]: -1 | 1;
|
|
33
|
-
}): any;
|
|
34
|
-
skip(value: number): any;
|
|
35
|
-
limit(value: number): any;
|
|
36
|
-
populate(value: string | object | (string | object)[]): any;
|
|
32
|
+
}): /*elided*/ any;
|
|
33
|
+
skip(value: number): /*elided*/ any;
|
|
34
|
+
limit(value: number): /*elided*/ any;
|
|
35
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
37
36
|
};
|
|
38
37
|
create: (body?: {}) => {
|
|
39
38
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
40
39
|
select(value: string | {
|
|
41
40
|
[key: string]: -1 | 1;
|
|
42
|
-
}): any;
|
|
41
|
+
}): /*elided*/ any;
|
|
43
42
|
sort(value: string | {
|
|
44
43
|
[key: string]: -1 | 1;
|
|
45
|
-
}): any;
|
|
46
|
-
skip(value: number): any;
|
|
47
|
-
limit(value: number): any;
|
|
48
|
-
populate(value: string | object | (string | object)[]): any;
|
|
44
|
+
}): /*elided*/ any;
|
|
45
|
+
skip(value: number): /*elided*/ any;
|
|
46
|
+
limit(value: number): /*elided*/ any;
|
|
47
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
49
48
|
};
|
|
50
49
|
updateOne: (match?: {}, body?: {}) => {
|
|
51
50
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
52
51
|
select(value: string | {
|
|
53
52
|
[key: string]: -1 | 1;
|
|
54
|
-
}): any;
|
|
53
|
+
}): /*elided*/ any;
|
|
55
54
|
sort(value: string | {
|
|
56
55
|
[key: string]: -1 | 1;
|
|
57
|
-
}): any;
|
|
58
|
-
skip(value: number): any;
|
|
59
|
-
limit(value: number): any;
|
|
60
|
-
populate(value: string | object | (string | object)[]): any;
|
|
56
|
+
}): /*elided*/ any;
|
|
57
|
+
skip(value: number): /*elided*/ any;
|
|
58
|
+
limit(value: number): /*elided*/ any;
|
|
59
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
61
60
|
};
|
|
62
61
|
updateMany: (match?: {}, body?: {}) => {
|
|
63
62
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
64
63
|
select(value: string | {
|
|
65
64
|
[key: string]: -1 | 1;
|
|
66
|
-
}): any;
|
|
65
|
+
}): /*elided*/ any;
|
|
67
66
|
sort(value: string | {
|
|
68
67
|
[key: string]: -1 | 1;
|
|
69
|
-
}): any;
|
|
70
|
-
skip(value: number): any;
|
|
71
|
-
limit(value: number): any;
|
|
72
|
-
populate(value: string | object | (string | object)[]): any;
|
|
68
|
+
}): /*elided*/ any;
|
|
69
|
+
skip(value: number): /*elided*/ any;
|
|
70
|
+
limit(value: number): /*elided*/ any;
|
|
71
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
73
72
|
};
|
|
74
73
|
deleteOne: (match?: {}) => {
|
|
75
74
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
76
75
|
select(value: string | {
|
|
77
76
|
[key: string]: -1 | 1;
|
|
78
|
-
}): any;
|
|
77
|
+
}): /*elided*/ any;
|
|
79
78
|
sort(value: string | {
|
|
80
79
|
[key: string]: -1 | 1;
|
|
81
|
-
}): any;
|
|
82
|
-
skip(value: number): any;
|
|
83
|
-
limit(value: number): any;
|
|
84
|
-
populate(value: string | object | (string | object)[]): any;
|
|
80
|
+
}): /*elided*/ any;
|
|
81
|
+
skip(value: number): /*elided*/ any;
|
|
82
|
+
limit(value: number): /*elided*/ any;
|
|
83
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
85
84
|
};
|
|
86
85
|
deleteMany: (match?: {}) => {
|
|
87
86
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
88
87
|
select(value: string | {
|
|
89
88
|
[key: string]: -1 | 1;
|
|
90
|
-
}): any;
|
|
89
|
+
}): /*elided*/ any;
|
|
91
90
|
sort(value: string | {
|
|
92
91
|
[key: string]: -1 | 1;
|
|
93
|
-
}): any;
|
|
94
|
-
skip(value: number): any;
|
|
95
|
-
limit(value: number): any;
|
|
96
|
-
populate(value: string | object | (string | object)[]): any;
|
|
92
|
+
}): /*elided*/ any;
|
|
93
|
+
skip(value: number): /*elided*/ any;
|
|
94
|
+
limit(value: number): /*elided*/ any;
|
|
95
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
97
96
|
};
|
|
98
97
|
findOne: (match?: {}) => {
|
|
99
98
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
100
99
|
select(value: string | {
|
|
101
100
|
[key: string]: -1 | 1;
|
|
102
|
-
}): any;
|
|
101
|
+
}): /*elided*/ any;
|
|
103
102
|
sort(value: string | {
|
|
104
103
|
[key: string]: -1 | 1;
|
|
105
|
-
}): any;
|
|
106
|
-
skip(value: number): any;
|
|
107
|
-
limit(value: number): any;
|
|
108
|
-
populate(value: string | object | (string | object)[]): any;
|
|
104
|
+
}): /*elided*/ any;
|
|
105
|
+
skip(value: number): /*elided*/ any;
|
|
106
|
+
limit(value: number): /*elided*/ any;
|
|
107
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
109
108
|
};
|
|
110
109
|
findOneAndUpdate: (match?: {}, body?: {}) => {
|
|
111
110
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
112
111
|
select(value: string | {
|
|
113
112
|
[key: string]: -1 | 1;
|
|
114
|
-
}): any;
|
|
113
|
+
}): /*elided*/ any;
|
|
115
114
|
sort(value: string | {
|
|
116
115
|
[key: string]: -1 | 1;
|
|
117
|
-
}): any;
|
|
118
|
-
skip(value: number): any;
|
|
119
|
-
limit(value: number): any;
|
|
120
|
-
populate(value: string | object | (string | object)[]): any;
|
|
116
|
+
}): /*elided*/ any;
|
|
117
|
+
skip(value: number): /*elided*/ any;
|
|
118
|
+
limit(value: number): /*elided*/ any;
|
|
119
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
121
120
|
};
|
|
122
121
|
aggregate: (pipeline?: never[]) => {
|
|
123
122
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
124
123
|
select(value: string | {
|
|
125
124
|
[key: string]: -1 | 1;
|
|
126
|
-
}): any;
|
|
125
|
+
}): /*elided*/ any;
|
|
127
126
|
sort(value: string | {
|
|
128
127
|
[key: string]: -1 | 1;
|
|
129
|
-
}): any;
|
|
130
|
-
skip(value: number): any;
|
|
131
|
-
limit(value: number): any;
|
|
132
|
-
populate(value: string | object | (string | object)[]): any;
|
|
128
|
+
}): /*elided*/ any;
|
|
129
|
+
skip(value: number): /*elided*/ any;
|
|
130
|
+
limit(value: number): /*elided*/ any;
|
|
131
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
133
132
|
};
|
|
134
133
|
findOneAndDelete: (match?: {}) => {
|
|
135
134
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
136
135
|
select(value: string | {
|
|
137
136
|
[key: string]: -1 | 1;
|
|
138
|
-
}): any;
|
|
137
|
+
}): /*elided*/ any;
|
|
139
138
|
sort(value: string | {
|
|
140
139
|
[key: string]: -1 | 1;
|
|
141
|
-
}): any;
|
|
142
|
-
skip(value: number): any;
|
|
143
|
-
limit(value: number): any;
|
|
144
|
-
populate(value: string | object | (string | object)[]): any;
|
|
140
|
+
}): /*elided*/ any;
|
|
141
|
+
skip(value: number): /*elided*/ any;
|
|
142
|
+
limit(value: number): /*elided*/ any;
|
|
143
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
145
144
|
};
|
|
146
145
|
findById: (id?: string) => {
|
|
147
146
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
148
147
|
select(value: string | {
|
|
149
148
|
[key: string]: -1 | 1;
|
|
150
|
-
}): any;
|
|
149
|
+
}): /*elided*/ any;
|
|
151
150
|
sort(value: string | {
|
|
152
151
|
[key: string]: -1 | 1;
|
|
153
|
-
}): any;
|
|
154
|
-
skip(value: number): any;
|
|
155
|
-
limit(value: number): any;
|
|
156
|
-
populate(value: string | object | (string | object)[]): any;
|
|
152
|
+
}): /*elided*/ any;
|
|
153
|
+
skip(value: number): /*elided*/ any;
|
|
154
|
+
limit(value: number): /*elided*/ any;
|
|
155
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
157
156
|
};
|
|
158
157
|
findByIdAndUpdate: (id?: string, body?: {}) => {
|
|
159
158
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
160
159
|
select(value: string | {
|
|
161
160
|
[key: string]: -1 | 1;
|
|
162
|
-
}): any;
|
|
161
|
+
}): /*elided*/ any;
|
|
163
162
|
sort(value: string | {
|
|
164
163
|
[key: string]: -1 | 1;
|
|
165
|
-
}): any;
|
|
166
|
-
skip(value: number): any;
|
|
167
|
-
limit(value: number): any;
|
|
168
|
-
populate(value: string | object | (string | object)[]): any;
|
|
164
|
+
}): /*elided*/ any;
|
|
165
|
+
skip(value: number): /*elided*/ any;
|
|
166
|
+
limit(value: number): /*elided*/ any;
|
|
167
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
169
168
|
};
|
|
170
169
|
findByIdAndDelete: (id?: string) => {
|
|
171
170
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
172
171
|
select(value: string | {
|
|
173
172
|
[key: string]: -1 | 1;
|
|
174
|
-
}): any;
|
|
173
|
+
}): /*elided*/ any;
|
|
175
174
|
sort(value: string | {
|
|
176
175
|
[key: string]: -1 | 1;
|
|
177
|
-
}): any;
|
|
178
|
-
skip(value: number): any;
|
|
179
|
-
limit(value: number): any;
|
|
180
|
-
populate(value: string | object | (string | object)[]): any;
|
|
176
|
+
}): /*elided*/ any;
|
|
177
|
+
skip(value: number): /*elided*/ any;
|
|
178
|
+
limit(value: number): /*elided*/ any;
|
|
179
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
181
180
|
};
|
|
182
181
|
} | undefined;
|
|
183
182
|
export default db;
|
package/dist/esm/db/db.js
CHANGED
|
@@ -14,7 +14,6 @@ let configs = {
|
|
|
14
14
|
path: "../models",
|
|
15
15
|
type: "external",
|
|
16
16
|
dbEnv: "DB_URL",
|
|
17
|
-
response: true,
|
|
18
17
|
...(0, getConfig_1.default)("db"),
|
|
19
18
|
};
|
|
20
19
|
const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
@@ -486,26 +485,21 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
486
485
|
: []);
|
|
487
486
|
}
|
|
488
487
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
:
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
res.success ? res.success(200, resBody) : res.status(200).json(resBody);
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
next();
|
|
508
|
-
}
|
|
488
|
+
const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
|
|
489
|
+
const resBody = queryState.action == "aggregate"
|
|
490
|
+
? {
|
|
491
|
+
message: config?.message ||
|
|
492
|
+
`the ${collectionName} was found successfully`,
|
|
493
|
+
content: [],
|
|
494
|
+
...data[0],
|
|
495
|
+
}
|
|
496
|
+
: {
|
|
497
|
+
content: data,
|
|
498
|
+
...{ detail: Object.keys(detail).length ? detail : undefined },
|
|
499
|
+
message: config?.message ||
|
|
500
|
+
`the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
|
|
501
|
+
};
|
|
502
|
+
res.success ? res.success(200, resBody) : res.status(200).json(resBody);
|
|
509
503
|
}
|
|
510
504
|
}
|
|
511
505
|
catch (err) {
|
|
@@ -585,7 +579,6 @@ const db = (collectionName, config = configs) => {
|
|
|
585
579
|
path: "../models",
|
|
586
580
|
dbEnv: "DB_URL",
|
|
587
581
|
type: "external",
|
|
588
|
-
response: true,
|
|
589
582
|
...(0, getConfig_1.default)("db"),
|
|
590
583
|
};
|
|
591
584
|
Object.entries(config).forEach(([key, value]) => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const document_1 = __importDefault(require("./document"));
|
|
7
|
+
exports.default = document_1.default;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import validator from "./validator/validator";
|
|
5
|
-
import document from "./document/document";
|
|
6
|
-
declare const utils: {
|
|
7
|
-
translator: (text?: string, lang?: string) => Promise<unknown>;
|
|
8
|
-
};
|
|
9
|
-
declare const models: {
|
|
10
|
-
translation: import("mongoose").Model<{
|
|
11
|
-
text: string;
|
|
12
|
-
lang: string;
|
|
13
|
-
translatedText: string;
|
|
14
|
-
} & import("mongoose").DefaultTimestampProps, {}, {}, {}, import("mongoose").Document<unknown, {}, {
|
|
15
|
-
text: string;
|
|
16
|
-
lang: string;
|
|
17
|
-
translatedText: string;
|
|
18
|
-
} & import("mongoose").DefaultTimestampProps, {}, {
|
|
19
|
-
timestamps: true;
|
|
20
|
-
}> & {
|
|
21
|
-
text: string;
|
|
22
|
-
lang: string;
|
|
23
|
-
translatedText: string;
|
|
24
|
-
} & import("mongoose").DefaultTimestampProps & {
|
|
25
|
-
_id: import("mongoose").Types.ObjectId;
|
|
26
|
-
} & {
|
|
27
|
-
__v: number;
|
|
28
|
-
}, import("mongoose").Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
29
|
-
timestamps: true;
|
|
30
|
-
}, {
|
|
31
|
-
text: string;
|
|
32
|
-
lang: string;
|
|
33
|
-
translatedText: string;
|
|
34
|
-
} & import("mongoose").DefaultTimestampProps, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
35
|
-
text: string;
|
|
36
|
-
lang: string;
|
|
37
|
-
translatedText: string;
|
|
38
|
-
} & import("mongoose").DefaultTimestampProps>, {}, import("mongoose").ResolveSchemaOptions<{
|
|
39
|
-
timestamps: true;
|
|
40
|
-
}>> & import("mongoose").FlatRecord<{
|
|
41
|
-
text: string;
|
|
42
|
-
lang: string;
|
|
43
|
-
translatedText: string;
|
|
44
|
-
} & import("mongoose").DefaultTimestampProps> & {
|
|
45
|
-
_id: import("mongoose").Types.ObjectId;
|
|
46
|
-
} & {
|
|
47
|
-
__v: number;
|
|
48
|
-
}>>;
|
|
49
|
-
};
|
|
50
|
-
declare const modules: {
|
|
51
|
-
translation: import("express-serve-static-core").Router;
|
|
52
|
-
};
|
|
53
|
-
export { auth, db, uploader, validator, models, modules, utils, document };
|
|
1
|
+
import speedly from "./config/init";
|
|
2
|
+
export { Request, Response, NextFunction, Application, Router, RequestHandler, ErrorRequestHandler, } from "express";
|
|
3
|
+
export default speedly;
|
package/dist/esm/index.js
CHANGED
|
@@ -3,25 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
const validator_1 = __importDefault(require("./validator/validator"));
|
|
14
|
-
exports.validator = validator_1.default;
|
|
15
|
-
const translation_1 = __importDefault(require("./model/translation"));
|
|
16
|
-
const translation_routes_1 = __importDefault(require("./modules/translation/translation.routes"));
|
|
17
|
-
const document_1 = __importDefault(require("./document/document"));
|
|
18
|
-
exports.document = document_1.default;
|
|
19
|
-
const translator_1 = __importDefault(require("./util/translator"));
|
|
20
|
-
const utils = {
|
|
21
|
-
translator: translator_1.default,
|
|
22
|
-
};
|
|
23
|
-
exports.utils = utils;
|
|
24
|
-
const models = { translation: translation_1.default };
|
|
25
|
-
exports.models = models;
|
|
26
|
-
const modules = { translation: translation_routes_1.default };
|
|
27
|
-
exports.modules = modules;
|
|
6
|
+
exports.Router = void 0;
|
|
7
|
+
const init_1 = __importDefault(require("./config/init"));
|
|
8
|
+
// Export express types and classes
|
|
9
|
+
var express_1 = require("express");
|
|
10
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return express_1.Router; } });
|
|
11
|
+
// Override the default express() with our speedly`s functions
|
|
12
|
+
exports.default = init_1.default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getConfig_1 = __importDefault(require("../../util/getConfig"));
|
|
7
|
+
const gConfig = {
|
|
8
|
+
admin: { role: "ADMIN", model: "../models/admin" },
|
|
9
|
+
jwtSecretEnv: "JWT_KEY",
|
|
10
|
+
customValidator: (req, key) => {
|
|
11
|
+
return true;
|
|
12
|
+
},
|
|
13
|
+
...(0, getConfig_1.default)("auth"),
|
|
14
|
+
};
|
|
15
|
+
const executer = (authType) => {
|
|
16
|
+
const mw = async (req, res, next) => {
|
|
17
|
+
const accessResult = await gConfig?.customValidator?.(req, authType);
|
|
18
|
+
if (accessResult == null)
|
|
19
|
+
return next({ status: 401, json: { message: "Unauthorized" } });
|
|
20
|
+
if (!accessResult)
|
|
21
|
+
return next({ status: 403, json: { message: "Forbidden" } });
|
|
22
|
+
return next();
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(mw, "name", { value: `auth:${authType}` });
|
|
25
|
+
return mw;
|
|
26
|
+
};
|
|
27
|
+
const auth = {
|
|
28
|
+
user: () => {
|
|
29
|
+
return executer("user");
|
|
30
|
+
},
|
|
31
|
+
admin: (config) => {
|
|
32
|
+
return executer(`admin${config?.permission ? `:${config.permission}` : ""}`);
|
|
33
|
+
},
|
|
34
|
+
any: () => {
|
|
35
|
+
return executer("any");
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
exports.default = auth;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
type Handler = (req: Request, res: Response, next: (errorMessage?: string) => unknown) => unknown;
|
|
3
|
+
type Executer = (authField: string) => (req: Request, res: Response, next: NextFunction) => unknown;
|
|
4
|
+
type Auth = {
|
|
5
|
+
user: () => Handler;
|
|
6
|
+
admin: (config?: {
|
|
7
|
+
permission: string;
|
|
8
|
+
}) => Handler;
|
|
9
|
+
any: () => Handler;
|
|
10
|
+
};
|
|
11
|
+
type ConfigType = {
|
|
12
|
+
customValidator?: (req: Request, key: string) => Promise<boolean | null>;
|
|
13
|
+
jwtSecretEnv?: string;
|
|
14
|
+
admin?: {
|
|
15
|
+
role: string;
|
|
16
|
+
model: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export { Handler, Executer, Auth, ConfigType };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
declare module "express-serve-static-core" {
|
|
3
|
+
interface Request {
|
|
4
|
+
document?: any;
|
|
5
|
+
user?: any;
|
|
6
|
+
}
|
|
7
|
+
interface Response {
|
|
8
|
+
logger?: (message: string, details?: any) => void;
|
|
9
|
+
success?: (statusCode: number, body: any) => void;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
type ConfigsType = {
|
|
13
|
+
dbType?: string;
|
|
14
|
+
path?: string;
|
|
15
|
+
dbEnv?: string;
|
|
16
|
+
type: "internal" | "external";
|
|
17
|
+
pagination?: {
|
|
18
|
+
quantity?: number;
|
|
19
|
+
detailed?: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
25
|
+
find: (match?: {}) => {
|
|
26
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
27
|
+
select(value: string | {
|
|
28
|
+
[key: string]: -1 | 1;
|
|
29
|
+
}): /*elided*/ any;
|
|
30
|
+
sort(value: string | {
|
|
31
|
+
[key: string]: -1 | 1;
|
|
32
|
+
}): /*elided*/ any;
|
|
33
|
+
skip(value: number): /*elided*/ any;
|
|
34
|
+
limit(value: number): /*elided*/ any;
|
|
35
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
36
|
+
};
|
|
37
|
+
create: (body?: {}) => {
|
|
38
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
39
|
+
select(value: string | {
|
|
40
|
+
[key: string]: -1 | 1;
|
|
41
|
+
}): /*elided*/ any;
|
|
42
|
+
sort(value: string | {
|
|
43
|
+
[key: string]: -1 | 1;
|
|
44
|
+
}): /*elided*/ any;
|
|
45
|
+
skip(value: number): /*elided*/ any;
|
|
46
|
+
limit(value: number): /*elided*/ any;
|
|
47
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
48
|
+
};
|
|
49
|
+
updateOne: (match?: {}, body?: {}) => {
|
|
50
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
51
|
+
select(value: string | {
|
|
52
|
+
[key: string]: -1 | 1;
|
|
53
|
+
}): /*elided*/ any;
|
|
54
|
+
sort(value: string | {
|
|
55
|
+
[key: string]: -1 | 1;
|
|
56
|
+
}): /*elided*/ any;
|
|
57
|
+
skip(value: number): /*elided*/ any;
|
|
58
|
+
limit(value: number): /*elided*/ any;
|
|
59
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
60
|
+
};
|
|
61
|
+
updateMany: (match?: {}, body?: {}) => {
|
|
62
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
63
|
+
select(value: string | {
|
|
64
|
+
[key: string]: -1 | 1;
|
|
65
|
+
}): /*elided*/ any;
|
|
66
|
+
sort(value: string | {
|
|
67
|
+
[key: string]: -1 | 1;
|
|
68
|
+
}): /*elided*/ any;
|
|
69
|
+
skip(value: number): /*elided*/ any;
|
|
70
|
+
limit(value: number): /*elided*/ any;
|
|
71
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
72
|
+
};
|
|
73
|
+
deleteOne: (match?: {}) => {
|
|
74
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
75
|
+
select(value: string | {
|
|
76
|
+
[key: string]: -1 | 1;
|
|
77
|
+
}): /*elided*/ any;
|
|
78
|
+
sort(value: string | {
|
|
79
|
+
[key: string]: -1 | 1;
|
|
80
|
+
}): /*elided*/ any;
|
|
81
|
+
skip(value: number): /*elided*/ any;
|
|
82
|
+
limit(value: number): /*elided*/ any;
|
|
83
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
84
|
+
};
|
|
85
|
+
deleteMany: (match?: {}) => {
|
|
86
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
87
|
+
select(value: string | {
|
|
88
|
+
[key: string]: -1 | 1;
|
|
89
|
+
}): /*elided*/ any;
|
|
90
|
+
sort(value: string | {
|
|
91
|
+
[key: string]: -1 | 1;
|
|
92
|
+
}): /*elided*/ any;
|
|
93
|
+
skip(value: number): /*elided*/ any;
|
|
94
|
+
limit(value: number): /*elided*/ any;
|
|
95
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
96
|
+
};
|
|
97
|
+
findOne: (match?: {}) => {
|
|
98
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
99
|
+
select(value: string | {
|
|
100
|
+
[key: string]: -1 | 1;
|
|
101
|
+
}): /*elided*/ any;
|
|
102
|
+
sort(value: string | {
|
|
103
|
+
[key: string]: -1 | 1;
|
|
104
|
+
}): /*elided*/ any;
|
|
105
|
+
skip(value: number): /*elided*/ any;
|
|
106
|
+
limit(value: number): /*elided*/ any;
|
|
107
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
108
|
+
};
|
|
109
|
+
findOneAndUpdate: (match?: {}, body?: {}) => {
|
|
110
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
111
|
+
select(value: string | {
|
|
112
|
+
[key: string]: -1 | 1;
|
|
113
|
+
}): /*elided*/ any;
|
|
114
|
+
sort(value: string | {
|
|
115
|
+
[key: string]: -1 | 1;
|
|
116
|
+
}): /*elided*/ any;
|
|
117
|
+
skip(value: number): /*elided*/ any;
|
|
118
|
+
limit(value: number): /*elided*/ any;
|
|
119
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
120
|
+
};
|
|
121
|
+
aggregate: (pipeline?: never[]) => {
|
|
122
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
123
|
+
select(value: string | {
|
|
124
|
+
[key: string]: -1 | 1;
|
|
125
|
+
}): /*elided*/ any;
|
|
126
|
+
sort(value: string | {
|
|
127
|
+
[key: string]: -1 | 1;
|
|
128
|
+
}): /*elided*/ any;
|
|
129
|
+
skip(value: number): /*elided*/ any;
|
|
130
|
+
limit(value: number): /*elided*/ any;
|
|
131
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
132
|
+
};
|
|
133
|
+
findOneAndDelete: (match?: {}) => {
|
|
134
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
135
|
+
select(value: string | {
|
|
136
|
+
[key: string]: -1 | 1;
|
|
137
|
+
}): /*elided*/ any;
|
|
138
|
+
sort(value: string | {
|
|
139
|
+
[key: string]: -1 | 1;
|
|
140
|
+
}): /*elided*/ any;
|
|
141
|
+
skip(value: number): /*elided*/ any;
|
|
142
|
+
limit(value: number): /*elided*/ any;
|
|
143
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
144
|
+
};
|
|
145
|
+
findById: (id?: string) => {
|
|
146
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
147
|
+
select(value: string | {
|
|
148
|
+
[key: string]: -1 | 1;
|
|
149
|
+
}): /*elided*/ any;
|
|
150
|
+
sort(value: string | {
|
|
151
|
+
[key: string]: -1 | 1;
|
|
152
|
+
}): /*elided*/ any;
|
|
153
|
+
skip(value: number): /*elided*/ any;
|
|
154
|
+
limit(value: number): /*elided*/ any;
|
|
155
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
156
|
+
};
|
|
157
|
+
findByIdAndUpdate: (id?: string, body?: {}) => {
|
|
158
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
159
|
+
select(value: string | {
|
|
160
|
+
[key: string]: -1 | 1;
|
|
161
|
+
}): /*elided*/ any;
|
|
162
|
+
sort(value: string | {
|
|
163
|
+
[key: string]: -1 | 1;
|
|
164
|
+
}): /*elided*/ any;
|
|
165
|
+
skip(value: number): /*elided*/ any;
|
|
166
|
+
limit(value: number): /*elided*/ any;
|
|
167
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
168
|
+
};
|
|
169
|
+
findByIdAndDelete: (id?: string) => {
|
|
170
|
+
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
171
|
+
select(value: string | {
|
|
172
|
+
[key: string]: -1 | 1;
|
|
173
|
+
}): /*elided*/ any;
|
|
174
|
+
sort(value: string | {
|
|
175
|
+
[key: string]: -1 | 1;
|
|
176
|
+
}): /*elided*/ any;
|
|
177
|
+
skip(value: number): /*elided*/ any;
|
|
178
|
+
limit(value: number): /*elided*/ any;
|
|
179
|
+
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
180
|
+
};
|
|
181
|
+
} | undefined;
|
|
182
|
+
export default db;
|