Stopped iterating over keys and started assigning instead. (#27)

I don't actually remember why I did it this way. I probably wanted to be
a lot more strict with the keys originally which seems silly in
retrospective.
This commit is contained in:
Sergio Díaz 2018-05-22 12:55:58 -06:00 committed by GitHub
parent dbc7addb39
commit 23064040df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 32 deletions

View File

@ -185,14 +185,10 @@ Beau {
"COOKIEJAR": false, "COOKIEJAR": false,
"DEPENDENCIES": Set {}, "DEPENDENCIES": Set {},
"ENDPOINT": "http://jsonplaceholder.typicode.com", "ENDPOINT": "http://jsonplaceholder.typicode.com",
"FORM": undefined,
"FORMDATA": undefined,
"HEADERS": Object { "HEADERS": Object {
"authentication": "hello", "authentication": "hello",
}, },
"PARAMS": undefined,
"PATH": "/posts/1", "PATH": "/posts/1",
"PAYLOAD": undefined,
"REQUEST": "GET /posts/1", "REQUEST": "GET /posts/1",
"VERB": "GET", "VERB": "GET",
"originalRequest": Object { "originalRequest": Object {
@ -218,15 +214,11 @@ Beau {
"COOKIEJAR": false, "COOKIEJAR": false,
"DEPENDENCIES": Set {}, "DEPENDENCIES": Set {},
"ENDPOINT": "http://jsonplaceholder.typicode.com", "ENDPOINT": "http://jsonplaceholder.typicode.com",
"FORM": undefined,
"FORMDATA": undefined,
"HEADERS": Object { "HEADERS": Object {
"authentication": "hello", "authentication": "hello",
"hello": "world", "hello": "world",
}, },
"PARAMS": undefined,
"PATH": "/user", "PATH": "/user",
"PAYLOAD": undefined,
"REQUEST": "GET /user", "REQUEST": "GET /user",
"VERB": "GET", "VERB": "GET",
"originalRequest": Object { "originalRequest": Object {

View File

@ -18,9 +18,7 @@ class Config {
this.doc = doc; this.doc = doc;
let config = this.loadConfig(doc); let config = this.loadConfig(doc);
this.configKeys.forEach(k => { Object.assign(this, this.defaultConfigValues, config);
this[k] = config[k] || this.defaultConfigValues[k];
});
this.ENVIRONMENT = deepMerge(this.ENVIRONMENT, env); this.ENVIRONMENT = deepMerge(this.ENVIRONMENT, env);

View File

@ -14,20 +14,8 @@ class Request {
this.originalRequest = req; this.originalRequest = req;
this.plugins = plugins; this.plugins = plugins;
this.loadCofiguration( req = UpperCaseKeys(req);
[ Object.assign(this, req);
'REQUEST',
'ENDPOINT',
'HEADERS',
'PAYLOAD',
'PARAMS',
'FORM',
'ALIAS',
'COOKIEJAR',
'FORMDATA'
],
req
);
if (!this.ALIAS) { if (!this.ALIAS) {
throw new Error(`${this.REQUEST} is missing an alias.`); throw new Error(`${this.REQUEST} is missing an alias.`);
@ -41,13 +29,6 @@ class Request {
this.DEPENDENCIES = this.findDependencies(req); this.DEPENDENCIES = this.findDependencies(req);
} }
loadCofiguration(keys, obj) {
obj = UpperCaseKeys(obj);
keys.forEach(k => {
this[k] = obj[k];
});
}
parseRequest(request) { parseRequest(request) {
const parts = request.match(requestRegex); const parts = request.match(requestRegex);