hookdesk 0.1.0 → 0.2.0
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/CHANGELOG.md +53 -0
- package/README.md +225 -43
- package/config/app.json +198 -0
- package/config/default.json +9 -0
- package/config/limits.json +40 -0
- package/config/messages.json +193 -0
- package/package.json +6 -5
- package/src/cli.js +24 -0
- package/src/loader/fixed.js +18 -0
- package/src/loader/settings.js +94 -0
- package/src/mocks/rules.js +95 -0
- package/src/server.js +161 -97
- package/src/store/events.js +34 -0
- package/src/ui/index.html +83 -0
- package/src/{ui.css → ui/ui.css} +32 -2
- package/src/ui/ui.js +419 -0
- package/src/config.js +0 -71
- package/src/ui.html +0 -66
- package/src/ui.js +0 -323
- package/src/wordmark.svg +0 -13
- /package/src/{logo.svg → ui/logo.svg} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { app, limits, messages, format, httpError, inRange, rangeText } from '../loader/fixed.js';
|
|
3
|
+
|
|
4
|
+
// Mock response rules: the status, headers, body, and delay a captured request gets back.
|
|
5
|
+
const M = messages.rules;
|
|
6
|
+
const RULE_KEYS = new Set(limits.mocks.ruleKeys);
|
|
7
|
+
const { status: STATUS, statusWithoutBody, reservedHeaders } = limits.mocks;
|
|
8
|
+
const { anyMethod: ANY_METHOD, prefixSuffix: PREFIX, ruleDefaults: DEFAULTS } = app.mocks;
|
|
9
|
+
const METHOD = new RegExp(limits.mocks.methodPattern);
|
|
10
|
+
const ID = new RegExp(limits.mocks.idPattern);
|
|
11
|
+
const PATH = new RegExp(limits.mocks.pathPattern);
|
|
12
|
+
const HEADER_NAME = new RegExp(limits.mocks.headerNamePattern);
|
|
13
|
+
const HEADER_VALUE_FORBIDDEN = new RegExp(limits.mocks.headerValueForbiddenPattern);
|
|
14
|
+
const RESERVED = new Set(reservedHeaders);
|
|
15
|
+
|
|
16
|
+
// "/hook/a" matches only that path; "/hook/a/*" matches "/hook/a" and everything below it.
|
|
17
|
+
const baseOf = pattern => pattern.endsWith(PREFIX) ? pattern.slice(0, -PREFIX.length) : null;
|
|
18
|
+
export function matchPath(pattern, pathname) {
|
|
19
|
+
const base = baseOf(pattern);
|
|
20
|
+
if (base === null) return pathname === pattern;
|
|
21
|
+
return pathname === base || pathname.startsWith(`${base}/`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const matchRule = (rule, method, pathname) => (rule.method === ANY_METHOD || rule.method === method) && matchPath(rule.path, pathname);
|
|
25
|
+
const isPlainObject = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
26
|
+
|
|
27
|
+
// Validates one rule and returns it normalized. Throws an Error whose `errors` lists every problem.
|
|
28
|
+
export function parseRule(input, { pathPrefix, maxDelayMs }, label = M.defaultLabel) {
|
|
29
|
+
if (!isPlainObject(input)) { const message = format(M.notObject, { label }); throw Object.assign(new Error(message), { errors: [message] }); }
|
|
30
|
+
const errors = [];
|
|
31
|
+
for (const key of Object.keys(input)) if (!RULE_KEYS.has(key)) errors.push(format(M.unknownKey, { label, key }));
|
|
32
|
+
if (input.id !== undefined && (typeof input.id !== 'string' || !ID.test(input.id))) errors.push(format(M.id, { label, pattern: limits.mocks.idPattern }));
|
|
33
|
+
|
|
34
|
+
const method = input.method === undefined ? ANY_METHOD : typeof input.method === 'string' ? input.method.toUpperCase() : '';
|
|
35
|
+
if (!METHOD.test(method)) errors.push(format(M.method, { label, any: ANY_METHOD }));
|
|
36
|
+
|
|
37
|
+
const { path } = input;
|
|
38
|
+
const base = typeof path === 'string' ? baseOf(path) ?? path : path;
|
|
39
|
+
if (typeof path !== 'string' || !PATH.test(base) || !(base === pathPrefix || base.startsWith(`${pathPrefix}/`))) {
|
|
40
|
+
errors.push(format(M.path, { label, prefix: pathPrefix, suffix: PREFIX }));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const status = input.status ?? DEFAULTS.status;
|
|
44
|
+
if (!inRange(status, STATUS)) errors.push(format(M.status, { label, range: rangeText(STATUS) }));
|
|
45
|
+
const delayMs = input.delayMs ?? DEFAULTS.delayMs;
|
|
46
|
+
const delayRange = { min: limits.mocks.maxDelayMs.min, max: maxDelayMs };
|
|
47
|
+
if (!inRange(delayMs, delayRange)) errors.push(format(M.delay, { label, range: rangeText(delayRange) }));
|
|
48
|
+
|
|
49
|
+
const headers = {};
|
|
50
|
+
if (input.headers !== undefined) {
|
|
51
|
+
if (!isPlainObject(input.headers)) errors.push(format(M.headersObject, { label }));
|
|
52
|
+
else for (const [name, value] of Object.entries(input.headers)) {
|
|
53
|
+
const lower = name.toLowerCase();
|
|
54
|
+
if (!HEADER_NAME.test(name)) errors.push(format(M.headerName, { label, name }));
|
|
55
|
+
else if (RESERVED.has(lower)) errors.push(format(M.headerReserved, { label, name: lower }));
|
|
56
|
+
else if (typeof value !== 'string' || HEADER_VALUE_FORBIDDEN.test(value)) errors.push(format(M.headerValue, { label, name }));
|
|
57
|
+
else headers[lower] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A string body is sent as is; any other JSON value is serialized and sent as JSON.
|
|
62
|
+
let body = null;
|
|
63
|
+
if (input.body !== undefined && input.body !== null) {
|
|
64
|
+
body = typeof input.body === 'string' ? input.body : JSON.stringify(input.body);
|
|
65
|
+
headers[app.headers.contentType] ??= typeof input.body === 'string' ? app.contentTypes.text : app.contentTypes.json;
|
|
66
|
+
}
|
|
67
|
+
if (body !== null && statusWithoutBody.includes(status)) errors.push(format(M.statusWithoutBody, { label, status }));
|
|
68
|
+
|
|
69
|
+
if (errors.length) throw Object.assign(new Error(errors.join(M.separator)), { errors });
|
|
70
|
+
return { id: input.id, method, path, status, headers, body, delayMs };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The live rule list. Rules added at runtime go first, so a test can override a rule from the config file.
|
|
74
|
+
export function createMockSet({ rules, maxRules, pathPrefix, maxDelayMs }) {
|
|
75
|
+
const list = [...rules];
|
|
76
|
+
return {
|
|
77
|
+
list,
|
|
78
|
+
match: (method, pathname) => list.find(rule => matchRule(rule, method, pathname)),
|
|
79
|
+
add(input) {
|
|
80
|
+
if (list.length >= maxRules) throw httpError(app.status.badRequest, format(messages.api.ruleLimit, { max: maxRules }));
|
|
81
|
+
let rule;
|
|
82
|
+
try { rule = parseRule(input, { pathPrefix, maxDelayMs }); } catch (error) { throw httpError(app.status.badRequest, error.message); }
|
|
83
|
+
if (rule.id === undefined) do rule.id = randomUUID().slice(0, app.mocks.generatedIdLength); while (list.some(r => r.id === rule.id));
|
|
84
|
+
else if (list.some(r => r.id === rule.id)) throw httpError(app.status.conflict, format(messages.api.ruleDuplicate, { id: rule.id }));
|
|
85
|
+
list.unshift(rule);
|
|
86
|
+
return rule;
|
|
87
|
+
},
|
|
88
|
+
remove(id) {
|
|
89
|
+
const index = list.findIndex(rule => rule.id === id);
|
|
90
|
+
if (index !== -1) list.splice(index, 1);
|
|
91
|
+
return index !== -1;
|
|
92
|
+
},
|
|
93
|
+
clear: () => { list.splice(0); },
|
|
94
|
+
};
|
|
95
|
+
}
|
package/src/server.js
CHANGED
|
@@ -1,130 +1,194 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import http from 'node:http';
|
|
3
2
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import {
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
5
4
|
import { readFile } from 'node:fs/promises';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
6
|
+
import { app, limits, messages, format, httpError, rangeText, urlHost } from './loader/fixed.js';
|
|
7
|
+
import { loadConfig } from './loader/settings.js';
|
|
8
|
+
import { createMockSet } from './mocks/rules.js';
|
|
9
|
+
import { createEventStore, createFilter } from './store/events.js';
|
|
10
|
+
|
|
11
|
+
const VERSION = JSON.parse(readFileSync(new URL(app.packageFile, import.meta.url), 'utf8')).version;
|
|
12
|
+
const M = messages.api;
|
|
13
|
+
const S = app.status;
|
|
14
|
+
const H = app.methods;
|
|
15
|
+
const { contentType: CONTENT_TYPE, replay: REPLAY_HEADER, eventId: EVENT_ID_HEADER } = app.headers;
|
|
16
|
+
const { defaults: DEFAULT_HEADERS, always: ALWAYS_HEADERS, onPayloadTooLarge: TOO_LARGE_HEADERS } = app.responseHeaders;
|
|
17
|
+
const HOST_HEADER = new RegExp(limits.server.hostHeaderPattern);
|
|
18
|
+
const API_CONTENT_TYPE = new RegExp(limits.mocks.apiContentTypePattern, 'i');
|
|
19
|
+
const SCHEME = `${app.scheme}:`;
|
|
20
|
+
|
|
21
|
+
// "/api/events/{id}" becomes a pattern that captures the id.
|
|
22
|
+
const escapeRegExp = text => text.replace(/[.*+?^$()|[\]\\]/g, '\\$&');
|
|
23
|
+
const routePattern = template => new RegExp(`^${template.split(/\{\w+\}/).map(escapeRegExp).join('([^/]+)')}$`);
|
|
24
|
+
const EVENT_ROUTE = routePattern(app.routes.event);
|
|
25
|
+
const REPLAY_ROUTE = routePattern(app.routes.replay);
|
|
26
|
+
const MOCK_ROUTE = routePattern(app.routes.mock);
|
|
27
|
+
const STATIC_BY_PATH = new Map(Object.values(app.staticFiles).map(file => [file.path, file]));
|
|
28
|
+
|
|
29
|
+
// The dashboard page is a template: {{t.key}} is a text from messages.json, {{routes.key}} and {{ui.key}} come from app.json.
|
|
30
|
+
const escapeHtml = text => String(text).replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
|
|
31
|
+
const templateValues = { t: messages.html, routes: app.routes, ui: app.ui, staticFiles: app.staticFiles, messages: { ui: messages.ui } };
|
|
32
|
+
const renderTemplate = html => html.replace(/\{\{([\w.]+)\}\}/g, (match, path) => {
|
|
33
|
+
const value = path.split('.').reduce((obj, key) => obj?.[key], templateValues);
|
|
34
|
+
return value === undefined ? match : escapeHtml(value);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export function redactHeaders(headers, { sensitiveHeaders, placeholder }) {
|
|
19
38
|
const sensitive = new Set(sensitiveHeaders);
|
|
20
39
|
return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, sensitive.has(key.toLowerCase()) ? placeholder : value]));
|
|
21
40
|
}
|
|
22
41
|
|
|
23
|
-
|
|
42
|
+
async function readBody(req, limit) {
|
|
24
43
|
const chunks = [];
|
|
25
44
|
let total = 0;
|
|
26
45
|
for await (const chunk of req) {
|
|
27
46
|
total += chunk.length;
|
|
28
|
-
if (total > limit)
|
|
47
|
+
if (total > limit) throw httpError(S.payloadTooLarge, format(M.payloadTooLarge, { limit }));
|
|
29
48
|
chunks.push(chunk);
|
|
30
49
|
}
|
|
31
|
-
return Buffer.concat(chunks).toString(
|
|
50
|
+
return Buffer.concat(chunks).toString();
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
function respond(res, status, value, extraHeaders = {}) {
|
|
35
|
-
res.writeHead(status, {
|
|
54
|
+
res.writeHead(status, { [CONTENT_TYPE]: app.contentTypes.json, ...DEFAULT_HEADERS, ...ALWAYS_HEADERS, ...extraHeaders });
|
|
36
55
|
res.end(JSON.stringify(value));
|
|
37
56
|
}
|
|
57
|
+
const fail = (res, status, message) => respond(res, status, { error: message });
|
|
38
58
|
|
|
39
|
-
const summarize = ({ id, timestamp, method, path, bytes, replayOf }) => ({ id, timestamp, method, path, bytes, replayOf });
|
|
40
|
-
const hostnameOf = value => { try { return new URL(
|
|
59
|
+
const summarize = ({ id, timestamp, method, path, bytes, replayOf, response }) => ({ id, timestamp, method, path, bytes, replayOf, status: response.status, mockId: response.mockId });
|
|
60
|
+
const hostnameOf = value => { try { return new URL(`${SCHEME}//${value}`).hostname; } catch { return null; } };
|
|
61
|
+
|
|
62
|
+
// ?method=POST&path=/hook/a/*&since=<ISO 8601>, shared by list, wait, and export.
|
|
63
|
+
function filterFromQuery(params) {
|
|
64
|
+
const Q = app.query;
|
|
65
|
+
const path = params.get(Q.path);
|
|
66
|
+
const sinceText = params.get(Q.since);
|
|
67
|
+
const since = sinceText === null ? undefined : Date.parse(sinceText);
|
|
68
|
+
if (path !== null && !path.startsWith('/')) throw httpError(S.badRequest, M.pathMustStartWithSlash);
|
|
69
|
+
if (Number.isNaN(since)) throw httpError(S.badRequest, M.sinceInvalid);
|
|
70
|
+
return createFilter({ method: params.get(Q.method)?.toUpperCase(), path, since });
|
|
71
|
+
}
|
|
41
72
|
|
|
42
73
|
export function createApp({ config = loadConfig() } = {}) {
|
|
43
|
-
const { capture, replay, redaction, ui } = config;
|
|
44
|
-
const events =
|
|
74
|
+
const { capture, replay, redaction, mocks: mockConfig, wait, ui } = config;
|
|
75
|
+
const events = createEventStore({ maxEvents: capture.maxEvents });
|
|
76
|
+
const mocks = createMockSet({ rules: mockConfig.rules, maxRules: mockConfig.maxRules, pathPrefix: capture.pathPrefix, maxDelayMs: mockConfig.maxDelayMs });
|
|
45
77
|
const allowedHostnames = new Set(config.server.allowedHostnames);
|
|
46
|
-
const listenHost = config.server.host
|
|
78
|
+
const listenHost = urlHost(config.server.host);
|
|
47
79
|
const notForwarded = new Set([...redaction.sensitiveHeaders, ...replay.excludedHeaders, REPLAY_HEADER]);
|
|
48
|
-
const
|
|
49
|
-
const
|
|
80
|
+
const waitRange = { min: limits.wait.defaultTimeoutMs.min, max: wait.maxTimeoutMs };
|
|
81
|
+
const safeView = ({ pathname, ...event }) => ({ ...event, headers: redactHeaders(event.headers, redaction) });
|
|
82
|
+
const publicConfig = {
|
|
83
|
+
version: VERSION, name: app.name, ui: app.ui, routes: app.routes, methods: app.methods, messages: messages.ui, headers: app.headers, contentTypes: app.contentTypes,
|
|
84
|
+
anyMethod: app.mocks.anyMethod, prefixSuffix: app.mocks.prefixSuffix, mockRuleDefaults: app.mocks.ruleDefaults, statusRange: limits.mocks.status, minDelayMs: limits.mocks.maxDelayMs.min,
|
|
85
|
+
examplePath: app.cli.examplePath, exampleContentType: app.cli.exampleContentType, exampleBody: app.cli.exampleBody, exampleCommand: messages.cli.exampleCommand,
|
|
86
|
+
themes: limits.ui.themes, host: config.server.host, captureBase: capture.pathPrefix, maxEvents: capture.maxEvents, maxBodyBytes: capture.maxBodyBytes, maxDelayMs: mockConfig.maxDelayMs,
|
|
87
|
+
pollIntervalMs: ui.pollIntervalMs, timelineWindowMs: ui.timelineWindowMs, defaultTheme: ui.defaultTheme, curlExcludedHeaders: ui.curlExcludedHeaders, redactedPlaceholder: redaction.placeholder,
|
|
88
|
+
};
|
|
50
89
|
|
|
51
|
-
|
|
90
|
+
async function captureRequest(req, res, url) {
|
|
91
|
+
const body = await readBody(req, capture.maxBodyBytes);
|
|
92
|
+
const rule = mocks.match(req.method, url.pathname);
|
|
93
|
+
const response = rule ? { status: rule.status, mockId: rule.id, mockPath: rule.path, delayMs: rule.delayMs } : { status: app.defaultResponse.status, mockId: null, mockPath: null, delayMs: app.mocks.ruleDefaults.delayMs };
|
|
94
|
+
const event = { id: randomUUID(), timestamp: new Date().toISOString(), method: req.method, path: url.pathname + url.search, pathname: url.pathname, headers: { ...req.headers }, body, bytes: Buffer.byteLength(body), replayOf: req.headers[REPLAY_HEADER] || null, response };
|
|
95
|
+
events.add(event);
|
|
96
|
+
if (!rule) return respond(res, app.defaultResponse.status, { ...app.defaultResponse.body, id: event.id }, { [EVENT_ID_HEADER]: event.id });
|
|
97
|
+
if (rule.delayMs) await sleep(rule.delayMs);
|
|
98
|
+
if (res.destroyed) return;
|
|
99
|
+
// Mock bodies are served from the dashboard origin, so they are sandboxed: a mocked HTML page cannot run scripts here.
|
|
100
|
+
res.writeHead(rule.status, { ...DEFAULT_HEADERS, ...rule.headers, ...ALWAYS_HEADERS, ...app.security.mockHeaders, [EVENT_ID_HEADER]: event.id });
|
|
101
|
+
res.end(req.method === H.head || rule.body === null ? undefined : rule.body);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function waitRequest(res, url) {
|
|
105
|
+
const matches = filterFromQuery(url.searchParams);
|
|
106
|
+
const timeoutText = url.searchParams.get(app.query.timeout);
|
|
107
|
+
const timeout = timeoutText === null ? wait.defaultTimeoutMs : Number(timeoutText);
|
|
108
|
+
if (!Number.isInteger(timeout) || timeout < waitRange.min || timeout > waitRange.max) return fail(res, S.badRequest, format(M.timeoutInvalid, { range: rangeText(waitRange) }));
|
|
109
|
+
const closed = new AbortController();
|
|
110
|
+
res.on('close', () => closed.abort());
|
|
111
|
+
const event = await events.waitFor(matches, timeout, closed.signal);
|
|
112
|
+
if (event === undefined) return;
|
|
113
|
+
return event ? respond(res, S.ok, { event: safeView(event) }) : fail(res, S.timeout, format(M.waitTimedOut, { timeout }));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function addMock(req, res) {
|
|
117
|
+
if (!API_CONTENT_TYPE.test(req.headers[CONTENT_TYPE] || '')) return fail(res, S.unsupportedMediaType, M.contentTypeJson);
|
|
118
|
+
let input;
|
|
119
|
+
try { input = JSON.parse(await readBody(req, capture.maxBodyBytes)); } catch (error) { if (error.status) throw error; return fail(res, S.badRequest, M.bodyInvalidJson); }
|
|
120
|
+
return respond(res, S.created, { rule: mocks.add(input) });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function replayRequest(res, source) {
|
|
124
|
+
if (replay.blockedMethods.includes(source.method)) return fail(res, S.badRequest, format(M.replayBlocked, { method: source.method }));
|
|
125
|
+
// Replay stays inside this app. Credentials, hop-by-hop and browser-controlled headers are never forwarded.
|
|
126
|
+
const headers = Object.fromEntries(Object.entries(source.headers).filter(([key]) => !notForwarded.has(key.toLowerCase())));
|
|
127
|
+
headers[REPLAY_HEADER] = source.id;
|
|
128
|
+
const destination = `${SCHEME}//${listenHost}:${server.address().port}${source.path}`;
|
|
129
|
+
let result;
|
|
130
|
+
try {
|
|
131
|
+
result = await fetch(destination, { method: source.method, headers, body: app.methodsWithoutBody.includes(source.method) ? undefined : source.body, signal: AbortSignal.timeout(replay.timeoutMs) });
|
|
132
|
+
await result.body?.cancel();
|
|
133
|
+
} catch (error) { return fail(res, S.badGateway, format(M.replayFailed, { reason: error.cause?.message || error.message })); }
|
|
134
|
+
return respond(res, S.ok, { ok: true, responseStatus: result.status });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function serveStatic(req, res, staticFile) {
|
|
138
|
+
const content = await readFile(new URL(`./${app.uiDirectory}/${staticFile.file}`, import.meta.url));
|
|
139
|
+
res.writeHead(S.ok, { [CONTENT_TYPE]: staticFile.type, ...DEFAULT_HEADERS, ...ALWAYS_HEADERS, ...(staticFile.dashboard ? app.security.dashboardHeaders : {}) });
|
|
140
|
+
res.end(req.method === H.head ? undefined : staticFile.template ? renderTemplate(content.toString()) : content);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function route(req, res, url) {
|
|
144
|
+
const { pathname } = url;
|
|
145
|
+
const R = app.routes;
|
|
146
|
+
const staticFile = STATIC_BY_PATH.get(pathname);
|
|
147
|
+
if (staticFile && (req.method === H.get || req.method === H.head)) return serveStatic(req, res, staticFile);
|
|
148
|
+
if (req.method === H.get && pathname === R.config) return respond(res, S.ok, publicConfig);
|
|
149
|
+
if (pathname === R.events) {
|
|
150
|
+
if (req.method === H.get) { const list = events.filter(filterFromQuery(url.searchParams)).map(summarize); return respond(res, S.ok, { events: list, count: list.length, total: events.items.length }); }
|
|
151
|
+
if (req.method === H.delete) { events.clear(); return respond(res, S.ok, { ok: true }); }
|
|
152
|
+
}
|
|
153
|
+
if (req.method === H.get && pathname === R.wait) return waitRequest(res, url);
|
|
154
|
+
if (req.method === H.get && pathname === R.export) {
|
|
155
|
+
const list = events.filter(filterFromQuery(url.searchParams)).map(safeView);
|
|
156
|
+
const exportedAt = new Date().toISOString();
|
|
157
|
+
const fileName = format(app.export.fileName, { time: exportedAt.replace(/[:.]/g, '-') });
|
|
158
|
+
const headers = Object.fromEntries(Object.entries(app.export.headers).map(([name, value]) => [name, format(value, { fileName })]));
|
|
159
|
+
return respond(res, S.ok, { tool: app.export.tool, version: VERSION, exportedAt, count: list.length, mocks: mocks.list, events: list }, headers);
|
|
160
|
+
}
|
|
161
|
+
const replayId = pathname.match(REPLAY_ROUTE)?.[1];
|
|
162
|
+
if (req.method === H.post && replayId) { const event = events.find(replayId); return event ? replayRequest(res, event) : fail(res, S.notFound, M.eventNotFound); }
|
|
163
|
+
const eventId = pathname.match(EVENT_ROUTE)?.[1];
|
|
164
|
+
if (req.method === H.get && eventId) { const event = events.find(eventId); return event ? respond(res, S.ok, { event: safeView(event) }) : fail(res, S.notFound, M.eventNotFound); }
|
|
165
|
+
if (pathname === R.mocks) {
|
|
166
|
+
if (req.method === H.get) return respond(res, S.ok, { rules: mocks.list, maxRules: mockConfig.maxRules, maxDelayMs: mockConfig.maxDelayMs });
|
|
167
|
+
if (req.method === H.post) return addMock(req, res);
|
|
168
|
+
if (req.method === H.delete) { mocks.clear(); return respond(res, S.ok, { ok: true }); }
|
|
169
|
+
}
|
|
170
|
+
const mockId = pathname.match(MOCK_ROUTE)?.[1];
|
|
171
|
+
if (req.method === H.delete && mockId) return mocks.remove(decodeURIComponent(mockId)) ? respond(res, S.ok, { ok: true }) : fail(res, S.notFound, M.ruleNotFound);
|
|
172
|
+
if (pathname === capture.pathPrefix || pathname.startsWith(`${capture.pathPrefix}/`)) return captureRequest(req, res, url);
|
|
173
|
+
return fail(res, S.notFound, M.notFound);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const server = http.createServer(async (req, res) => {
|
|
52
177
|
// Not intended as an externally exposed service; reject foreign hosts (DNS rebinding) and cross-site browser requests.
|
|
53
178
|
const host = req.headers.host || '';
|
|
54
|
-
if (
|
|
179
|
+
if (!HOST_HEADER.test(host) || !allowedHostnames.has(hostnameOf(host))) return fail(res, S.forbidden, M.onlyLocalhost);
|
|
55
180
|
const origin = req.headers.origin;
|
|
56
181
|
if (origin) {
|
|
57
|
-
try { const u = new URL(origin); if (u.protocol !==
|
|
58
|
-
catch { return
|
|
182
|
+
try { const u = new URL(origin); if (u.protocol !== SCHEME || !allowedHostnames.has(u.hostname) || u.port !== String(server.address().port)) return fail(res, S.forbidden, M.crossOrigin); }
|
|
183
|
+
catch { return fail(res, S.forbidden, M.invalidOrigin); }
|
|
59
184
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const content = await readFile(fileURLToPath(new URL(`./${staticFile.file}`, import.meta.url)));
|
|
65
|
-
res.writeHead(200, { 'content-type': staticFile.type, 'cache-control': 'no-store', 'x-content-type-options': 'nosniff', ...staticFile.headers });
|
|
66
|
-
res.end(req.method === 'HEAD' ? undefined : content);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (req.method === 'GET' && url.pathname === '/api/config') return respond(res, 200, publicConfig);
|
|
70
|
-
if (req.method === 'GET' && url.pathname === '/api/events') return respond(res, 200, { events: events.map(summarize), count: events.length });
|
|
71
|
-
if (req.method === 'DELETE' && url.pathname === '/api/events') { events.splice(0); return respond(res, 200, { ok: true }); }
|
|
72
|
-
const detailMatch = url.pathname.match(/^\/api\/events\/([^/]+)$/);
|
|
73
|
-
if (req.method === 'GET' && detailMatch) {
|
|
74
|
-
const event = events.find(x => x.id === detailMatch[1]);
|
|
75
|
-
return event ? respond(res, 200, { event: safeView(event) }) : respond(res, 404, { error: 'Event not found' });
|
|
76
|
-
}
|
|
77
|
-
const replayMatch = url.pathname.match(/^\/api\/events\/([^/]+)\/replay$/);
|
|
78
|
-
if (req.method === 'POST' && replayMatch) {
|
|
79
|
-
const source = events.find(x => x.id === replayMatch[1]);
|
|
80
|
-
if (!source) return respond(res, 404, { error: 'Event not found' });
|
|
81
|
-
if (replay.blockedMethods.includes(source.method)) return respond(res, 400, { error: `${source.method} requests cannot be replayed` });
|
|
82
|
-
// Replay stays inside this app. Credentials, hop-by-hop and browser-controlled headers are never forwarded.
|
|
83
|
-
const headers = Object.fromEntries(Object.entries(source.headers).filter(([key]) => !notForwarded.has(key.toLowerCase())));
|
|
84
|
-
headers[REPLAY_HEADER] = source.id;
|
|
85
|
-
const destination = `http://${listenHost}:${server.address().port}${source.path}`;
|
|
86
|
-
let result;
|
|
87
|
-
try {
|
|
88
|
-
result = await fetch(destination, { method: source.method, headers, body: ['GET', 'HEAD'].includes(source.method) ? undefined : source.body, signal: AbortSignal.timeout(replay.timeoutMs) });
|
|
89
|
-
await result.body?.cancel();
|
|
90
|
-
} catch (error) { return respond(res, 502, { error: `Replay failed: ${error.cause?.message || error.message}` }); }
|
|
91
|
-
return respond(res, 200, { ok: true, responseStatus: result.status });
|
|
92
|
-
}
|
|
93
|
-
if (url.pathname === capture.pathPrefix || url.pathname.startsWith(`${capture.pathPrefix}/`)) {
|
|
94
|
-
const body = await readBody(req, capture.maxBodyBytes);
|
|
95
|
-
const event = { id: randomUUID(), timestamp: new Date().toISOString(), method: req.method, path: url.pathname + url.search, headers: { ...req.headers }, body, bytes: Buffer.byteLength(body), replayOf: req.headers[REPLAY_HEADER] || null };
|
|
96
|
-
events.unshift(event);
|
|
97
|
-
if (events.length > capture.maxEvents) events.length = capture.maxEvents;
|
|
98
|
-
return respond(res, 200, { received: true, id: event.id });
|
|
99
|
-
}
|
|
100
|
-
return respond(res, 404, { error: 'Not found' });
|
|
101
|
-
} catch (error) {
|
|
102
|
-
const status = error.status || 500;
|
|
185
|
+
try { await route(req, res, new URL(req.url || '/', `${SCHEME}//${host}`)); }
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (res.headersSent) return res.destroy();
|
|
188
|
+
const status = error.status || S.serverError;
|
|
103
189
|
// Close the connection on 413 so the client stops streaming the rest of the oversized body.
|
|
104
|
-
|
|
190
|
+
respond(res, status, { error: error.status ? error.message : M.internalError }, status === S.payloadTooLarge ? TOO_LARGE_HEADERS : {});
|
|
105
191
|
}
|
|
106
|
-
};
|
|
107
|
-
const server = http.createServer(handler);
|
|
108
|
-
return { server, events, config };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const argValue = name => process.argv.find(x => x.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
112
|
-
// Resolve symlinks so the server also starts when launched through an npm bin link.
|
|
113
|
-
const isMain = () => { try { return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url)); } catch { return false; } };
|
|
114
|
-
|
|
115
|
-
if (process.argv[1] && isMain()) {
|
|
116
|
-
const port = argValue('port') ?? process.env.PORT;
|
|
117
|
-
let config;
|
|
118
|
-
try { config = loadConfig({ file: argValue('config'), overrides: port === undefined ? undefined : { server: { port: Number(port) } } }); }
|
|
119
|
-
catch (error) { console.error(error.message); process.exit(1); }
|
|
120
|
-
const { server } = createApp({ config });
|
|
121
|
-
server.on('error', error => { console.error(`Cannot start HookDesk Mini: ${error.message}`); process.exit(1); });
|
|
122
|
-
server.listen(config.server.port, config.server.host, () => {
|
|
123
|
-
const host = config.server.host === '::1' ? '[::1]' : config.server.host;
|
|
124
|
-
const base = `http://${host}:${server.address().port}`;
|
|
125
|
-
console.log(`\n HookDesk Mini is running`);
|
|
126
|
-
console.log(` Dashboard: ${base}`);
|
|
127
|
-
console.log(` Webhook: ${base}${config.capture.pathPrefix}`);
|
|
128
|
-
console.log(` Example: curl -X POST ${base}${config.capture.pathPrefix}/demo -H 'Content-Type: application/json' -d '{"event":"hello"}'\n`);
|
|
129
192
|
});
|
|
193
|
+
return { server, events, mocks, config };
|
|
130
194
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { matchPath } from '../mocks/rules.js';
|
|
2
|
+
|
|
3
|
+
// Builds a predicate from optional filters: method, path (exact or ending in "/*"), and since (epoch ms, inclusive).
|
|
4
|
+
export const createFilter = ({ method, path, since }) => event =>
|
|
5
|
+
(!method || event.method === method) && (!path || matchPath(path, event.pathname)) && (since === undefined || Date.parse(event.timestamp) >= since);
|
|
6
|
+
|
|
7
|
+
// In-memory request history, newest first, plus waiters that resolve when a matching request arrives.
|
|
8
|
+
export function createEventStore({ maxEvents }) {
|
|
9
|
+
const items = [];
|
|
10
|
+
const waiters = new Set();
|
|
11
|
+
return {
|
|
12
|
+
items,
|
|
13
|
+
add(event) {
|
|
14
|
+
items.unshift(event);
|
|
15
|
+
if (items.length > maxEvents) items.length = maxEvents;
|
|
16
|
+
for (const waiter of [...waiters]) if (waiter.matches(event)) waiter.done(event);
|
|
17
|
+
},
|
|
18
|
+
find: id => items.find(event => event.id === id),
|
|
19
|
+
filter: matches => items.filter(matches),
|
|
20
|
+
clear: () => { items.splice(0); },
|
|
21
|
+
// Resolves with the oldest stored match, else the next one to arrive; null on timeout; undefined if aborted.
|
|
22
|
+
waitFor(matches, timeoutMs, signal) {
|
|
23
|
+
const stored = items.findLast(matches);
|
|
24
|
+
if (stored || timeoutMs === 0) return Promise.resolve(stored ?? null);
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
const waiter = { matches, done: result => { if (!waiters.delete(waiter)) return; clearTimeout(timer); signal.removeEventListener('abort', onAbort); resolve(result); } };
|
|
27
|
+
const onAbort = () => waiter.done(undefined);
|
|
28
|
+
const timer = setTimeout(() => waiter.done(null), timeoutMs);
|
|
29
|
+
waiters.add(waiter);
|
|
30
|
+
signal.addEventListener('abort', onAbort);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title></title>
|
|
3
|
+
<link rel="stylesheet" href="{{staticFiles.styles.path}}">
|
|
4
|
+
<link rel="icon" href="{{staticFiles.logo.path}}" type="image/svg+xml">
|
|
5
|
+
</head><body data-config-url="{{routes.config}}" data-retry-ms="{{ui.retryMs}}" data-offline="{{messages.ui.offline}}">
|
|
6
|
+
<header class="top">
|
|
7
|
+
<div class="brand"><img class="brand-mark" src="{{staticFiles.logo.path}}" width="28" height="28" alt=""><span class="brand-name">{{t.brandName}}</span><span class="brand-tag">{{t.brandTag}}</span></div>
|
|
8
|
+
<div class="top-meta">
|
|
9
|
+
<span class="kv"><span class="k">{{t.version}}</span><span class="v" data-bind="version"></span></span>
|
|
10
|
+
<span class="kv"><span class="k">{{t.host}}</span><span class="v" data-bind="host"></span></span>
|
|
11
|
+
<span class="kv"><span class="k">{{t.buffer}}</span><span class="v"><span data-bind="limit"></span> {{t.requestsShort}}</span></span>
|
|
12
|
+
<span class="kv"><span class="k">{{t.storage}}</span><span class="v">{{t.memory}}</span></span>
|
|
13
|
+
</div>
|
|
14
|
+
<div id="live" class="live" title="{{t.liveTitle}}"><span class="live-dot" aria-hidden="true"></span><span id="live-label">{{messages.ui.live}}</span></div>
|
|
15
|
+
<div id="themes" class="theme" role="group" aria-label="{{t.themeGroup}}"></div>
|
|
16
|
+
</header>
|
|
17
|
+
|
|
18
|
+
<section class="scope">
|
|
19
|
+
<div class="stats">
|
|
20
|
+
<div class="stat"><div class="stat-k">{{t.captured}}</div><div id="count" class="stat-v"></div><div class="stat-d">{{t.capturedNote}}</div></div>
|
|
21
|
+
<div class="stat"><div class="stat-k">{{t.last}} <span data-bind="rate-window"></span></div><div id="rate" class="stat-v"></div><div class="stat-d">{{t.rateNote}}</div></div>
|
|
22
|
+
<div class="stat"><div class="stat-k">{{t.lastHit}}</div><div id="last" class="stat-v"></div><div class="stat-d">{{t.lastHitNote}}</div></div>
|
|
23
|
+
<div class="stat"><div class="stat-k">{{t.inMemory}}</div><div id="bytes" class="stat-v"></div><div class="stat-d">{{t.inMemoryNote}}</div></div>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="scope-chart">
|
|
26
|
+
<div class="scope-head">
|
|
27
|
+
<span class="scope-title">{{t.activity}} <span data-bind="window"></span></span>
|
|
28
|
+
<span class="scope-help">{{t.activityHelp}}</span>
|
|
29
|
+
<span id="legend" class="legend"></span>
|
|
30
|
+
</div>
|
|
31
|
+
<canvas id="scope" role="img" aria-label="{{t.timelineLabel}}"></canvas>
|
|
32
|
+
<div id="axis" class="scope-axis"></div>
|
|
33
|
+
</div>
|
|
34
|
+
</section>
|
|
35
|
+
|
|
36
|
+
<section class="command">
|
|
37
|
+
<span class="command-label">{{t.sendTest}}</span>
|
|
38
|
+
<span class="prompt" aria-hidden="true">$</span>
|
|
39
|
+
<code id="command" class="command-text" title="{{t.commandTitle}}"></code>
|
|
40
|
+
<div class="command-actions">
|
|
41
|
+
<button id="copy" class="btn" title="{{t.copyEndpointTitle}}">{{t.copyEndpoint}}</button>
|
|
42
|
+
<button id="copy-cmd" class="btn" title="{{t.copyCurlTitle}}">{{t.copyCurl}}</button>
|
|
43
|
+
<a class="btn btn-link" href="{{routes.export}}" download title="{{t.exportTitle}}">{{t.export}}</a>
|
|
44
|
+
<button id="refresh" class="btn btn-ghost" title="{{t.refreshTitle}}">{{t.refresh}}</button>
|
|
45
|
+
<button id="clear" class="btn btn-ghost btn-danger" title="{{t.clearTitle}}">{{t.clear}}</button>
|
|
46
|
+
</div>
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
<details class="mocks">
|
|
50
|
+
<summary class="mocks-summary"><span class="command-label">{{t.mockResponses}}</span><span id="mocks-count" class="mocks-count"></span><span class="mocks-hint">{{t.mocksHint}}</span></summary>
|
|
51
|
+
<div class="mocks-body">
|
|
52
|
+
<div id="mocks-list" class="mocks-list"></div>
|
|
53
|
+
<form id="mock-form" class="mock-form">
|
|
54
|
+
<label>{{t.formMethod}}<select name="method"></select></label>
|
|
55
|
+
<label>{{t.formPath}} <span data-bind="prefix-suffix"></span><input name="path" required spellcheck="false"></label>
|
|
56
|
+
<label>{{t.formStatus}}<input name="status" type="number" required></label>
|
|
57
|
+
<label>{{t.formDelay}}<input name="delayMs" type="number" required></label>
|
|
58
|
+
<label>{{t.formHeaders}}<textarea name="headers" rows="2" spellcheck="false"></textarea></label>
|
|
59
|
+
<label>{{t.formBody}}<textarea name="body" rows="2" spellcheck="false"></textarea></label>
|
|
60
|
+
<div class="mock-actions">
|
|
61
|
+
<button class="btn btn-primary" type="submit">{{t.addRule}}</button>
|
|
62
|
+
<button id="mocks-clear" class="btn btn-ghost btn-danger" type="button">{{t.removeAllRules}}</button>
|
|
63
|
+
</div>
|
|
64
|
+
</form>
|
|
65
|
+
</div>
|
|
66
|
+
</details>
|
|
67
|
+
|
|
68
|
+
<main class="split">
|
|
69
|
+
<section class="pane pane-list">
|
|
70
|
+
<div class="pane-head"><span class="pane-title">{{t.requests}}<span class="pane-sub">{{t.newestFirst}}</span></span><span class="keys"><span data-keys="next previous"></span> {{t.navigate}}</span></div>
|
|
71
|
+
<div class="table-head"><span>{{t.columnMethod}}</span><span>{{t.columnPath}}</span><span class="num">{{t.columnStatus}}</span><span class="num">{{t.columnSize}}</span><span class="num">{{t.columnAge}}</span></div>
|
|
72
|
+
<div id="entries" class="entries"></div>
|
|
73
|
+
</section>
|
|
74
|
+
<section class="pane pane-detail"><div id="detail" class="detail"></div></section>
|
|
75
|
+
</main>
|
|
76
|
+
|
|
77
|
+
<footer class="foot">
|
|
78
|
+
<span>{{t.footer}}</span>
|
|
79
|
+
<span class="keys"><span data-keys="replay"></span> {{t.replay}} <span data-keys="copyCurl"></span> {{t.copyCurlKey}}</span>
|
|
80
|
+
</footer>
|
|
81
|
+
|
|
82
|
+
<div id="toast" class="toast" role="status"></div>
|
|
83
|
+
<script src="{{staticFiles.script.path}}"></script></body></html>
|
package/src/{ui.css → ui/ui.css}
RENAMED
|
@@ -109,6 +109,29 @@ kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px;
|
|
|
109
109
|
.btn-ghost { background: transparent; border-color: transparent; color: var(--dim); }
|
|
110
110
|
.btn-ghost:hover { background: var(--raise); border-color: var(--line-strong); color: var(--text); }
|
|
111
111
|
.btn-danger:hover { color: var(--danger); }
|
|
112
|
+
.btn-link { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
|
|
113
|
+
|
|
114
|
+
/* Mock responses */
|
|
115
|
+
.mocks { border-bottom: 1px solid var(--line); }
|
|
116
|
+
.mocks-summary { display: flex; align-items: center; gap: 14px; padding: 10px var(--pad); cursor: pointer; list-style: none; }
|
|
117
|
+
.mocks-summary::-webkit-details-marker { display: none; }
|
|
118
|
+
.mocks-summary::before { content: "+"; font-family: var(--mono); color: var(--faint); }
|
|
119
|
+
.mocks[open] .mocks-summary::before { content: "-"; }
|
|
120
|
+
.mocks-count { font-family: var(--mono); font-size: 12px; color: var(--accent-text); }
|
|
121
|
+
.mocks-hint { font-size: 12px; color: var(--dim); }
|
|
122
|
+
.mocks-body { padding: 0 var(--pad) 16px; }
|
|
123
|
+
.mocks-list { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
|
|
124
|
+
.mocks-list > .note { margin: 0; padding: 10px 14px; }
|
|
125
|
+
.mock-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 48px 70px minmax(60px, 120px) auto; gap: 12px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px; }
|
|
126
|
+
.mock-row:last-child { border-bottom: 0; }
|
|
127
|
+
.mock-row .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
128
|
+
.mock-row .mock-id { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
129
|
+
.mock-form { display: grid; grid-template-columns: 110px minmax(0, 1fr) 90px 110px; gap: 10px 12px; }
|
|
130
|
+
.mock-form label { display: flex; flex-direction: column; gap: 5px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--faint); }
|
|
131
|
+
.mock-form label:nth-child(5), .mock-form label:nth-child(6) { grid-column: 1 / -1; }
|
|
132
|
+
.mock-form input, .mock-form select, .mock-form textarea { height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 12px; }
|
|
133
|
+
.mock-form textarea { height: auto; padding: 6px 8px; resize: vertical; }
|
|
134
|
+
.mock-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
|
|
112
135
|
|
|
113
136
|
/* Split panes */
|
|
114
137
|
.split { flex: 1; display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; min-height: 0; }
|
|
@@ -116,7 +139,7 @@ kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px;
|
|
|
116
139
|
.pane-list { border-right: 1px solid var(--line); }
|
|
117
140
|
.pane-head { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 var(--pad); border-bottom: 1px solid var(--line); }
|
|
118
141
|
.pane-title { font-weight: 600; font-size: 13px; }
|
|
119
|
-
.table-head, .row { display: grid; grid-template-columns: 62px minmax(0, 1fr)
|
|
142
|
+
.table-head, .row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 48px 76px 46px; gap: 12px; align-items: center; padding: 0 var(--pad); }
|
|
120
143
|
.table-head { height: 30px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
|
|
121
144
|
.num { text-align: right; font-variant-numeric: tabular-nums; }
|
|
122
145
|
.entries { flex: 1; overflow: auto; max-height: calc(100vh - 330px); min-height: 220px; }
|
|
@@ -126,7 +149,9 @@ kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px;
|
|
|
126
149
|
.row.is-new { animation: flash 1.4s ease-out; }
|
|
127
150
|
.row .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
|
|
128
151
|
.row .num { color: var(--dim); font-size: 11.5px; }
|
|
129
|
-
.row .replay-mark { color: var(--accent-text); margin-left: 8px; font-size: 10px; }
|
|
152
|
+
.row .replay-mark, .row .mock-mark { color: var(--accent-text); margin-left: 8px; font-size: 10px; }
|
|
153
|
+
.row .mock-mark { color: var(--m-other); }
|
|
154
|
+
.status-error { color: var(--danger) !important; }
|
|
130
155
|
.m { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
|
|
131
156
|
.m-get { color: var(--m-get); } .m-post { color: var(--m-post); } .m-put { color: var(--m-put); } .m-patch { color: var(--m-patch); } .m-delete { color: var(--m-delete); } .m-other { color: var(--m-other); }
|
|
132
157
|
|
|
@@ -204,9 +229,14 @@ kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px;
|
|
|
204
229
|
.scope { grid-template-columns: 1fr; }
|
|
205
230
|
.stats { border-right: 0; border-bottom: 1px solid var(--line); }
|
|
206
231
|
.command { flex-wrap: wrap; }
|
|
232
|
+
.command-actions { flex-wrap: wrap; }
|
|
207
233
|
.command-text { flex-basis: calc(100% - 30px); }
|
|
208
234
|
.split { grid-template-columns: 1fr; }
|
|
209
235
|
.pane-list { border-right: 0; border-bottom: 1px solid var(--line); }
|
|
236
|
+
.mocks-hint { display: none; }
|
|
237
|
+
.mock-form { grid-template-columns: 1fr 1fr; }
|
|
238
|
+
.mock-row { grid-template-columns: 56px minmax(0, 1fr) 40px auto; }
|
|
239
|
+
.mock-row .num:nth-child(4), .mock-row .mock-id { display: none; }
|
|
210
240
|
.entries, .detail { max-height: none; }
|
|
211
241
|
.foot .keys { display: none; }
|
|
212
242
|
}
|