Skip to content

Commit

Permalink
chore(copy format): minor copy and formatting
Browse files Browse the repository at this point in the history
* remove verbose logs, slightly different formatting for copy
  • Loading branch information
cdcabrera committed Jul 26, 2018
1 parent 8549097 commit 348aad7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apidoc-mock",
"version": "1.0.1",
"version": "1.0.2",
"description": "Creates a mock server from apiDoc comments.",
"author": "cdcabrera",
"private": true,
Expand Down
22 changes: 9 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ class LoadApi {
try {
result = apidoc.createDoc(apiDocsConfig);
} catch (e) {
console.error(`ApiDoc error...${e.message}`);
console.error(`ApiDoc error...\t${e.message}`);
}

if (result === false) {
console.error('ApiDoc error... exiting.');
console.error('ApiDoc error...\texiting.');
return;
}

console.info('ApiDoc finished... loading JSON');
console.info('ApiDoc finished...\tloading JSON');
return JSON.parse(fs.readFileSync(apiJsonFile, 'utf8'));
}

Expand Down Expand Up @@ -307,7 +307,6 @@ class LoadApi {
try {
const successExamples = (value.success && value.success.examples) || [];
const errorExamples = (value.error && value.error.examples) || [];
const hasNoExamples = !successExamples.length && !errorExamples.length;
const mockSettings = LoadApi.parseMockSettings(value);
const successObjects = LoadApi.parseStatus(
successExamples,
Expand Down Expand Up @@ -363,7 +362,7 @@ class LoadApi {
authExample.type
);

console.info(`Response :${value.type}\t:${value.url}\t:401`);
console.info(`Response :401 :${value.type}\t:${value.url}`);

response.append('WWW-Authenticate', 'Spoof response');
response.status(401);
Expand All @@ -376,28 +375,25 @@ class LoadApi {
}
}

console.info(`Response :${value.type}\t:${value.url}\t:${httpStatus}`);
console.info(`Response :${httpStatus} :${value.type}\t:${value.url}`);

response.set('Content-Type', type);
response.status(httpStatus);
response.send(content);
});

routesLoaded += 1;
console.info(
`Loading "${value.type}" route ${value.url}... ${
hasNoExamples ? 'No examples found, using fallback response' : ''
}`
);
} catch (e) {
console.warn(e.message);
}
});

if (routesLoaded) {
this.app.listen(port, () => console.info(`Mock server listening on port ${port}`));
this.app.listen(port, () =>
console.info(`JSON finished...\tloaded routes\nMock finished...\tforwarded port ${port}`)
);
} else {
console.info(`Mock server waiting...`);
console.info(`Mock waiting...`);
}
}
}
Expand Down

0 comments on commit 348aad7

Please sign in to comment.