@aaroncadillac/crudify-mongo 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/crudify.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,13 +30,13 @@ An automatic CRUD generator for [fastify](https://fastify.dev) and MongoDB, usin
|
|
|
30
30
|
|
|
31
31
|
You can automatically enjoy the following CRUD operations:
|
|
32
32
|
|
|
33
|
-
| Route | Description | Additional built-in benefits |
|
|
34
|
-
|
|
35
|
-
| `GET /` | Get all documents | `Pagination` `Filtering` `Sorting` |
|
|
36
|
-
| `GET /:id` | Get a document by id | `Not-Found validation`|
|
|
37
|
-
| `POST /` | Create a document | `Schema validation`|
|
|
38
|
-
| `PUT /:id` | Update a document by id | `Not-Found validation` `Schema validation`|
|
|
39
|
-
| `DELETE /:id` | Delete a document by id | `Not-Found validation` |
|
|
33
|
+
| Route | Description | Additional built-in benefits |How to use|
|
|
34
|
+
|-------|-------------|----|---|
|
|
35
|
+
| `GET /` | Get all documents | `Pagination` `Filtering` `Sorting` |query parameters: `filters` and `options` for more details see [mongoose-paginate-v2 documentation](https://github.com/aravindnc/mongoose-paginate-v2#readme) |
|
|
36
|
+
| `GET /:id` | Get a document by id | `Not-Found validation`|Activated by default|
|
|
37
|
+
| `POST /` | Create a document | `Schema validation`|Activated by default|
|
|
38
|
+
| `PUT /:id` | Update a document by id | `Not-Found validation` `Schema validation`|Activated by default|
|
|
39
|
+
| `DELETE /:id` | Delete a document by id | `Not-Found validation` |Activated by default|
|
|
40
40
|
|
|
41
41
|
### Custom routes
|
|
42
42
|
|
|
@@ -58,7 +58,9 @@ const routes = ( fastify, opts, done ) => {
|
|
|
58
58
|
})
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### Swagger auto-documentation
|
|
61
|
+
### Swagger auto-documentation (WIP)
|
|
62
|
+
|
|
63
|
+
> If you need to integrate Swagger auto-documentation, is necessary to export and process mongoose model to define schemas into `openapi.json`, this module is under development.
|
|
62
64
|
|
|
63
65
|
You can add Swagger auto-documentation to your API, using the [`@fastify/swagger`](https://github.com/fastify/fastify-swagger) and [`@fastify/swagger-ui`](https://github.com/fastify/fastify-swagger-ui) plugins.
|
|
64
66
|
|
package/crudify.js
CHANGED
|
@@ -72,7 +72,7 @@ function addGetResponseArray(opts) {
|
|
|
72
72
|
filters: {
|
|
73
73
|
type: 'string'
|
|
74
74
|
},
|
|
75
|
-
|
|
75
|
+
options: {
|
|
76
76
|
type: 'string'
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -100,7 +100,7 @@ function Crudify (fastify, opts, next) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
const paginateOptions = JSON.parse(req.query.
|
|
103
|
+
const paginateOptions = JSON.parse(req.query.options ||= '{"pagination": false}')
|
|
104
104
|
return reply.type('application/json').code(200).send(await opts.Model.paginate(filterObject, paginateOptions))
|
|
105
105
|
} catch (err) {
|
|
106
106
|
return reply.type('application/json').code(500).send({ error: err.message || err })
|