@micro-cms/resource-module 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.
Files changed (2) hide show
  1. package/README.md +43 -0
  2. package/package.json +11 -2
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @micro-cms/resource-module
2
+
3
+ A core module that provides framework-agnostic CRUD (Create, Read, Update, Delete) business logic and API route definitions. It acts as the bridge between your database adapter and your web server adapter.
4
+
5
+ ## Features
6
+
7
+ - **Standardized API Routes:** Provides pre-defined `RouteDefinition`s for resource listing, retrieval, creation, updates, and deletion.
8
+ - **Automatic Introspection:** Exposes a `/schema` endpoint that queries the `database-adapter` to describe the data structure.
9
+ - **Framework Agnostic:** Generates generic route handlers that can be mounted on Express, Hono, Fastify, or any other supported web framework.
10
+ - **Middleware Integration:** Uses abstract middleware keys (like `admin-auth`) that are resolved by the server adapter.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @micro-cms/resource-module
16
+ ```
17
+
18
+ ## Basic Usage
19
+
20
+ ```javascript
21
+ import { createApp } from '@micro-cms/core';
22
+ import { createResourceModule } from '@micro-cms/resource-module';
23
+ import postgresModule from '@micro-cms/postgres';
24
+
25
+ const app = createApp();
26
+
27
+ // Resource module REQUIRES a database-adapter
28
+ app.use(postgresModule);
29
+ app.use(createResourceModule());
30
+
31
+ await app.start();
32
+ ```
33
+
34
+ ## Routes Provided
35
+
36
+ | Method | Path | Description |
37
+ | :--- | :--- | :--- |
38
+ | `GET` | `/schema` | Returns the data schema for all entities. |
39
+ | `GET` | `/resources/:name` | Lists records for a specific resource (supports paging/sorting). |
40
+ | `GET` | `/resources/:name/:id` | Returns a single record by ID. |
41
+ | `POST` | `/resources/:name` | Creates a new record. |
42
+ | `PATCH` | `/resources/:name/:id` | Updates an existing record. |
43
+ | `DELETE` | `/resources/:name/:id` | Deletes a record. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-cms/resource-module",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Standardized CRUD and Schema routes for Micro-CMS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,5 +14,14 @@
14
14
  "devDependencies": {
15
15
  "typescript": "^5.3.3",
16
16
  "tsup": "^8.0.2"
17
- }
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/teamoremi/micro-cms.git",
21
+ "directory": "packages/resource-module"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/teamoremi/micro-cms/issues"
25
+ },
26
+ "homepage": "https://github.com/teamoremi/micro-cms/tree/master/packages/resource-module#readme"
18
27
  }