@macss/modular-api 0.4.0 → 0.4.3
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 +6 -6
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# modular-api
|
|
2
2
|
|
|
3
3
|
Use-case centric toolkit for building modular APIs with Express.
|
|
4
4
|
Define `UseCase` classes (input → validate → execute → output), connect them to HTTP routes, and get automatic Swagger/OpenAPI documentation.
|
|
5
5
|
|
|
6
|
-
> Also available in **Dart**: [modular_api](https://pub.dev/packages/modular_api)
|
|
6
|
+
> Also available in **Dart**: [modular_api](https://pub.dev/packages/modular_api) · **Python**: [macss-modular-api](https://pypi.org/project/macss-modular-api/)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
## Quick start
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
|
-
import { ModularApi, ModuleBuilder } from '
|
|
13
|
+
import { ModularApi, ModuleBuilder } from '@macss/modular-api';
|
|
14
14
|
|
|
15
15
|
// ─── Module builder (separate file in real projects) ──────────
|
|
16
16
|
function buildGreetingsModule(m: ModuleBuilder): void {
|
|
@@ -37,7 +37,7 @@ curl -X POST http://localhost:8080/api/greetings/hello \
|
|
|
37
37
|
|
|
38
38
|
**Docs** → `http://localhost:8080/docs`
|
|
39
39
|
**Health** → `http://localhost:8080/health`
|
|
40
|
-
**OpenAPI JSON** → `http://localhost:8080/openapi.json` _(also /openapi.yaml)_
|
|
40
|
+
**OpenAPI JSON** → `http://localhost:8080/openapi.json` _(also /openapi.yaml)_
|
|
41
41
|
**Metrics** → `http://localhost:8080/metrics` _(opt-in)_
|
|
42
42
|
|
|
43
43
|
See `example/example.ts` for the full implementation including Input, Output, UseCase with `validate()`, and the builder.
|
|
@@ -47,7 +47,7 @@ See `example/example.ts` for the full implementation including Input, Output, Us
|
|
|
47
47
|
## Features
|
|
48
48
|
|
|
49
49
|
- `UseCase<I, O>` — pure business logic, no HTTP concerns
|
|
50
|
-
- `Input` / `Output` — DTOs with
|
|
50
|
+
- `Input` / `Output` — DTOs with automatic OpenAPI schema generation via `@Field` decorators
|
|
51
51
|
- `Output.statusCode` — custom HTTP status codes per response
|
|
52
52
|
- `UseCaseException` — structured error handling (status code, message, error code, details)
|
|
53
53
|
- `ModularApi` + `ModuleBuilder` — module registration and routing
|
|
@@ -100,7 +100,7 @@ No HTTP server or real infrastructure needed.
|
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
102
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
103
|
-
import { UseCaseException } from '
|
|
103
|
+
import { UseCaseException } from '@macss/modular-api';
|
|
104
104
|
|
|
105
105
|
// ─── Fake ────────────────────────────────────────────────────
|
|
106
106
|
class FakeGreetingRepository implements GreetingRepository {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macss/modular-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Use-case-centric toolkit for building modular APIs with Express. Define UseCase classes (input → validate → execute → output), connect them to HTTP routes, and expose Swagger/OpenAPI documentation automatically.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,16 +25,22 @@
|
|
|
25
25
|
],
|
|
26
26
|
"author": "ccisne.dev",
|
|
27
27
|
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/macss-dev/modular_api.git",
|
|
31
|
+
"directory": "ts"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/macss-dev/modular_api/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/macss-dev/modular_api/tree/main/ts#readme",
|
|
28
37
|
"dependencies": {
|
|
29
|
-
"express": "^4.22.1"
|
|
30
|
-
"prom-client": "^15.1.3",
|
|
31
|
-
"swagger-ui-express": "^5.0.1"
|
|
38
|
+
"express": "^4.22.1"
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
34
41
|
"@types/express": "^5.0.6",
|
|
35
42
|
"@types/node": "^22.19.11",
|
|
36
43
|
"@types/supertest": "^6.0.3",
|
|
37
|
-
"@types/swagger-ui-express": "^4.1.8",
|
|
38
44
|
"prettier": "^3.8.1",
|
|
39
45
|
"supertest": "^7.2.2",
|
|
40
46
|
"ts-node": "^10.9.2",
|