@micro-cms/node-adapter 1.0.20 → 1.0.22
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 +46 -0
- package/package.json +12 -3
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @micro-cms/node-adapter
|
|
2
|
+
|
|
3
|
+
A "translator" module that allows the Micro-CMS runtime to communicate with an existing REST API. This is the primary module used when you have a backend with CRUD endpoints and want to instantly generate a full-featured admin panel for it.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **API Mapping:** Translates `DataProvider` calls into standard RESTful requests (`GET`, `POST`, `PATCH`, `DELETE`).
|
|
8
|
+
- **Schema Introspection:** Fetches data models from a remote `/admin/schema` endpoint to drive the Admin UI.
|
|
9
|
+
- **Authentication:** Supports Bearer Token authentication via configuration or local storage.
|
|
10
|
+
- **Pagination & Sorting:** Passes through UI state to the API for efficient server-side data handling.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @micro-cms/node-adapter
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import { createApp } from '@micro-cms/core';
|
|
22
|
+
import nodeAdapter from '@micro-cms/node-adapter';
|
|
23
|
+
import adminUi from '@micro-cms/admin-ui';
|
|
24
|
+
|
|
25
|
+
const app = createApp();
|
|
26
|
+
|
|
27
|
+
// Configure the adapter to point to your API
|
|
28
|
+
app.use(nodeAdapter, {
|
|
29
|
+
apiUrl: 'https://my-api.com',
|
|
30
|
+
token: 'your-secret-token'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
app.use(adminUi);
|
|
34
|
+
|
|
35
|
+
await app.start();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API Contract
|
|
39
|
+
|
|
40
|
+
For this adapter to work, your existing API **must** expose the following endpoints:
|
|
41
|
+
|
|
42
|
+
1. **GET /admin/schema:** Must return a JSON object defining your resources and their fields.
|
|
43
|
+
2. **GET /admin/resources/:name:** Must return a paginated list of records.
|
|
44
|
+
3. **POST /admin/resources/:name:** Must handle record creation.
|
|
45
|
+
4. **PATCH /admin/resources/:name/:id:** Must handle updates.
|
|
46
|
+
5. **DELETE /admin/resources/:name/:id:** Must handle deletion.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-cms/node-adapter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@micro-cms/types": "^1.0.
|
|
19
|
+
"@micro-cms/types": "^1.0.22"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
@@ -25,5 +25,14 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "^5.0.0",
|
|
27
27
|
"tsup": "^8.0.2"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/teamoremi/micro-cms.git",
|
|
32
|
+
"directory": "packages/node-adapter"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/teamoremi/micro-cms/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/teamoremi/micro-cms/tree/master/packages/node-adapter#readme"
|
|
29
38
|
}
|