From eaba41ab32819b8b416b61c63f89ebb0f7611f55 Mon Sep 17 00:00:00 2001 From: Many0nne Date: Tue, 14 Apr 2026 14:51:33 +0200 Subject: [PATCH 1/3] feat: add examples front page --- README.md | 30 + demo/index.html | 1486 +++++++++++++++++++++++++++++++++++++++++++ demo/types/index.ts | 31 + package-lock.json | 6 + tsconfig.json | 2 - 5 files changed, 1553 insertions(+), 2 deletions(-) create mode 100644 demo/index.html create mode 100644 demo/types/index.ts diff --git a/README.md b/README.md index 1f506d1..dce4f0a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,36 @@ Write a TypeScript interface, get a fully working REST API with realistic mock d --- +## πŸ–₯️ Try the Demo + +The repo includes a ready-to-use demo with sample types and a frontend UI. + +**1 β€” Install dependencies** (first time only) + +```bash +npm install +``` + +**2 β€” Start the server** + +```bash +npm start +``` + +This uses `.mock-config.json` at the root, which points to `demo/types/` on port `3000`. + +**3 β€” Open the frontend** + +Open `demo/index.html` directly in your browser (no server needed for the UI itself): + +``` +demo/index.html ← open this file in your browser +``` + +Then click **Connect** β€” the UI will automatically discover the available types (`User`, `Product`, `Order`) and let you browse, filter, create, edit, and delete mock data. + +--- + ## ⚑ Quick Start ### 1 β€” Install diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..50d2021 --- /dev/null +++ b/demo/index.html @@ -0,0 +1,1486 @@ + + + + + + ts-mock-proxy β€” Demo + + + + + + + + + + + +
+
+ Filter: + + + + + + Sort: + + + + + +
+ +
+ + + +
+ + +
+ + + +

Connect to the server to get started

+ Enter a server URL above and click Connect +
+
+ + +
+ + + + + +
+
+ Item Detail + +
+

+
+ + + + + + + diff --git a/demo/types/index.ts b/demo/types/index.ts new file mode 100644 index 0000000..b07432a --- /dev/null +++ b/demo/types/index.ts @@ -0,0 +1,31 @@ +// @endpoint +export interface User { + id: number; + firstName: string; + lastName: string; + email: string; + /** @enum admin,user,moderator */ + role: string; + age: number; +} + +// @endpoint +export interface Product { + id: string; + name: string; + /** @min 0 */ + price: number; + /** @enum electronics,clothing,food */ + category: string; + inStock: boolean; +} + +// @endpoint +export interface Order { + id: string; + userId: number; + /** @min 0 */ + total: number; + /** @enum pending,processing,shipped,delivered,cancelled */ + status: string; +} diff --git a/package-lock.json b/package-lock.json index 3ed3089..634ca62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,6 +75,7 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -1813,6 +1814,7 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.13.tgz", "integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==", "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2297,6 +2299,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -3240,6 +3243,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -4189,6 +4193,7 @@ "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6647,6 +6652,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/tsconfig.json b/tsconfig.json index 4776f73..f124713 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,6 @@ /* Modules */ "module": "commonjs", "rootDir": "./src", - "moduleResolution": "node", - "baseUrl": "./src", "resolveJsonModule": true, /* Emit */ From 15e1dbfb5bfa191732ca859d34f1f7b470c28ed9 Mon Sep 17 00:00:00 2001 From: Many0nne Date: Sat, 25 Apr 2026 04:10:23 +0200 Subject: [PATCH 2/3] fix: sonarqube errors --- demo/index.html | 66 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/demo/index.html b/demo/index.html index 50d2021..d08e6d8 100644 --- a/demo/index.html +++ b/demo/index.html @@ -766,7 +766,12 @@
- + + + + + +
FieldActions