Skip to content

Commit 6131e0b

Browse files
committed
chore: implement parsing of YAML config
1 parent d41c1e6 commit 6131e0b

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
},
1010
"keywords": [],
1111
"author": "Slava Semushin <slava.semushin@gmail.com>",
12-
"license": "GPL-2.0"
12+
"license": "GPL-2.0",
13+
"dependencies": {
14+
"js-yaml": "~3.14.0"
15+
}
1316
}

src/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
console.log('Generate code');
1+
const yaml = require('js-yaml');
2+
const fs = require('fs');
3+
4+
const file = 'endpoints.yaml';
5+
console.log('Read', file);
6+
7+
try {
8+
9+
const content = fs.readFileSync(file, 'utf8');
10+
const config = yaml.safeLoad(content);
11+
//console.debug(config);
12+
console.log('Generate code');
13+
for (let endpoint of config) {
14+
console.log('GET', endpoint.path, '=>', endpoint.get);
15+
}
16+
17+
} catch (ex) {
18+
console.error('Failed to parse', file);
19+
}

0 commit comments

Comments
 (0)