mirror of https://github.com/Seich/Beau.git
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:
parent
dbc7addb39
commit
23064040df
|
|
@ -185,14 +185,10 @@ Beau {
|
|||
"COOKIEJAR": false,
|
||||
"DEPENDENCIES": Set {},
|
||||
"ENDPOINT": "http://jsonplaceholder.typicode.com",
|
||||
"FORM": undefined,
|
||||
"FORMDATA": undefined,
|
||||
"HEADERS": Object {
|
||||
"authentication": "hello",
|
||||
},
|
||||
"PARAMS": undefined,
|
||||
"PATH": "/posts/1",
|
||||
"PAYLOAD": undefined,
|
||||
"REQUEST": "GET /posts/1",
|
||||
"VERB": "GET",
|
||||
"originalRequest": Object {
|
||||
|
|
@ -218,15 +214,11 @@ Beau {
|
|||
"COOKIEJAR": false,
|
||||
"DEPENDENCIES": Set {},
|
||||
"ENDPOINT": "http://jsonplaceholder.typicode.com",
|
||||
"FORM": undefined,
|
||||
"FORMDATA": undefined,
|
||||
"HEADERS": Object {
|
||||
"authentication": "hello",
|
||||
"hello": "world",
|
||||
},
|
||||
"PARAMS": undefined,
|
||||
"PATH": "/user",
|
||||
"PAYLOAD": undefined,
|
||||
"REQUEST": "GET /user",
|
||||
"VERB": "GET",
|
||||
"originalRequest": Object {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ class Config {
|
|||
this.doc = doc;
|
||||
|
||||
let config = this.loadConfig(doc);
|
||||
this.configKeys.forEach(k => {
|
||||
this[k] = config[k] || this.defaultConfigValues[k];
|
||||
});
|
||||
Object.assign(this, this.defaultConfigValues, config);
|
||||
|
||||
this.ENVIRONMENT = deepMerge(this.ENVIRONMENT, env);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,20 +14,8 @@ class Request {
|
|||
this.originalRequest = req;
|
||||
this.plugins = plugins;
|
||||
|
||||
this.loadCofiguration(
|
||||
[
|
||||
'REQUEST',
|
||||
'ENDPOINT',
|
||||
'HEADERS',
|
||||
'PAYLOAD',
|
||||
'PARAMS',
|
||||
'FORM',
|
||||
'ALIAS',
|
||||
'COOKIEJAR',
|
||||
'FORMDATA'
|
||||
],
|
||||
req
|
||||
);
|
||||
req = UpperCaseKeys(req);
|
||||
Object.assign(this, req);
|
||||
|
||||
if (!this.ALIAS) {
|
||||
throw new Error(`${this.REQUEST} is missing an alias.`);
|
||||
|
|
@ -41,13 +29,6 @@ class Request {
|
|||
this.DEPENDENCIES = this.findDependencies(req);
|
||||
}
|
||||
|
||||
loadCofiguration(keys, obj) {
|
||||
obj = UpperCaseKeys(obj);
|
||||
keys.forEach(k => {
|
||||
this[k] = obj[k];
|
||||
});
|
||||
}
|
||||
|
||||
parseRequest(request) {
|
||||
const parts = request.match(requestRegex);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue