@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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/package.json +8 -6
  3. package/src/api/api.ts +69 -48
  4. package/src/api/utils.ts +26 -26
  5. package/src/api/validators.ts +44 -35
  6. package/src/api/webgui/rules.pug +4 -2
  7. package/src/api/webgui/style.css +3 -3
  8. package/src/api/webgui/traffic.pug +1 -0
  9. package/src/bin/stuntman.ts +2 -2
  10. package/src/ipUtils.ts +1 -1
  11. package/src/mock.ts +137 -153
  12. package/src/ruleExecutor.ts +2 -1
  13. package/src/rules/index.ts +5 -5
  14. package/src/storage.ts +2 -2
  15. package/dist/api/api.d.ts +0 -22
  16. package/dist/api/api.js +0 -188
  17. package/dist/api/utils.d.ts +0 -4
  18. package/dist/api/utils.js +0 -69
  19. package/dist/api/validators.d.ts +0 -3
  20. package/dist/api/validators.js +0 -118
  21. package/dist/api/webgui/rules.pug +0 -145
  22. package/dist/api/webgui/style.css +0 -28
  23. package/dist/api/webgui/traffic.pug +0 -37
  24. package/dist/bin/stuntman.d.ts +0 -2
  25. package/dist/bin/stuntman.js +0 -7
  26. package/dist/index.d.ts +0 -1
  27. package/dist/index.js +0 -5
  28. package/dist/ipUtils.d.ts +0 -17
  29. package/dist/ipUtils.js +0 -101
  30. package/dist/mock.d.ts +0 -30
  31. package/dist/mock.js +0 -321
  32. package/dist/requestContext.d.ts +0 -9
  33. package/dist/requestContext.js +0 -18
  34. package/dist/ruleExecutor.d.ts +0 -22
  35. package/dist/ruleExecutor.js +0 -187
  36. package/dist/rules/catchAll.d.ts +0 -2
  37. package/dist/rules/catchAll.js +0 -15
  38. package/dist/rules/echo.d.ts +0 -2
  39. package/dist/rules/echo.js +0 -15
  40. package/dist/rules/index.d.ts +0 -3
  41. package/dist/rules/index.js +0 -70
  42. package/dist/storage.d.ts +0 -4
  43. 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;