Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brokeboiflex/strapi-middleware-resolvenestedobjects
Painless POST and PUT of nested objects
https://github.com/brokeboiflex/strapi-middleware-resolvenestedobjects
Last synced: about 2 months ago
JSON representation
Painless POST and PUT of nested objects
- Host: GitHub
- URL: https://github.com/brokeboiflex/strapi-middleware-resolvenestedobjects
- Owner: brokeboiflex
- Created: 2023-08-25T16:26:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-26T20:43:30.000Z (over 1 year ago)
- Last Synced: 2023-08-26T21:39:10.361Z (over 1 year ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# resolveNestedObjects Middleware
The `resolveNestedObjects` middleware is designed to handle resolving and creating nested objects in Strapi. This middleware is particularly useful when dealing with complex data structures and relationships in your API endpoints.
## Assumptions / Prerequisites
CRUD operations in Strapi require strings formated like that: `api::article.article` notice that `article` is **singular**.
This middleware is based on object keys of the parent object, so it requires them to reflect type names of the nested objects.For example if you have a parent object `cart` and nested field `content` which is related to object `product` this middleware will not work unless you rename `content` to `product`.
## Installation
To use the `resolveNestedObjects` middleware, follow these steps:
1. Copy the content of the provided middleware code.
2. Create a new file named `resolveNestedObjects.js` in your Strapi project's `src/middlewares` directory.
3. Paste the copied code into the `resolveNestedObjects.js` file.
4. In your Strapi project, navigate to the `config/middleware.ts` file.5. Register the middleware by adding `global::resolveNestedObjects` to the end of the list:
```javascript
module.exports = [
// Other middleware configurations...
"global::resolveNestedObjects"
];