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/README.md
CHANGED
|
@@ -1,280 +1,171 @@
|
|
|
1
|
-
|
|
1
|
+
**Overview**
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- **Project**: `speedly` — a lightweight express utility framework that bundles auth middlewares, database model handlers, file uploader helpers, request validators, API documentation loader and small utilities to speed up building REST APIs.
|
|
4
|
+
- **Entry point exports**: `auth`, `db`, `uploader`, `validator`, `models`, `modules`, `utils`, `document` (see below for details and examples).
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Quick Start**
|
|
6
7
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- 📤 **File Upload Handler** - Multer-based file upload with automatic directory management
|
|
10
|
-
- ✅ **Request Validation** - Yup-based schema validation for requests
|
|
11
|
-
- 🌐 **Translation Service** - Multi-provider translation with caching support
|
|
12
|
-
- 📦 **Dual Module Support** - Both CommonJS and ES Module exports
|
|
8
|
+
- **Install**: add the project to your workspace or import the package in your service.
|
|
9
|
+
- **Basic server skeleton**:
|
|
13
10
|
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install speedly
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { auth, db, uploader, validator } from 'speedly';
|
|
24
|
-
|
|
25
|
-
// Initialize your Express app with Speedly modules
|
|
26
11
|
```
|
|
12
|
+
import express from 'express'
|
|
13
|
+
import { auth, db, uploader, validator, models, modules, utils, document } from './src'
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### 🔐 Authentication (`auth`)
|
|
15
|
+
const app = express();
|
|
16
|
+
app.use(express.json());
|
|
31
17
|
|
|
32
|
-
|
|
18
|
+
// Mount example module router
|
|
19
|
+
app.use('/api/translation', modules.translation);
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
// Swagger docs (served at /docs)
|
|
22
|
+
document(app, require('path').join(process.cwd(), 'src/modules'));
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
const authConfig = {
|
|
39
|
-
admin: {
|
|
40
|
-
role: 'ADMIN',
|
|
41
|
-
model: '../models/admin'
|
|
42
|
-
},
|
|
43
|
-
jwtSecretEnv: 'JWT_KEY',
|
|
44
|
-
customValidator: (req, key) => {
|
|
45
|
-
// Custom validation logic
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const authMiddleware = auth(authConfig);
|
|
51
|
-
|
|
52
|
-
// Use in Express routes
|
|
53
|
-
app.use('/admin', authMiddleware.useAuth);
|
|
24
|
+
app.listen(3000);
|
|
54
25
|
```
|
|
55
26
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
27
|
+
**Exports Reference**
|
|
28
|
+
|
|
29
|
+
**`auth`**
|
|
30
|
+
|
|
31
|
+
- **Type**: default export (object)
|
|
32
|
+
- **Purpose**: Provides simple express middlewares for access control. Each function returns an Express middleware that inspects the request using a configurable `customValidator` (from `getConfig('auth')`) and either allows, forbids or rejects the request.
|
|
33
|
+
- **API**:
|
|
34
|
+
- `auth.user()` → middleware that enforces a `user` access type.
|
|
35
|
+
- `auth.admin(config?)` → middleware for admin access. Optionally pass `{ permission }` to require a specific admin permission (the middleware names themselves include the permission, e.g. `auth:admin:PERM`).
|
|
36
|
+
- `auth.any()` → middleware that accepts any authenticated-type logic configured by the `customValidator`.
|
|
37
|
+
- **Notes**: `auth` reads default options from `getConfig('auth')`. The `customValidator` should return truthy to allow or falsy to forbid; `null` is treated as unauthorized.
|
|
38
|
+
|
|
39
|
+
**`db`**
|
|
40
|
+
|
|
41
|
+
- **Type**: default export (factory function)
|
|
42
|
+
- **Purpose**: Creates Express middlewares that operate on a Mongoose model (or other model loaded from the `models` path). Designed to simplify CRUD endpoints by composing handler builders like `.find()`, `.create()`, `.findByIdAndUpdate()`, etc.
|
|
43
|
+
- **How to use**: call `db(collectionName, config?)` to get a model handler factory, then chain action methods and use the returned function as an Express middleware.
|
|
44
|
+
- **Common methods returned by `db('collection')`**:
|
|
45
|
+
- `.find(match = {})`
|
|
46
|
+
- `.create(body = {})`
|
|
47
|
+
- `.updateOne(match, body)`
|
|
48
|
+
- `.updateMany(match, body)`
|
|
49
|
+
- `.deleteOne(match)`
|
|
50
|
+
- `.deleteMany(match)`
|
|
51
|
+
- `.findOne(match)`
|
|
52
|
+
- `.findOneAndUpdate(match, body)`
|
|
53
|
+
- `.aggregate(pipeline)`
|
|
54
|
+
- `.findById(id)`
|
|
55
|
+
- `.findByIdAndUpdate(id, body)`
|
|
56
|
+
- `.findByIdAndDelete(id)`
|
|
57
|
+
- **Query behavior**: The produced middleware reads query params like `search`, `filters`, `sort`, `page`, `limit`, and `select` to modify results. Pagination behaviour can be controlled via `getConfig('db')` (e.g., `pagination.quantity`, `pagination.detailed`).
|
|
58
|
+
- **Config**: second argument allows overriding `{ path, type: 'internal'|'external', message }`. When `type` is `internal` the loader resolves models relative to the library; when `external` it resolves from the host app and `configs.path`.
|
|
59
|
+
- **Example**:
|
|
73
60
|
|
|
74
|
-
// Use database operations
|
|
75
|
-
// Supports complex queries, aggregation pipelines, and automatic pagination
|
|
76
61
|
```
|
|
62
|
+
// GET /api/translation -> finds translations
|
|
63
|
+
app.get('/api/translation', db('translation', { type: 'internal' }).find());
|
|
77
64
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Multer-based file upload system with automatic directory creation and validation.
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
import { uploader } from 'speedly';
|
|
84
|
-
|
|
85
|
-
// Configure uploader
|
|
86
|
-
const uploadConfig = {
|
|
87
|
-
saveInDb: false,
|
|
88
|
-
prefix: "img_",
|
|
89
|
-
limit: 5,
|
|
90
|
-
format: /png|jpg|webp|jpeg/i
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const upload = uploader("/uploads/images", uploadConfig);
|
|
94
|
-
|
|
95
|
-
// Use in Express routes
|
|
96
|
-
app.post('/upload', upload.single('file'), (req, res) => {
|
|
97
|
-
// File uploaded successfully
|
|
98
|
-
res.json({ mediaId: req.mediaId });
|
|
99
|
-
});
|
|
65
|
+
// POST /api/translation -> create translation documents
|
|
66
|
+
app.post('/api/translation', db('translation', { type: 'internal' }).create());
|
|
100
67
|
```
|
|
101
68
|
|
|
102
|
-
|
|
69
|
+
**`uploader`**
|
|
70
|
+
|
|
71
|
+
- **Type**: default export (factory)
|
|
72
|
+
- **Purpose**: Provides file uploading middlewares built on `multer` and convenience helpers that optionally save media metadata to a `media` collection.
|
|
73
|
+
- **Signature**: `uploader(destination = '/image', config?)` returns an object with methods `{ single, array, fields, any, none }` which are wrappers around multer handlers.
|
|
74
|
+
- **Config options** (defaults obtained from `getConfig('uploader')`):
|
|
75
|
+
- `saveInDb` (boolean) — whether to persist metadata in a `media` collection
|
|
76
|
+
- `prefix` (string) — prefix for saved filenames
|
|
77
|
+
- `limit` (number) — max upload size in MB
|
|
78
|
+
- `format` (RegExp) — allowed file extensions
|
|
79
|
+
- `path` (string) — base path to save files (default `../../../public` in library defaults)
|
|
80
|
+
- **Returned helpers**:
|
|
81
|
+
- `single(fieldName)` — middleware saving a single file and setting the file URL into `req.body[fieldName]`. If `saveInDb` is true it will store a doc in `media` and set `req.mediaId`.
|
|
82
|
+
- `array(fieldName, maxCount)` — accept multiple files and set an array of URLs into `req.body[fieldName]`.
|
|
83
|
+
- `fields(fieldsArray)` — accept mixed fields (multer-style field definitions).
|
|
84
|
+
- `any()` and `none()` — passthrough multer helpers.
|
|
85
|
+
- **Example**:
|
|
103
86
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
import { validator } from 'speedly';
|
|
108
|
-
import * as yup from 'yup';
|
|
109
|
-
|
|
110
|
-
// Define validation schema
|
|
111
|
-
const userSchema = {
|
|
112
|
-
body: yup.object({
|
|
113
|
-
name: yup.string().required(),
|
|
114
|
-
email: yup.string().email().required(),
|
|
115
|
-
age: yup.number().min(18)
|
|
116
|
-
}),
|
|
117
|
-
params: yup.object({
|
|
118
|
-
id: yup.string().required()
|
|
119
|
-
}),
|
|
120
|
-
query: yup.object({
|
|
121
|
-
page: yup.number().default(1)
|
|
122
|
-
})
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Use validation middleware
|
|
126
|
-
app.post('/users/:id', validator(userSchema), (req, res) => {
|
|
127
|
-
// req.body, req.params, req.query are now validated and typed
|
|
87
|
+
```
|
|
88
|
+
app.post('/upload', uploader('/images').single('photo'), (req,res) => {
|
|
89
|
+
res.json({ url: req.body.photo });
|
|
128
90
|
});
|
|
129
91
|
```
|
|
130
92
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Speedly uses a configuration system that allows you to customize each module. Create configuration files or use environment variables:
|
|
93
|
+
**`validator`**
|
|
134
94
|
|
|
135
|
-
|
|
95
|
+
- **Type**: default export (generic factory)
|
|
96
|
+
- **Purpose**: A small wrapper around `yup` to validate `req.body`, `req.params`, and `req.query`. On failure it forwards an error object to `next()` with `status: 405` and a message.
|
|
97
|
+
- **Signature**: `validator({ body?: yup.Schema, params?: yup.Schema, query?: yup.Schema })` returns an Express `RequestHandler`.
|
|
98
|
+
- **Behavior**: strips unknown fields, assigns validated values back to `req.body`, `req.params`, and `req.query`. The created middleware is annotated with `__validationSchema` (used by automatic documentation generator).
|
|
99
|
+
- **Example**:
|
|
136
100
|
|
|
137
|
-
```bash
|
|
138
|
-
# Database
|
|
139
|
-
DB_URL=mongodb://localhost:27017/myapp
|
|
140
|
-
|
|
141
|
-
# JWT Secret
|
|
142
|
-
JWT_KEY=your-secret-key
|
|
143
|
-
|
|
144
|
-
# Translation API (optional)
|
|
145
|
-
ONE_API_TOKEN=your-translation-api-token
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Configuration Files
|
|
149
|
-
|
|
150
|
-
Create module-specific configuration by using the `getConfig` utility:
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
// Example configuration structure
|
|
154
|
-
const config = {
|
|
155
|
-
auth: {
|
|
156
|
-
jwtSecretEnv: 'JWT_KEY',
|
|
157
|
-
admin: { role: 'ADMIN' }
|
|
158
|
-
},
|
|
159
|
-
db: {
|
|
160
|
-
dbType: 'mongodb',
|
|
161
|
-
pagination: { quantity: 20 }
|
|
162
|
-
},
|
|
163
|
-
uploader: {
|
|
164
|
-
limit: 10,
|
|
165
|
-
format: /png|jpg|jpeg|webp|gif/i
|
|
166
|
-
},
|
|
167
|
-
translate: {
|
|
168
|
-
one_api_token: process.env.ONE_API_TOKEN
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Advanced Usage
|
|
174
|
-
|
|
175
|
-
### Database Queries with Pipelines
|
|
176
|
-
|
|
177
|
-
```typescript
|
|
178
|
-
// Complex aggregation pipeline example
|
|
179
|
-
const queryState = {
|
|
180
|
-
action: 'aggregate',
|
|
181
|
-
match: { status: 'active' },
|
|
182
|
-
pipeline: [
|
|
183
|
-
{ $lookup: { from: 'users', localField: 'userId', foreignField: '_id', as: 'user' } },
|
|
184
|
-
{ $unwind: '$user' },
|
|
185
|
-
{ $sort: { createdAt: -1 } }
|
|
186
|
-
]
|
|
187
|
-
};
|
|
188
101
|
```
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
The translation module automatically caches translations and supports multiple providers:
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
import { translator } from 'speedly/dist/util/translator';
|
|
196
|
-
|
|
197
|
-
// Translate text with automatic caching
|
|
198
|
-
const translatedText = await translator("Hello World", "fa");
|
|
102
|
+
import * as yup from 'yup';
|
|
103
|
+
const schema = { body: yup.object({ text: yup.string().required() }) };
|
|
104
|
+
app.post('/translate', validator(schema), handler);
|
|
199
105
|
```
|
|
200
106
|
|
|
201
|
-
|
|
107
|
+
**`models`**
|
|
202
108
|
|
|
203
|
-
|
|
109
|
+
- **Type**: object containing Mongoose models
|
|
110
|
+
- **Currently included**:
|
|
111
|
+
- `translation` — Mongoose model with fields `{ text: String, lang: String, translatedText: String }` and timestamps.
|
|
112
|
+
- **Purpose**: Direct access to low-level models for custom operations (e.g., prefetch, caching or complex queries).
|
|
204
113
|
|
|
205
|
-
|
|
206
|
-
- `useAuth` - Express middleware for route protection
|
|
114
|
+
**`modules`**
|
|
207
115
|
|
|
208
|
-
|
|
116
|
+
- **Type**: object of `express.Router` instances keyed by module name
|
|
117
|
+
- **Included**:
|
|
118
|
+
- `translation` — router defined in `src/modules/translation/translation.routes.ts` with routes:
|
|
119
|
+
- `GET /` → `db('translation', {type:'internal'}).find()`
|
|
120
|
+
- `POST /` → guarded by a simple body `auth` check inside the route and then `create()`
|
|
121
|
+
- `PUT /:id` → `auth.admin()` + `validator(...)` + `findByIdAndUpdate()`
|
|
122
|
+
- **Mounting**: `app.use('/api/translation', modules.translation)`
|
|
209
123
|
|
|
210
|
-
|
|
211
|
-
- Built-in pagination and query building
|
|
212
|
-
- Aggregation pipeline support
|
|
124
|
+
**`utils`**
|
|
213
125
|
|
|
214
|
-
|
|
126
|
+
- **Type**: object of helper utilities
|
|
127
|
+
- **Included**:
|
|
128
|
+
- `translator` — a small translation helper that attempts multiple external translation providers and caches successful translations to the `translation` model. Signature: `translator(text = 'unspecified text', lang = 'fa') => Promise<string>`.
|
|
129
|
+
- **Behavior**: Normalizes text, looks up local cache (`translation` model), attempts external services (a worker proxy and optionally `one-api`), writes the result to DB, and returns the translated text. Falls back to the formatted original text on failure.
|
|
215
130
|
|
|
216
|
-
|
|
217
|
-
- Automatic directory creation
|
|
218
|
-
- File format validation
|
|
131
|
+
**`document`**
|
|
219
132
|
|
|
220
|
-
|
|
133
|
+
- **Type**: default export (function)
|
|
134
|
+
- **Purpose**: Scans `src/modules` routers and mounts a Swagger UI at `/docs` with automatically generated OpenAPI paths and basic security scheme.
|
|
135
|
+
- **Signature**: `document(app: Express, baseDir?: string)` — `baseDir` defaults to `path.join(process.cwd(), 'src/module')` in the loader. Use a correct path to your modules folder (e.g., `path.join(process.cwd(), 'src/modules')`).
|
|
136
|
+
- **What it detects**: routes, http methods, `yup` validation schemas (to document request bodies), and auth middlewares (to add security hints and descriptions).
|
|
221
137
|
|
|
222
|
-
|
|
223
|
-
- Type-safe validation with Yup
|
|
224
|
-
- Supports body, params, and query validation
|
|
138
|
+
**Configuration & Environment**
|
|
225
139
|
|
|
226
|
-
|
|
140
|
+
- Use `getConfig(key)` (internal) to supply runtime options for `auth`, `db`, `uploader`, and `translate` providers. Typical environment keys used by the modules:
|
|
141
|
+
- `JWT_KEY` (used by auth-related configs)
|
|
142
|
+
- `DB_URL` (database connection string if using external db config)
|
|
143
|
+
- `one_api_token` (optional token for the alternate translator provider)
|
|
227
144
|
|
|
228
|
-
|
|
229
|
-
- **Mongoose** - MongoDB object modeling
|
|
230
|
-
- **Multer** - File upload handling
|
|
231
|
-
- **Yup** - Schema validation
|
|
232
|
-
- **jsonwebtoken** - JWT authentication
|
|
233
|
-
- **axios** - HTTP client
|
|
234
|
-
- **translate** - Translation services
|
|
145
|
+
**Examples**
|
|
235
146
|
|
|
236
|
-
|
|
147
|
+
- Mounting everything in a small app:
|
|
237
148
|
|
|
238
|
-
### Building the Project
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
# Build both CommonJS and ES modules
|
|
242
|
-
npm run build
|
|
243
|
-
|
|
244
|
-
# Build CommonJS only
|
|
245
|
-
npm run build:cjs
|
|
246
|
-
|
|
247
|
-
# Build ES modules only
|
|
248
|
-
npm run build:esm
|
|
249
|
-
|
|
250
|
-
# Development mode
|
|
251
|
-
npm run dev
|
|
252
149
|
```
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
150
|
+
import express from 'express';
|
|
151
|
+
import { modules, document } from './src';
|
|
152
|
+
import path from 'path';
|
|
153
|
+
|
|
154
|
+
const app = express();
|
|
155
|
+
app.use(express.json());
|
|
156
|
+
app.use('/api/translation', modules.translation);
|
|
157
|
+
document(app, path.join(process.cwd(), 'src/modules'));
|
|
158
|
+
app.listen(3000);
|
|
256
159
|
```
|
|
257
|
-
src/
|
|
258
|
-
├── auth/ # Authentication module
|
|
259
|
-
├── db/ # Database operations
|
|
260
|
-
├── uploader/ # File upload handling
|
|
261
|
-
├── validator/ # Request validation
|
|
262
|
-
├── util/ # Utility functions
|
|
263
|
-
└── model/ # Data models
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## TypeScript Support
|
|
267
|
-
|
|
268
|
-
Speedly is written in TypeScript and provides full type definitions. The package exports both CommonJS and ES modules for maximum compatibility.
|
|
269
|
-
|
|
270
|
-
## License
|
|
271
|
-
|
|
272
|
-
MIT © MAHSERIN
|
|
273
160
|
|
|
274
|
-
|
|
161
|
+
**Developer Notes**
|
|
275
162
|
|
|
276
|
-
|
|
163
|
+
- `db` middleware attaches pagination, `search` and `filters` behavior using `req.query`. Use `type: 'internal'` when you want the model path resolved inside the package, or `external` to resolve from the consumer app.
|
|
164
|
+
- `validator` attaches `__validationSchema` to middlewares which `document` uses to generate OpenAPI schemas.
|
|
165
|
+
- `uploader` writes files to disk under the configured `path` and returns public URLs prefixed with `/static`.
|
|
277
166
|
|
|
278
|
-
|
|
167
|
+
If you'd like, I can also:
|
|
279
168
|
|
|
280
|
-
|
|
169
|
+
- add usage examples/tests around each exported function
|
|
170
|
+
- add API reference tables per-method for `db` handlers
|
|
171
|
+
- generate a small example express app under `examples/` using these exports
|
package/dist/cjs/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;
|