mockaton 0.10.4 → 0.10.5
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
package/src/Mockaton.js
CHANGED
|
@@ -30,7 +30,7 @@ export function Mockaton(options) {
|
|
|
30
30
|
.listen(Config.port, Config.host, function (error) {
|
|
31
31
|
const { address, port } = this.address()
|
|
32
32
|
const url = `http://${address}:${port}`
|
|
33
|
-
console.log('Listening
|
|
33
|
+
console.log('Listening', url)
|
|
34
34
|
console.log('Dashboard', url + API.dashboard)
|
|
35
35
|
if (error)
|
|
36
36
|
console.error(error)
|
package/src/StaticDispatcher.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
|
-
import { existsSync, lstatSync } from 'node:fs'
|
|
2
|
+
import { existsSync as exists, lstatSync as lstat } from 'node:fs'
|
|
3
3
|
|
|
4
4
|
import { Config } from './Config.js'
|
|
5
5
|
import { sendFile, sendPartialContent } from './utils/http-response.js'
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
export function isStatic(req) {
|
|
9
|
-
return Config.staticDir &&
|
|
10
|
-
existsSync(resolvePath(req))
|
|
9
|
+
return Config.staticDir && exists(resolvePath(req))
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export async function dispatchStatic(req, response) {
|
|
@@ -20,8 +19,8 @@ export async function dispatchStatic(req, response) {
|
|
|
20
19
|
|
|
21
20
|
function resolvePath(req) {
|
|
22
21
|
const candidate = join(Config.staticDir, req.url)
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
22
|
+
if (exists(candidate))
|
|
23
|
+
return lstat(candidate).isDirectory()
|
|
25
24
|
? candidate + '/index.html'
|
|
26
25
|
: candidate
|
|
27
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
|
-
import { readdirSync, lstatSync } from 'node:fs'
|
|
2
|
+
import { readdirSync as readDir, lstatSync } from 'node:fs'
|
|
3
3
|
|
|
4
4
|
import { Route } from './Route.js'
|
|
5
5
|
import { Config } from './Config.js'
|
|
@@ -23,7 +23,7 @@ export function init() {
|
|
|
23
23
|
collection = {}
|
|
24
24
|
cookie.init(Config.cookies)
|
|
25
25
|
|
|
26
|
-
const files =
|
|
26
|
+
const files = readDir(Config.mocksDir, { recursive: true })
|
|
27
27
|
.filter(f => Config.allowedExt.test(f) && lstatSync(join(Config.mocksDir, f)).isFile())
|
|
28
28
|
.sort()
|
|
29
29
|
|