speedly 1.3.0 → 2.0.6

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.
Files changed (67) hide show
  1. package/dist/cjs/auth/auth2.d.ts +18 -0
  2. package/dist/cjs/auth/auth2.js +93 -0
  3. package/dist/cjs/config/init.d.ts +15 -0
  4. package/dist/cjs/config/init.js +58 -0
  5. package/dist/cjs/db/db.d.ts +65 -67
  6. package/dist/cjs/db/db.js +15 -30
  7. package/dist/cjs/document/index.d.ts +2 -0
  8. package/dist/cjs/document/index.js +7 -0
  9. package/dist/cjs/index.d.ts +3 -53
  10. package/dist/cjs/index.js +9 -22
  11. package/dist/cjs/kit/auth/auth.d.ts +3 -0
  12. package/dist/cjs/kit/auth/auth.js +38 -0
  13. package/dist/cjs/kit/auth/types.d.ts +19 -0
  14. package/dist/cjs/kit/auth/types.js +2 -0
  15. package/dist/cjs/kit/db/db.d.ts +182 -0
  16. package/dist/cjs/kit/db/db.js +594 -0
  17. package/dist/cjs/kit/db/utils.d.ts +3 -0
  18. package/dist/cjs/kit/db/utils.js +15 -0
  19. package/dist/cjs/kit/index.d.ts +5 -0
  20. package/dist/cjs/kit/index.js +14 -0
  21. package/dist/cjs/kit/uploader/uploader.d.ts +24 -0
  22. package/dist/cjs/kit/uploader/uploader.js +148 -0
  23. package/dist/cjs/kit/validator/validator.d.ts +9 -0
  24. package/dist/cjs/kit/validator/validator.js +36 -0
  25. package/dist/cjs/model/index.d.ts +2 -0
  26. package/dist/cjs/model/index.js +8 -0
  27. package/dist/cjs/model/translation.d.ts +24 -6
  28. package/dist/cjs/modules/index.d.ts +2 -0
  29. package/dist/cjs/modules/index.js +8 -0
  30. package/dist/cjs/modules/translation/translation.routes.js +12 -8
  31. package/dist/cjs/util/index.d.ts +2 -0
  32. package/dist/cjs/util/index.js +8 -0
  33. package/dist/cjs/util/makeOptional.js +17 -7
  34. package/dist/cjs/yup.config.d.ts +2 -0
  35. package/dist/cjs/yup.config.js +24 -0
  36. package/dist/esm/config/init.d.ts +15 -0
  37. package/dist/esm/config/init.js +58 -0
  38. package/dist/esm/db/db.d.ts +65 -67
  39. package/dist/esm/db/db.js +15 -30
  40. package/dist/esm/document/index.d.ts +2 -0
  41. package/dist/esm/document/index.js +7 -0
  42. package/dist/esm/index.d.ts +3 -53
  43. package/dist/esm/index.js +9 -22
  44. package/dist/esm/kit/auth/auth.d.ts +3 -0
  45. package/dist/esm/kit/auth/auth.js +38 -0
  46. package/dist/esm/kit/auth/types.d.ts +19 -0
  47. package/dist/esm/kit/auth/types.js +2 -0
  48. package/dist/esm/kit/db/db.d.ts +182 -0
  49. package/dist/esm/kit/db/db.js +594 -0
  50. package/dist/esm/kit/db/utils.d.ts +3 -0
  51. package/dist/esm/kit/db/utils.js +15 -0
  52. package/dist/esm/kit/index.d.ts +5 -0
  53. package/dist/esm/kit/index.js +14 -0
  54. package/dist/esm/kit/uploader/uploader.d.ts +24 -0
  55. package/dist/esm/kit/uploader/uploader.js +148 -0
  56. package/dist/esm/kit/validator/validator.d.ts +9 -0
  57. package/dist/esm/kit/validator/validator.js +36 -0
  58. package/dist/esm/model/index.d.ts +2 -0
  59. package/dist/esm/model/index.js +8 -0
  60. package/dist/esm/model/translation.d.ts +24 -6
  61. package/dist/esm/modules/index.d.ts +2 -0
  62. package/dist/esm/modules/index.js +8 -0
  63. package/dist/esm/modules/translation/translation.routes.js +12 -8
  64. package/dist/esm/util/index.d.ts +2 -0
  65. package/dist/esm/util/index.js +8 -0
  66. package/dist/esm/util/makeOptional.js +17 -7
  67. package/package.json +1 -1
