1 | const RequestList = require('./requestList');
|
2 |
|
3 | class Beau {
|
4 | constructor(doc) {
|
5 | this.defaults = {
|
6 | VERSION: 1,
|
7 | CACHE: false,
|
8 | HOST: '',
|
9 | PLUGINS: []
|
10 | };
|
11 |
|
12 |
|
13 | this.configKeys = Object.keys(this.defaults);
|
14 | this.config = this.loadConfig(doc, this.defaults);
|
15 | this.requests = new RequestList(doc, this.config);
|
16 | }
|
17 |
|
18 | loadConfig(doc, defaults = {}) {
|
19 | var result = defaults;
|
20 |
|
21 | Object.keys(doc)
|
22 | .filter(k => this.configKeys.indexOf(k.toUpperCase()) > -1)
|
23 | .forEach(k => result[k.toUpperCase()] = doc[k]);
|
24 |
|
25 | return result;
|
26 | }
|
27 | }
|
28 |
|
29 |
|
30 | module.exports = Beau;
|