fakelab 0.0.15 → 0.0.16
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 +44 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,50 @@ export interface User {
|
|
|
83
83
|
|
|
84
84
|
**NOTE:** Fakelab only supports `interfaces`, `types`, `named export declarations`.
|
|
85
85
|
|
|
86
|
+
## Fakelab Runtime
|
|
87
|
+
|
|
88
|
+
`fakelab/runtime` enables a **global Fakelab object** at runtime, allowing your frontend or Node environment to communicate with the running Fakelab mock server.
|
|
89
|
+
|
|
90
|
+
## Enabling the runtime (important)
|
|
91
|
+
|
|
92
|
+
To enable the global `fakelab` object, you **must import the runtime once** in your application.
|
|
93
|
+
|
|
94
|
+
## `fakelab.URL`
|
|
95
|
+
|
|
96
|
+
The base URL of the running Fakelab server.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
fakelab.URL;
|
|
100
|
+
// e.g. "http://localhost:50000/api"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## `fakelab.fetch`
|
|
104
|
+
|
|
105
|
+
Fetch mock data from the Fakelab server by **typescript interface/type name**.
|
|
106
|
+
|
|
107
|
+
### Signature
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
fakelab.fetch(name: string, count?: number): Promise<T[]>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Parameters
|
|
114
|
+
|
|
115
|
+
| Name | Type | Description |
|
|
116
|
+
| ------- | -------- | -------------------------------------- |
|
|
117
|
+
| `name` | `string` | Interface/Type name |
|
|
118
|
+
| `count` | `number` | Number of items to generate (optional) |
|
|
119
|
+
|
|
120
|
+
### Basic example
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import "fakelab/runtime";
|
|
124
|
+
|
|
125
|
+
const users = await fakelab.fetch("User", 10);
|
|
126
|
+
|
|
127
|
+
console.log(users);
|
|
128
|
+
```
|
|
129
|
+
|
|
86
130
|
## Server Command
|
|
87
131
|
|
|
88
132
|
Run:
|