mockaton 13.6.2 → 13.6.4

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
@@ -44,11 +44,11 @@ Also, each route can have different mock file variants.
44
44
 
45
45
  | Route | Filename | Description |
46
46
  | -----| -----| ---|
47
- | /api/company/123 | api/company/[id].GET.200.json | `[id]` is a dynamic parameter |
47
+ | /api/company/123 | api/company/[id].GET.200.ts | `[id]` is a dynamic parameter. `.ts`, and `.js` are sent as JSON by default |
48
48
  | /media/avatar.png | media/avatar.png | Statics assets don't need the above extension |
49
- | /api/login | api/login(invalid attempt).POST.401.json | Anything within parenthesis is a **comment**, they are ignored when routing |
50
- | /api/login | api/login(default).GET.200.json | `(default)` is a special comment; otherwise, the first mock variant in alphabetical order wins |
51
- | /api/login | api/login(locked out user).POST.423.ts | TypeScript or JavaScript mocks are sent as JSON by default |
49
+ | /api/login | api/login(invalid attempt).POST.401.ts | Anything within parenthesis is a **comment**, they are ignored when routing |
50
+ | /api/login | api/login(default).GET.200.ts | `(default)` is a special comment; otherwise, the first mock variant in alphabetical order wins |
51
+ | /api/login | api/login(locked out user).POST.423.json | `.json` is allowed too |
52
52
 
53
53
 
54
54
  ## Docs
@@ -72,27 +72,29 @@ sleep 0.1 # Wait for the watcher to register it
72
72
  ```
73
73
 
74
74
  ### Example A: JSON
75
- - **Route:** /api/company/123
76
- - **Filename:** api/company/[id].GET.200.json
77
-
78
- ```json
79
- {
80
- "name": "Acme, Inc."
81
- }
82
- ```
83
-
84
- ### Example B: TypeScript or JavaScript
85
- Exporting an Object, Array, or String is sent as JSON.
75
+ For JSON responses, use TypeScript (or JavaScript), and export an Object, Array, or String.
86
76
 
87
- - **Route:** /api/company/abc
77
+ - **Route:** /api/company/123
88
78
  - **Filename:** api/company/[id].GET.200.ts
89
79
 
90
80
  ```ts
91
81
  export default {
82
+ id: 123,
92
83
  name: 'Acme, Inc.'
93
84
  }
94
85
  ```
95
86
 
87
+ ### Example B: Non-JSON
88
+ - **Route:** /api/company/123
89
+ - **Filename:** api/company/[id].GET.200.xml
90
+
91
+ ```xml
92
+ <company>
93
+ <id>123</id>
94
+ <name>Acme, Inc.</name>
95
+ </company>
96
+ ```
97
+
96
98
  ### Example C: [Function Mocks](https://mockaton.com/function-mocks)
97
99
  With a function mock you can do pretty much anything you could do with a normal backend handler.</p>
98
100
  For example, you can handle complex logic, URL parsing, saving toa database, etc.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "13.6.2",
5
+ "version": "13.6.4",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./index.js",
package/src/server/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { resolve } from 'node:path'
3
+ import { resolve, join } from 'node:path'
4
4
  import { parseArgs } from 'node:util'
5
5
 
6
6
  import { isFile } from './utils/fs.js'
7
7
  import { Mockaton } from '../../index.js'
8
-
9
8
  import pkgJSON from '../../package.json' with { type: 'json' }
10
9
 
10
+ const rel = f => join(import.meta.dirname, f)
11
11
 
12
12
  process.on('unhandledRejection', error => { throw error })
13
13
 
@@ -25,6 +25,7 @@ try {
25
25
  'no-read-only': { type: 'boolean' },
26
26
 
27
27
  help: { short: 'h', type: 'boolean' },
28
+ skills: { type: 'boolean' },
28
29
  version: { short: 'v', type: 'boolean' }
29
30
  },
30
31
  allowPositionals: true
@@ -44,6 +45,9 @@ process.on('SIGUSR2', () => process.exit(0))
44
45
  if (args.version)
45
46
  console.log(pkgJSON.version)
46
47
 
48
+ else if (args.skills)
49
+ console.log(rel('../../www/src/assets/SKILLS.md'))
50
+
47
51
  else if (args.help)
48
52
  console.log(`
49
53
  Usage: mockaton [mocks-dir] [options]
@@ -58,6 +62,7 @@ Options:
58
62
  --no-open Don't open dashboard in a browser
59
63
  --no-read-only Allow writing and deleting mocks via API
60
64
 
65
+ --skills Show AI agent SKILLS.md file path
61
66
  -h, --help
62
67
  -v, --version
63
68
 
@@ -15,11 +15,11 @@ Also, each route can have different mock file variants.
15
15
 
16
16
  | Route | Filename | Description |
17
17
  | -----| -----| ---|
18
- | /api/company/123 | api/company/[id].GET.200.json | `[id]` is a dynamic parameter |
18
+ | /api/company/123 | api/company/[id].GET.200.ts | `[id]` is a dynamic parameter. `.ts`, and `.js` are sent as JSON by default |
19
19
  | /media/avatar.png | media/avatar.png | Statics assets don't need the above extension |
20
- | /api/login | api/login(invalid attempt).POST.401.json | Anything within parenthesis is a **comment**, they are ignored when routing |
21
- | /api/login | api/login(default).GET.200.json | `(default)` is a special comment; otherwise, the first mock variant in alphabetical order wins |
22
- | /api/login | api/login(locked out user).POST.423.ts | TypeScript or JavaScript mocks are sent as JSON by default |
20
+ | /api/login | api/login(invalid attempt).POST.401.ts | Anything within parenthesis is a **comment**, they are ignored when routing |
21
+ | /api/login | api/login(default).GET.200.ts | `(default)` is a special comment; otherwise, the first mock variant in alphabetical order wins |
22
+ | /api/login | api/login(locked out user).POST.423.json | `.json` is allowed too |
23
23
 
24
24
 
25
25
  ## Docs
@@ -39,27 +39,29 @@ sleep 0.1 # Wait for the watcher to register it
39
39
  ```
40
40
 
41
41
  ### Example A: JSON
42
- - **Route:** /api/company/123
43
- - **Filename:** api/company/[id].GET.200.json
44
-
45
- ```json
46
- {
47
- "name": "Acme, Inc."
48
- }
49
- ```
50
-
51
- ### Example B: TypeScript or JavaScript
52
- Exporting an Object, Array, or String is sent as JSON.
42
+ For JSON responses, use TypeScript (or JavaScript), and export an Object, Array, or String.
53
43
 
54
- - **Route:** /api/company/abc
44
+ - **Route:** /api/company/123
55
45
  - **Filename:** api/company/[id].GET.200.ts
56
46
 
57
47
  ```ts
58
48
  export default {
49
+ id: 123,
59
50
  name: 'Acme, Inc.'
60
51
  }
61
52
  ```
62
53
 
54
+ ### Example B: Non-JSON
55
+ - **Route:** /api/company/123
56
+ - **Filename:** api/company/[id].GET.200.xml
57
+
58
+ ```xml
59
+ <company>
60
+ <id>123</id>
61
+ <name>Acme, Inc.</name>
62
+ </company>
63
+ ```
64
+
63
65
  ### Example C: [Function Mocks](https://mockaton.com/function-mocks)
64
66
  With a function mock you can do pretty much anything you could do with a normal backend handler.</p>
65
67
  For example, you can handle complex logic, URL parsing, saving toa database, etc.