@@ -13,8 +13,6 @@ type ConfigsType = {
13
13
  dbType?: string;
14
14
  path?: string;
15
15
  dbEnv?: string;
16
- response?: boolean;
17
- first?: boolean;
18
16
  type: "internal" | "external";
19
17
  pagination?: {
20
18
  quantity?: number;
@@ -28,157 +26,157 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
28
26
  (req: Request, res: Response, next: NextFunction): Promise<void>;
29
27
  select(value: string | {
30
28
  [key: string]: -1 | 1;
31
- }): any;
29
+ }): /*elided*/ any;
32
30
  sort(value: string | {
33
31
  [key: string]: -1 | 1;
34
- }): any;
35
- skip(value: number): any;
36
- limit(value: number): any;
37
- 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;
38
36
  };
39
37
  create: (body?: {}) => {
40
38
  (req: Request, res: Response, next: NextFunction): Promise<void>;
41
39
  select(value: string | {
42
40
  [key: string]: -1 | 1;
43
- }): any;
41
+ }): /*elided*/ any;
44
42
  sort(value: string | {
45
43
  [key: string]: -1 | 1;
46
- }): any;
47
- skip(value: number): any;
48
- limit(value: number): any;
49
- 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;
50
48
  };
51
49
  updateOne: (match?: {}, body?: {}) => {
52
50
  (req: Request, res: Response, next: NextFunction): Promise<void>;
53
51
  select(value: string | {
54
52
  [key: string]: -1 | 1;
55
- }): any;
53
+ }): /*elided*/ any;
56
54
  sort(value: string | {
57
55
  [key: string]: -1 | 1;
58
- }): any;
59
- skip(value: number): any;
60
- limit(value: number): any;
61
- 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;
62
60
  };
63
61
  updateMany: (match?: {}, body?: {}) => {
64
62
  (req: Request, res: Response, next: NextFunction): Promise<void>;
65
63
  select(value: string | {
66
64
  [key: string]: -1 | 1;
67
- }): any;
65
+ }): /*elided*/ any;
68
66
  sort(value: string | {
69
67
  [key: string]: -1 | 1;
70
- }): any;
71
- skip(value: number): any;
72
- limit(value: number): any;
73
- 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;
74
72
  };
75
73
  deleteOne: (match?: {}) => {
76
74
  (req: Request, res: Response, next: NextFunction): Promise<void>;
77
75
  select(value: string | {
78
76
  [key: string]: -1 | 1;
79
- }): any;
77
+ }): /*elided*/ any;
80
78
  sort(value: string | {
81
79
  [key: string]: -1 | 1;
82
- }): any;
83
- skip(value: number): any;
84
- limit(value: number): any;
85
- 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;
86
84
  };
87
85
  deleteMany: (match?: {}) => {
88
86
  (req: Request, res: Response, next: NextFunction): Promise<void>;
89
87
  select(value: string | {
90
88
  [key: string]: -1 | 1;
91
- }): any;
89
+ }): /*elided*/ any;
92
90
  sort(value: string | {
93
91
  [key: string]: -1 | 1;
94
- }): any;
95
- skip(value: number): any;
96
- limit(value: number): any;
97
- 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;
98
96
  };
99
97
  findOne: (match?: {}) => {
100
98
  (req: Request, res: Response, next: NextFunction): Promise<void>;
101
99
  select(value: string | {
102
100
  [key: string]: -1 | 1;
103
- }): any;
101
+ }): /*elided*/ any;
104
102
  sort(value: string | {
105
103
  [key: string]: -1 | 1;
106
- }): any;
107
- skip(value: number): any;
108
- limit(value: number): any;
109
- 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;
110
108
  };
111
109
  findOneAndUpdate: (match?: {}, body?: {}) => {
112
110
  (req: Request, res: Response, next: NextFunction): Promise<void>;
113
111
  select(value: string | {
114
112
  [key: string]: -1 | 1;
115
- }): any;
113
+ }): /*elided*/ any;
116
114
  sort(value: string | {
117
115
  [key: string]: -1 | 1;
118
- }): any;
119
- skip(value: number): any;
120
- limit(value: number): any;
121
- 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;
122
120
  };
123
121
  aggregate: (pipeline?: never[]) => {
124
122
  (req: Request, res: Response, next: NextFunction): Promise<void>;
125
123
  select(value: string | {
126
124
  [key: string]: -1 | 1;
127
- }): any;
125
+ }): /*elided*/ any;
128
126
  sort(value: string | {
129
127
  [key: string]: -1 | 1;
130
- }): any;
131
- skip(value: number): any;
132
- limit(value: number): any;
133
- 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;
134
132
  };
