You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This starts a mock server immediately without permanent installation. Perfect for quick tests and demos.
38
+
````
11
39
12
40
## Installation Options
13
41
@@ -16,23 +44,39 @@ Choose your preferred method below:
16
44
17
45
::: tabs
18
46
47
+
@tab "NPM"
48
+
49
+
If you prefer to install Mokapi globally as a Node.js package, install [go-mokapi](https://www.npmjs.com/package/go-mokapi)
50
+
using:
51
+
52
+
```bash
53
+
npm install -g go-mokapi
54
+
```
55
+
56
+
After installation, the mokapi command is available globally.
57
+
19
58
@tab "macOS"
20
59
21
60
### Homebrew
22
61
62
+
Install via Homebrew for easy updates and management:
63
+
23
64
```bash
24
65
brew tap marle3003/tap
25
66
brew install mokapi
26
67
```
27
68
28
69
### Direct Download
29
70
30
-
Download the latest macOS version from [GitHub](https://github.com/marle3003/mokapi/releases)
71
+
Download the latest macOS binary from [GitHub](https://github.com/marle3003/mokapi/releases). Extract
72
+
archive and move the binary to your PATH.
31
73
32
74
@tab "Windows"
33
75
34
76
### Chocolatey
35
77
78
+
Install via Chocolatey for easy updates:
79
+
36
80
```Powershell
37
81
choco install mokapi
38
82
```
@@ -43,6 +87,8 @@ Download the latest Windows version from [GitHub](https://github.com/marle3003/m
43
87
44
88
@tab "Linux"
45
89
90
+
Download the .deb package from the releases page and install:
91
+
46
92
### Direct Download
47
93
48
94
Download file appropriate for your Linux distribution and ARCH from the [release page](https://github.com/marle3003/mokapi/releases), then install with
To get started with Mokapi using Docker, visit [DockerHub](https://hub.docker.com/r/mokapi/mokapi/tags) for a list of available images.
61
-
You can also use a custom base Docker image as demonstrated in [these examples](/resources/examples/mokapi-with-custom-base-image.md).
106
+
Mokapi provides official Docker images on [Docker Hub](https://hub.docker.com/r/mokapi/mokapi):
62
107
63
108
```
64
109
docker pull mokapi/mokapi
65
110
```
66
111
67
-
@tab "NPM"
112
+
:::
68
113
69
-
If you prefer to install Mokapi as a Node.js package, install [go-mokapi](https://www.npmjs.com/package/go-mokapi)
70
-
using:
114
+
````box=info title="Verify Installation"
115
+
After installation, verify Mokapi is working:
71
116
72
-
```bash
73
-
npm install -g go-mokapi
117
+
```bash style=simple
118
+
mokapi --version
74
119
```
75
120
76
-
:::
121
+
````
77
122
78
-
### Mokapi Scripts Type Definitions
123
+
##TypeScript Support
79
124
80
-
Mokapi allows you to write **custom scripts** to handle API events or modify responses.
81
-
For full type safety and autocompletion in TypeScript, you can install the [`@types/mokapi`](https://www.npmjs.com/package/@types/mokapi`) package:
125
+
For full type safety and autocompletion when writing Mokapi scripts in TypeScript, install the type definitions:
82
126
83
127
```bash
84
128
npm install --save-dev @types/mokapi
85
129
```
86
130
87
-
## Next steps
131
+
This enables IntelliSense and type checking in your IDE when writing custom event handlers and scripts.
132
+
133
+
### Example TypeScript Script
134
+
135
+
```typescript title=petstore.ts
136
+
import { on } from'mokapi'
137
+
138
+
exportdefaultfunction() {
139
+
on('http', (request, response) => {
140
+
// TypeScript provides full autocompletion here
141
+
if (request.path.petId==='999') {
142
+
response.statusCode=404
143
+
response.data= { message: 'Pet not found' }
144
+
}
145
+
})
146
+
}
147
+
```
148
+
```box=tip title="IDE Integration"
149
+
With @types/mokapi installed, editors like VS Code will provide autocompletion for Mokapi's API, making script development faster and less error-prone.
150
+
```
151
+
152
+
## What's Next?
153
+
154
+
Now that Mokapi is installed, here's what you can do:
88
155
89
-
-[Create your first Mock](/docs/get-started/running.md)
0 commit comments