Skip to content

Commit

Permalink
fix: domain fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Ottun committed Nov 21, 2021
1 parent 81fab8e commit 9505b30
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/deputy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const args = yargs(hideBin(process.argv))
default: process.env.DEPUTY_TSL_ENABLED || false,
})
.option('tls-domains', {
type: 'array',
alias: 'domain',
type: 'string',
alias: 'domains',
describe: 'Specify domain to auto-generate certification for. localhost is auto included',
default: process.env.DEPUTY_TSL_DOMAINS ? process.env.DEPUTY_TSL_DOMAINS.split(',') : [],
}).argv;
Expand Down
5 changes: 3 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultConfig: DeputyConfig = {
proxy: true,
mocksDirectory: 'mocks',
tlsEnabled: false,
tslDomains: [],
tslDomains: '',
};

const createExpress = (): Express => {
Expand Down Expand Up @@ -82,7 +82,8 @@ export const createMockServer = async ({ engine, config }) => {
};

export const createServer = async (argConfig: DeputyConfig): Promise<App> => {
const config = Object.assign({}, defaultConfig, argConfig);
const tlsDomains = (argConfig.tslDomains || '').split(',');
const config = Object.assign({}, defaultConfig, argConfig, { tlsDomains });
const engine = createEngine(config);

const mockServer = await createMockServer({ engine, config });
Expand Down
3 changes: 3 additions & 0 deletions src/server/routes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const createRequestRouter = ({ engine }: Props) => {
try {
// @ts-ignore
const verifications = req.payload;
if (!Array.isArray(verifications)) {
return next(new Error('Request body must be an array'));
}
const verified = verifications.map((verify: Verification) => engine.assert(verify));
const passed = verified.filter((res) => typeof res !== 'boolean');

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface DeputyConfig {
mocksDirectory?: string;
tlsEnabled?: boolean;
proxy?: boolean;
tslDomains?: Array<string>;
tslDomains?: string;
}

export interface MiddlewareConfig extends DeputyConfig {
Expand Down

0 comments on commit 9505b30

Please sign in to comment.