Skip to content

Commit ccf198a

Browse files
committed
Print endpoints prettier 💅
1 parent 267b9b9 commit ccf198a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

‎src/parser/commands.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ import chalk from 'chalk';
44

55
export class Commands {
66
public static printEndpoints(endpoints: Endpoint[]) {
7-
const paths = endpoints.map((item) => {
8-
let path = item.type + ' ' + item.path;
9-
const queryKeys = Object.keys(item.query);
10-
if (queryKeys.length) {
11-
path += ' query: ' + queryKeys;
12-
}
13-
const bodyKeys = Object.keys(item.body);
14-
if (bodyKeys.length) {
15-
path += ' body: ' + bodyKeys;
16-
}
17-
return path;
7+
endpoints.forEach((endpoint) => {
8+
console.log(chalk.cyan('➜ ') + chalk.bold.cyan(endpoint.path));
9+
Object.keys(endpoint.body).length > 0 &&
10+
console.log(' ' + chalk.bold.yellow('body: ') + Object.keys(endpoint.body).join(', '));
11+
Object.keys(endpoint.query).length > 0 &&
12+
console.log(' ' + chalk.bold.yellow('query: ') + Object.keys(endpoint.query).join(', '));
13+
Object.keys(endpoint.headers).length > 0 &&
14+
console.log(' ' + chalk.bold.yellow('headers: ') + Object.keys(endpoint.headers).join(', '));
1815
});
19-
console.log(paths);
2016
}
2117

2218
public static generatePostmanCollection(collectionName: string, endpoints: Endpoint[]) {

0 commit comments

Comments
 (0)