fakelab 0.0.5 → 0.0.7

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.
Files changed (2) hide show
  1. package/README.md +19 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -28,33 +28,36 @@ import { defineConfig } from "fakelab";
28
28
 
29
29
  export default defineConfig({
30
30
  sourcePath: "./interfaces", // can set a directory or a single typescript file.
31
+ faker: { locale: "en" }, // optional
32
+ server: { pathPrefix: "api/v1", port: 8080 }, // optional
31
33
  });
32
34
  ```
33
35
 
34
- interfaces folder:
36
+ Fakelab allows you to control generated mock data using JSDoc tags.
37
+ You simply annotate your TypeScript interfaces with the @faker tag, and Fakelab uses the corresponding [faker](https://fakerjs.dev/)
38
+ method when generating mock values.
39
+
40
+ `/interfaces/user.ts`:
35
41
 
36
42
  ```typescript
37
43
  export interface User {
44
+ /** @faker string.uuid */
45
+ id: string;
46
+
47
+ /** @faker person.fullName */
38
48
  name: string;
49
+
50
+ /** @faker number.int */
39
51
  age: number;
52
+
53
+ /** @faker datatype.boolean */
40
54
  admin: boolean;
55
+
56
+ /** @faker location.streetAddress */
41
57
  address: string;
42
- tags: string[];
43
- }
44
- export interface User {
45
- gender: "male" | "female";
46
- }
47
- export interface Post {
48
- id: string;
49
- title: string;
50
- content: string;
51
- published: boolean;
52
- }
53
58
 
54
- export interface Profile {
55
- id: string;
56
- bio: string;
57
- user: User;
59
+ /** @faker word.words */
60
+ tags: string[];
58
61
  }
59
62
  ```
60
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fakelab",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A easy-config mock server for frontend developers.",