@stuntman/server 0.1.5 → 0.1.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.
- package/README.md +3 -3
- package/package.json +8 -6
- package/src/api/api.ts +69 -48
- package/src/api/utils.ts +26 -26
- package/src/api/validators.ts +44 -35
- package/src/api/webgui/rules.pug +4 -2
- package/src/api/webgui/style.css +3 -3
- package/src/api/webgui/traffic.pug +1 -0
- package/src/bin/stuntman.ts +2 -2
- package/src/ipUtils.ts +1 -1
- package/src/mock.ts +137 -153
- package/src/ruleExecutor.ts +2 -1
- package/src/rules/index.ts +5 -5
- package/src/storage.ts +2 -2
- package/dist/api/api.d.ts +0 -22
- package/dist/api/api.js +0 -188
- package/dist/api/utils.d.ts +0 -4
- package/dist/api/utils.js +0 -69
- package/dist/api/validators.d.ts +0 -3
- package/dist/api/validators.js +0 -118
- package/dist/api/webgui/rules.pug +0 -145
- package/dist/api/webgui/style.css +0 -28
- package/dist/api/webgui/traffic.pug +0 -37
- package/dist/bin/stuntman.d.ts +0 -2
- package/dist/bin/stuntman.js +0 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/dist/ipUtils.d.ts +0 -17
- package/dist/ipUtils.js +0 -101
- package/dist/mock.d.ts +0 -30
- package/dist/mock.js +0 -321
- package/dist/requestContext.d.ts +0 -9
- package/dist/requestContext.js +0 -18
- package/dist/ruleExecutor.d.ts +0 -22
- package/dist/ruleExecutor.js +0 -187
- package/dist/rules/catchAll.d.ts +0 -2
- package/dist/rules/catchAll.js +0 -15
- package/dist/rules/echo.d.ts +0 -2
- package/dist/rules/echo.js +0 -15
- package/dist/rules/index.d.ts +0 -3
- package/dist/rules/index.js +0 -70
- package/dist/storage.d.ts +0 -4
- package/dist/storage.js +0 -42
package/dist/storage.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import LRUCache from 'lru-cache';
|
|
2
|
-
import type * as Stuntman from '@stuntman/shared';
|
|
3
|
-
export declare const getTrafficStore: (key: string, options?: Stuntman.StorageConfig) => LRUCache<string, Stuntman.LogEntry>;
|
|
4
|
-
export declare const getDnsResolutionCache: (key: string) => LRUCache<string, string>;
|
package/dist/storage.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDnsResolutionCache = exports.getTrafficStore = void 0;
|
|
7
|
-
const lru_cache_1 = __importDefault(require("lru-cache"));
|
|
8
|
-
const object_sizeof_1 = __importDefault(require("object-sizeof"));
|
|
9
|
-
const DNS_CACHE_OPTIONS = {
|
|
10
|
-
max: 1000,
|
|
11
|
-
ttl: 1000 * 60 * 15,
|
|
12
|
-
allowStale: false,
|
|
13
|
-
updateAgeOnGet: false,
|
|
14
|
-
updateAgeOnHas: false,
|
|
15
|
-
};
|
|
16
|
-
const trafficStoreInstances = {};
|
|
17
|
-
const dnsResolutionCacheInstances = {};
|
|
18
|
-
const getTrafficStore = (key, options) => {
|
|
19
|
-
if (!(key in trafficStoreInstances)) {
|
|
20
|
-
if (!options) {
|
|
21
|
-
throw new Error('initialize with options first');
|
|
22
|
-
}
|
|
23
|
-
trafficStoreInstances[key] = new lru_cache_1.default({
|
|
24
|
-
max: options.limitCount,
|
|
25
|
-
maxSize: options.limitSize,
|
|
26
|
-
ttl: options.ttl,
|
|
27
|
-
allowStale: false,
|
|
28
|
-
updateAgeOnGet: false,
|
|
29
|
-
updateAgeOnHas: false,
|
|
30
|
-
sizeCalculation: (value) => (0, object_sizeof_1.default)(value),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return trafficStoreInstances[key];
|
|
34
|
-
};
|
|
35
|
-
exports.getTrafficStore = getTrafficStore;
|
|
36
|
-
const getDnsResolutionCache = (key) => {
|
|
37
|
-
if (!(key in dnsResolutionCacheInstances)) {
|
|
38
|
-
dnsResolutionCacheInstances[key] = new lru_cache_1.default(DNS_CACHE_OPTIONS);
|
|
39
|
-
}
|
|
40
|
-
return dnsResolutionCacheInstances[key];
|
|
41
|
-
};
|
|
42
|
-
exports.getDnsResolutionCache = getDnsResolutionCache;
|