mockaton 6.3.0 → 6.3.2

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "6.3.0",
5
+ "version": "6.3.2",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/MockBroker.js CHANGED
@@ -1,7 +1,5 @@
1
- import { join } from 'node:path'
2
1
  import { Route } from './Route.js'
3
2
  import { Config } from './Config.js'
4
- import { isDirectory } from './utils/fs.js'
5
3
  import { DEFAULT_500_COMMENT } from './ApiConstants.js'
6
4
 
7
5
 
@@ -12,7 +10,6 @@ export class MockBroker {
12
10
 
13
11
  constructor(file) {
14
12
  this.#route = new Route(file)
15
- this.method = this.#route.method
16
13
  this.mocks = []
17
14
  this.currentMock = {
18
15
  file: '',
@@ -61,19 +58,11 @@ export class MockBroker {
61
58
  if (!this.#has500())
62
59
  this.#registerTemp500()
63
60
  }
64
-
65
61
  #has500() {
66
- return this.mocks.some(mock =>
67
- Route.parseFilename(mock).status === 500)
62
+ return this.mocks.some(mock => Route.parseFilename(mock).status === 500)
68
63
  }
69
-
70
64
  #registerTemp500() {
71
65
  const { urlMask, method } = Route.parseFilename(this.mocks[0])
72
- let mask = urlMask
73
- if (isDirectory(join(Config.mocksDir, urlMask)))
74
- mask = urlMask + '/'
75
- mask = mask.replace(/^\//, '') // remove initial slash
76
- const file = `${mask}${DEFAULT_500_COMMENT}.${method}.500.txt`
77
- this.register(file)
66
+ this.register(`${urlMask}${DEFAULT_500_COMMENT}.${method}.500.txt`)
78
67
  }
79
68
  }
@@ -22,7 +22,7 @@ export async function dispatchMock(req, response) {
22
22
 
23
23
  try {
24
24
  const { file, status, delay } = broker
25
- console.log('\n', req.url, '→\n ', file)
25
+ console.log(req.url, ' ', file)
26
26
 
27
27
  let mockText
28
28
  if (file.endsWith('.js')) {
package/src/Route.js CHANGED
@@ -14,8 +14,7 @@ export class Route {
14
14
  #urlRegex
15
15
 
16
16
  constructor(file) {
17
- const { urlMask, method } = Route.parseFilename(file)
18
- this.method = method
17
+ const { urlMask } = Route.parseFilename(file)
19
18
  this.#urlRegex = new RegExp('^' + disregardVariables(removeQueryStringAndFragment(urlMask)) + '/*$')
20
19
  }
21
20