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