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 +3 -49
- package/README.zh-CN.md +7 -0
- package/dist/index.d.cts +2 -3
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/vite.cjs +552 -158
- package/dist/vite.d.cts +4 -4
- package/dist/vite.d.mts +4 -4
- package/dist/vite.d.ts +4 -4
- package/dist/vite.mjs +554 -160
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
# mokup
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [Chinese](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
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.
|
package/README.zh-CN.md
ADDED
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 };
|