mokup 0.0.0 → 0.0.1

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 CHANGED
@@ -1,53 +1,7 @@
1
1
  # mokup
2
2
 
3
- Mock utilities and a Vite plugin for local API mocking.
3
+ English | [Chinese](./README.zh-CN.md)
4
4
 
5
- ## Vite plugin
5
+ ## Overview
6
6
 
7
- ```ts
8
- import mokup from 'mokup/vite'
9
- import { defineConfig } from 'vite'
10
-
11
- export default defineConfig({
12
- plugins: [
13
- mokup({
14
- dir: 'mock',
15
- prefix: '',
16
- }),
17
- ],
18
- })
19
- ```
20
-
21
- ## Mock files
22
-
23
- Filenames must include an HTTP method suffix (`.get`, `.post`, etc.).
24
-
25
- `mock/user.get.json`
26
-
27
- ```json
28
- {
29
- "id": 1,
30
- "name": "Ada"
31
- }
32
- ```
33
-
34
- `mock/auth.post.ts`
35
-
36
- ```ts
37
- export default {
38
- response: ({ body }) => {
39
- if (body && typeof body === 'object' && 'username' in body) {
40
- return { ok: true }
41
- }
42
- return { ok: false }
43
- },
44
- }
45
- ```
46
-
47
- `mock/users/[id].get.ts`
48
-
49
- ```ts
50
- export default {
51
- response: ({ params }) => ({ ok: true, id: params?.id }),
52
- }
53
- ```
7
+ Mokup provides file-based mock routing, a Vite plugin, and a playground UI to help you build and debug API mocks locally. For detailed usage, see https://mokup.icebreaker.top.
@@ -0,0 +1,7 @@
1
+ # mokup
2
+
3
+ [English](./README.md) | 中文
4
+
5
+ ## 概览
6
+
7
+ Mokup 提供基于文件的 mock 路由、Vite 插件和 Playground UI,帮助你在本地构建与调试接口。完整文档见 https://mokup.icebreaker.top。
package/dist/index.d.cts CHANGED
@@ -17,8 +17,6 @@ interface MockContext {
17
17
  type MockResponseHandler = (req: MockRequest, res: ServerResponse, ctx: MockContext) => unknown | Promise<unknown>;
18
18
  type MockResponse = unknown | MockResponseHandler;
19
19
  interface MockRule {
20
- url?: string;
21
- method?: string;
22
20
  response: MockResponse;
23
21
  status?: number;
24
22
  headers?: Record<string, string>;
@@ -36,5 +34,6 @@ interface MokupViteOptions {
36
34
  enabled?: boolean;
37
35
  };
38
36
  }
37
+ type MokupViteOptionsInput = MokupViteOptions | MokupViteOptions[];
39
38
 
40
- export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions };
39
+ export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions, MokupViteOptionsInput };
package/dist/index.d.mts CHANGED
@@ -17,8 +17,6 @@ interface MockContext {
17
17
  type MockResponseHandler = (req: MockRequest, res: ServerResponse, ctx: MockContext) => unknown | Promise<unknown>;
18
18
  type MockResponse = unknown | MockResponseHandler;
19
19
  interface MockRule {
20
- url?: string;
21
- method?: string;
22
20
  response: MockResponse;
23
21
  status?: number;
24
22
  headers?: Record<string, string>;
@@ -36,5 +34,6 @@ interface MokupViteOptions {
36
34
  enabled?: boolean;
37
35
  };
38
36
  }
37
+ type MokupViteOptionsInput = MokupViteOptions | MokupViteOptions[];
39
38
 
40
- export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions };
39
+ export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions, MokupViteOptionsInput };
package/dist/index.d.ts CHANGED
@@ -17,8 +17,6 @@ interface MockContext {
17
17
  type MockResponseHandler = (req: MockRequest, res: ServerResponse, ctx: MockContext) => unknown | Promise<unknown>;
18
18
  type MockResponse = unknown | MockResponseHandler;
19
19
  interface MockRule {
20
- url?: string;
21
- method?: string;
22
20
  response: MockResponse;
23
21
  status?: number;
24
22
  headers?: Record<string, string>;
@@ -36,5 +34,6 @@ interface MokupViteOptions {
36
34
  enabled?: boolean;
37
35
  };
38
36
  }
37
+ type MokupViteOptionsInput = MokupViteOptions | MokupViteOptions[];
39
38
 
40
- export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions };
39
+ export type { HttpMethod, MockContext, MockRequest, MockResponse, MockResponseHandler, MockRule, MokupViteOptions, MokupViteOptionsInput };