Skip to content

Commit 7a43b2c

Browse files
author
Raymond Ottun
committed
fix: tlsoption fixed
1 parent 339a792 commit 7a43b2c

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

docs/content/en/start.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ npx @sayjava/deputy@latest
2121
<code-block label="Docker">
2222

2323
```bash
24-
docker run -p 8080:8080 -p 8081:8081 @sayjava/deputy
24+
docker run -p 8080:8080 -p 8081:8081 sayjava/deputy
2525
```
2626

2727
</code-block>
@@ -39,8 +39,8 @@ This command will:
3939
| \--port, -p | DEPUTY_PORT | 8080 | The port the mock sever runs on |
4040
| \--api-port, -ap | DEPUTY_API_PORT | 8081 | The port the api sever runs on |
4141
| \--auto-proxy, -px | DEPUTY_AUTO_PROXY | true | Auto proxy requests |
42-
| \--tls-enabled, -tls | DEPUTY_TLS_ENABLED | undefined | Enables HTTPs and auto generates a self-signed certificate |
43-
| \--tls-domains, -domains | DEPUTY_TLS_DOMAINS | undefined | Domain names that will be included in the certificate |
42+
| \--tls-enabled, -tls | DEPUTY_TLS | undefined | Enables HTTPs and auto generates a self-signed certificate |
43+
| \--tls-domains, -domains | DEPUTY_DOMAINS | undefined | Domain names that will be included in the certificate |
4444

4545
## Initialize Mocks
4646

src/deputy.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const logInfo = (config) => {
2929

3030
eth0.forEach((it) => {
3131
if (it.family === 'IPv4') {
32-
const protocol = config.tlsEnabled ? 'https' : 'http';
32+
const protocol = config.tls ? 'https' : 'http';
3333
const table = new Table({ head: ['Description', 'Url'] });
3434
routes.forEach(([desc, url]) => {
3535
table.push([desc, `http://${it.address}:${config.apiPort}${url}`]);
@@ -66,17 +66,16 @@ const args = yargs(hideBin(process.argv))
6666
describe: 'A directory containing .yml files definitions',
6767
default: process.env.DEPUTY_MOCKS_DIRECTORY || 'mocks',
6868
})
69-
.option('tls-enabled', {
69+
.option('tls', {
7070
type: 'boolean',
71-
alias: 'tls',
7271
describe: 'Enable HTTPS, Auto generate ssl certificates',
73-
default: process.env.DEPUTY_TSL_ENABLED || false,
72+
default: process.env.DEPUTY_TLS || false,
7473
})
75-
.option('tls-domains', {
74+
.option('domains', {
7675
type: 'string',
7776
alias: 'domains',
7877
describe: 'Specify domain to auto-generate certification for. localhost is auto included',
79-
default: process.env.DEPUTY_TSL_DOMAINS ? process.env.DEPUTY_TSL_DOMAINS.split(',') : [],
78+
default: process.env.DEPUTY_DOMAINS || '',
8079
}).argv;
8180

8281
const startServer = async () => {

src/server/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const defaultConfig: DeputyConfig = {
2020
apiPort: 8081,
2121
proxy: true,
2222
mocksDirectory: 'mocks',
23-
tlsEnabled: false,
24-
tslDomains: '',
23+
tls: false,
24+
domains: '',
2525
};
2626

2727
const createExpress = (): Express => {
@@ -73,7 +73,7 @@ export const createMockServer = async ({ engine, config }) => {
7373
const SERVER_TIMEOUT = 4000;
7474
const onTimeOut = () => logger.error('Request Timeout');
7575

76-
if (config.tlsEnabled) {
76+
if (config.tls) {
7777
const { cert, key } = await loadSSLCerts({ domains: config.tlsDomains });
7878
return https.createServer({ key, cert }, server).setTimeout(SERVER_TIMEOUT, onTimeOut);
7979
} else {
@@ -82,7 +82,7 @@ export const createMockServer = async ({ engine, config }) => {
8282
};
8383

8484
export const createServer = async (argConfig: DeputyConfig): Promise<App> => {
85-
const tlsDomains = (argConfig.tslDomains || '').split(',');
85+
const tlsDomains = (argConfig.domains || '').split(',');
8686
const config = Object.assign({}, defaultConfig, argConfig, { tlsDomains });
8787
const engine = createEngine(config);
8888

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ export interface DeputyConfig {
137137
apiPort?: number;
138138
port?: number;
139139
mocksDirectory?: string;
140-
tlsEnabled?: boolean;
140+
tls?: boolean;
141141
proxy?: boolean;
142-
tslDomains?: string;
142+
domains?: string;
143143
}
144144

145145
export interface MiddlewareConfig extends DeputyConfig {

0 commit comments

Comments
 (0)