@vhictor/amockgen 1.0.7

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 (3) hide show
  1. package/README.md +76 -0
  2. package/dist/index.js +92601 -0
  3. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # AmockGen
2
+
3
+ A high-performance, zero-config stateful API mocking CLI and server built for modern TypeScript monorepos.
4
+
5
+ amockgen parses OpenAPI (v3.x) specifications and instantly spins up a local HTTP mock server paired with interactive documentation, dynamic stateful data generation, request payload validation, and color-coded terminal telemetry.
6
+
7
+ ## Features
8
+
9
+ - Zero-Config Developer Workflow: Automatically detects openapi.json or openapi.yaml in your active working directory or bootstraps a ready-to-use template if none exists.
10
+
11
+ - Stateful In-Memory Store: Implements full CRUD persistence across resources **(GET, POST, PUT, PATCH, DELETE)** during the server lifecycle.
12
+
13
+ - Dynamic Data Engine: Generates realistic, schema-driven mock data powered by **@faker-js/faker** based on property types, formats, and key-naming heuristics.
14
+
15
+ - Schema Validation: Uses **Ajv and ajv-formats** to strictly validate incoming **POST**, **PUT**, and **PATCH** request payloads, returning standard **422 Unprocessable Entity** responses on schema mismatches.
16
+
17
+ - Interactive Documentation UI: Embeds Stoplight Elements locally at /docs for testing and exploring endpoints.
18
+
19
+ - Hot-Reloading: Monitors OpenAPI specification files for updates and automatically reloads server routes and schemas in real time.
20
+
21
+ - Visual Terminal Telemetry: Built-in **ANSI** escape sequences format request methods, HTTP status codes, and execution times (in ms) with distinct color highlights.
22
+
23
+ ## Install
24
+
25
+ `npx @vhictor/amockgen@latest`
26
+
27
+ ## Usage:
28
+
29
+ When you run `npx @vhictor/amockgen@latest`, amockgen:
30
+
31
+ - Resolves openapi.json / openapi.yaml in your current directory.
32
+
33
+ - Serves the interactive API documentation UI at http://localhost:8083/docs.
34
+
35
+ - Sets up mock HTTP endpoints under http://localhost:8083.
36
+
37
+ ## Example Log Output
38
+
39
+ Parsing OpenAPI spec: C:\Users\user\amockgen\openapi.json
40
+
41
+ ```
42
+ ┌─────────────────────────────────────────────────────────────┐
43
+ │ 🚀 API Mock Server & Documentation Running │
44
+ │ │
45
+ │ • Interactive Docs: http://localhost:8083/docs │
46
+ │ • Mock API Base: http://localhost:8083 │
47
+ │ • Spec File: openapi.json │
48
+ │ • Status: Active │
49
+ └─────────────────────────────────────────────────────────────┘
50
+
51
+ │ [16:02:12] PUT /todos/0c6dd1a2 - 404 Not Found (6ms)
52
+ │ [16:02:17] GET /todos - 200 OK (0ms)
53
+ │ [16:03:01] POST /todos - 422 Unprocessable Entity (55ms)
54
+ │ [16:03:29] POST /todos - 201 Created (3ms)
55
+
56
+ ```
57
+
58
+ ## Tech Stack
59
+
60
+ - Server Framework: Fastify
61
+
62
+ - OpenAPI Parser: @apidevtools/swagger-parser
63
+
64
+ - Validation Engine: Ajv + ajv-formats
65
+
66
+ - Data Mocking: @faker-js/faker
67
+
68
+ - CLI Engine: Commander
69
+
70
+ - File Watcher: Chokidar
71
+
72
+ - Monorepo Tooling: pnpm workspaces + Turborepo
73
+
74
+ ## License:
75
+
76
+ **MIT**