135
133
  findOneAndDelete: (match?: {}) => {
136
134
  (req: Request, res: Response, next: NextFunction): Promise<void>;
137
135
  select(value: string | {
138
136
  [key: string]: -1 | 1;
139
- }): any;
137
+ }): /*elided*/ any;
140
138
  sort(value: string | {
141
139
  [key: string]: -1 | 1;
142
- }): any;
143
- skip(value: number): any;
144
- limit(value: number): any;
145
- 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;
146
144
  };
147
145
  findById: (id?: string) => {
148
146
  (req: Request, res: Response, next: NextFunction): Promise<void>;
149
147
  select(value: string | {
150
148
  [key: string]: -1 | 1;
151
- }): any;
149
+ }): /*elided*/ any;
152
150
  sort(value: string | {
153
151
  [key: string]: -1 | 1;
154
- }): any;
155
- skip(value: number): any;
156
- limit(value: number): any;
157
- 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;
158
156
  };
159
157
  findByIdAndUpdate: (id?: string, body?: {}) => {
160
158
  (req: Request, res: Response, next: NextFunction): Promise<void>;
161
159
  select(value: string | {
162
160
  [key: string]: -1 | 1;
163
- }): any;
161
+ }): /*elided*/ any;
164
162
  sort(value: string | {
165
163
  [key: string]: -1 | 1;
166
- }): any;
167
- skip(value: number): any;
168
- limit(value: number): any;
169
- 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;
170
168
  };
171
169
  findByIdAndDelete: (id?: string) => {
172
170
  (req: Request, res: Response, next: NextFunction): Promise<void>;
173
171
  select(value: string | {
174
172
  [key: string]: -1 | 1;
175
- }): any;
173
+ }): /*elided*/ any;
176
174
  sort(value: string | {
177
175
  [key: string]: -1 | 1;
178
- }): any;
179
- skip(value: number): any;
180
- limit(value: number): any;
181
- 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;
182
180
  };
183
181
  } | undefined;
184
182
  export default db;
package/dist/esm/db/db.js CHANGED
@@ -14,8 +14,6 @@ let configs = {
14
14
  path: "../models",
15
15
  type: "external",
16
16
  dbEnv: "DB_URL",
17
- first: false,
18
- response: true,
19
17
  ...(0, getConfig_1.default)("db"),
20
18
  };
21
19
  const usingMongoDb = (collectionName, config = { type: "external" }) => {
@@ -487,32 +485,21 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
487
485
  : []);
488
486
  }
489
487
  }
490
- if (config?.response) {
491
- const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
492
- if (queryState.action == "aggregate" && config.first && data[0]?.content.length)
493
- data[0].content.length = data[0].content[0];
494
- const resBody = queryState.action == "aggregate"
495
- ? {
496
- message: config?.message ||
497
- `the ${collectionName} was found successfully`,
498
- content: [],
499
- ...data[0],
500
- }
501
- : {
502
- content: data,
503
- ...{
504
- detail: Object.keys(detail).length ? detail : undefined,
505
- },
506
- message: config?.message ||
507
- `the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
508
- };
509
- res.success
510
- ? res.success(200, resBody)
511
- : res.status(200).json(resBody);
512
- }
513
- else {
514
- next();
515
- }
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);
516
503
  }
517
504
  }
518
505
  catch (err) {
@@ -592,8 +579,6 @@ const db = (collectionName, config = configs) => {
592
579
  path: "../models",
593
580
  dbEnv: "DB_URL",
594
581
  type: "external",
595
- first: false,
596
- response: true,
597
582
  ...(0, getConfig_1.default)("db"),
598
583
  };
599
584
  Object.entries(config).forEach(([key, value]) => {
@@ -0,0 +1,2 @@
1
+ import document from "./document";
2
+ export default document;
@@ -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;
@@ -1,53 +1,3 @@
1
- import auth from "./auth/auth";
2
- import db from "./db/db";
3
- import uploader from "./uploader/uploader";
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,12 @@ 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.document = exports.utils = exports.modules = exports.models = exports.validator = exports.uploader = exports.db = exports.auth = void 0;
7
- const auth_1 = __importDefault(require("./auth/auth"));
8
- exports.auth = auth_1.default;
9
- const db_1 = __importDefault(require("./db/db"));
10
- exports.db = db_1.default;
11
- const uploader_1 = __importDefault(require("./uploader/uploader"));
12
- exports.uploader = uploader_1.default;
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;
13
+ module.exports = init_1.default;
14
+ module.exports.default = init_1.default;
@@ -0,0 +1,3 @@
1
+ import * as Types from "./types";
2
+ declare const auth: Types.Auth;
3
+ export default auth;
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;