@stuntman/shared 0.1.2 → 0.1.3

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/dist/config.js CHANGED
@@ -6,18 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.serverConfig = void 0;
7
7
  const _1 = require(".");
8
8
  const config_1 = __importDefault(require("config"));
9
- const defaults_1 = __importDefault(require("defaults"));
9
+ const path_1 = __importDefault(require("path"));
10
10
  // TODO safeguards & defaults
11
11
  const defaultConfig = {
12
12
  api: {
13
13
  disabled: false,
14
14
  port: _1.DEFAULT_API_PORT,
15
+ apiKeyReadOnly: null,
16
+ apiKeyReadWrite: null,
15
17
  },
16
18
  mock: {
17
19
  domain: _1.DEFAULT_MOCK_DOMAIN,
18
20
  externalDns: _1.EXTERNAL_DNS,
19
21
  port: _1.DEFAULT_MOCK_PORT,
20
22
  timeout: _1.DEFAULT_PROXY_TIMEOUT,
23
+ rulesPath: path_1.default.join(process.cwd(), 'rules'),
21
24
  },
22
25
  storage: {
23
26
  traffic: {
@@ -30,6 +33,7 @@ const defaultConfig = {
30
33
  disabled: false,
31
34
  },
32
35
  };
36
+ config_1.default.util.setModuleDefaults('stuntman', defaultConfig);
33
37
  let configFromFile = {};
34
38
  try {
35
39
  configFromFile = config_1.default.get('stuntman');
@@ -38,4 +42,4 @@ catch (error) {
38
42
  // eslint-disable-next-line no-console
39
43
  console.warn('unable to find correct config - starting with defaults');
40
44
  }
41
- exports.serverConfig = (0, defaults_1.default)(configFromFile, defaultConfig);
45
+ exports.serverConfig = configFromFile;
package/dist/index.d.ts CHANGED
@@ -123,6 +123,8 @@ export type WebGuiConfig = {
123
123
  export type ApiConfig = {
124
124
  port: number;
125
125
  disabled: boolean;
126
+ apiKeyReadWrite: string | null;
127
+ apiKeyReadOnly: string | null;
126
128
  };
127
129
  export type ClientConfig = {
128
130
  protocol?: 'http' | 'https';
@@ -138,6 +140,7 @@ export type MockConfig = {
138
140
  httpsCert?: string;
139
141
  timeout: number;
140
142
  externalDns: string[];
143
+ rulesPath: string;
141
144
  };
142
145
  export type StorageConfig = {
143
146
  limitCount: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stuntman/shared",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Stuntman - HTTP proxy / mock shared types and utils",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -33,18 +33,16 @@
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
35
  "config": "3.3.9",
36
- "defaults": "1.0.4",
37
36
  "pino": "8.10.0"
38
37
  },
39
38
  "devDependencies": {
40
- "@types/config": "3.3.0",
41
- "@types/defaults": "1.0.3"
39
+ "@types/config": "3.3.0"
42
40
  },
43
41
  "scripts": {
44
42
  "test": "echo \"Error: no test specified\" && exit 1",
45
43
  "clean": "rm -fr dist",
46
44
  "build": "tsc",
47
45
  "lint": "prettier --check . && eslint . --ext ts",
48
- "lint:fix": "prettier --write ./src && eslint ./src --ext ts --fix"
46
+ "lint:fix": "prettier --write ./{src,test} && eslint ./{src,test} --ext ts --fix"
49
47
  }
50
48
  }
package/src/config.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- RecursivePartial,
3
2
  ServerConfig,
4
3
  DEFAULT_API_PORT,
5
4
  DEFAULT_MOCK_DOMAIN,
@@ -11,7 +10,7 @@ import {
11
10
  DEFAULT_CACHE_TTL,
12
11
  } from '.';
13
12
  import config from 'config';
14
- import defaults from 'defaults';
13
+ import path from 'path';
15
14
 
16
15
  // TODO safeguards & defaults
17
16
 
@@ -19,12 +18,15 @@ const defaultConfig: ServerConfig = {
19
18
  api: {
20
19
  disabled: false,
21
20
  port: DEFAULT_API_PORT,
21
+ apiKeyReadOnly: null,
22
+ apiKeyReadWrite: null,
22
23
  },
23
24
  mock: {
24
25
  domain: DEFAULT_MOCK_DOMAIN,
25
26
  externalDns: EXTERNAL_DNS,
26
27
  port: DEFAULT_MOCK_PORT,
27
28
  timeout: DEFAULT_PROXY_TIMEOUT,
29
+ rulesPath: path.join(process.cwd(), 'rules'),
28
30
  },
29
31
  storage: {
30
32
  traffic: {
@@ -38,12 +40,14 @@ const defaultConfig: ServerConfig = {
38
40
  },
39
41
  };
40
42
 
41
- let configFromFile: RecursivePartial<ServerConfig> = {};
43
+ config.util.setModuleDefaults('stuntman', defaultConfig);
44
+
45
+ let configFromFile = {} as ServerConfig;
42
46
  try {
43
- configFromFile = config.get<RecursivePartial<ServerConfig>>('stuntman');
47
+ configFromFile = config.get<ServerConfig>('stuntman');
44
48
  } catch (error) {
45
49
  // eslint-disable-next-line no-console
46
50
  console.warn('unable to find correct config - starting with defaults');
47
51
  }
48
52
 
49
- export const serverConfig = defaults(configFromFile, defaultConfig) as ServerConfig;
53
+ export const serverConfig = configFromFile;
package/src/index.ts CHANGED
@@ -166,6 +166,8 @@ export type WebGuiConfig = {
166
166
  export type ApiConfig = {
167
167
  port: number;
168
168
  disabled: boolean;
169
+ apiKeyReadWrite: string | null;
170
+ apiKeyReadOnly: string | null;
169
171
  };
170
172
 
171
173
  export type ClientConfig = {
@@ -183,6 +185,7 @@ export type MockConfig = {
183
185
  httpsCert?: string;
184
186
  timeout: number;
185
187
  externalDns: string[];
188
+ rulesPath: string;
186
189
  };
187
190
 
188
191
  export type StorageConfig = {
@@ -0,0 +1 @@
1
+ // TODO
package/tsconfig.json CHANGED
@@ -11,6 +11,12 @@
11
11
  "skipLibCheck": true,
12
12
  "typeRoots": ["node_modules/@types"],
13
13
  "allowJs": true,
14
- "moduleResolution": "node16"
15
- }
14
+ "moduleResolution": "node16",
15
+ "types": ["node", "jest"]
16
+ },
17
+ "exclude": [
18
+ "jest.config.js",
19
+ "./dist/**",
20
+ "./test/**"
21
+ ]
16
22
  }