mastercontroller 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MasterCors.js +32 -17
- package/MasterRequest.js +5 -4
- package/package.json +8 -8
package/MasterCors.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// version 1.1.
|
|
1
|
+
// version 1.1.6
|
|
2
2
|
var master = require('./MasterControl');
|
|
3
|
+
var tools = require('./MasterTools');
|
|
4
|
+
|
|
3
5
|
// todo - res.setHeader('Access-Control-Request-Method', '*');
|
|
4
6
|
class MasterCors{
|
|
5
7
|
|
|
@@ -28,21 +30,29 @@ class MasterCors{
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
setHeader(header, value){
|
|
34
|
+
this.response.setHeader(header, value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
removeHeader(header){
|
|
38
|
+
this.response.removeHeader(header);
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
configureOrigin(){
|
|
32
42
|
// this will set the origin based on the the options value
|
|
33
43
|
if(this.options.origin){
|
|
34
44
|
var originBool = JSON.parse(this.options.origin);
|
|
35
45
|
if(originBool === true){
|
|
36
|
-
this.
|
|
46
|
+
this.setHeader('access-control-allow-origin', '*');
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
// remove all origins
|
|
40
50
|
if(originBool === false){
|
|
41
|
-
this.
|
|
51
|
+
this.removeHeader('access-control-allow-origin');
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
if(typeof this.options.origin === 'string'){
|
|
45
|
-
this.
|
|
55
|
+
this.setHeader('access-control-allow-arigin', this.options.origin);
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
if(this.options.origin.constructor === Array){
|
|
@@ -50,7 +60,7 @@ class MasterCors{
|
|
|
50
60
|
var requestURL = this.request.url;
|
|
51
61
|
for (const element of this.options.origin) {
|
|
52
62
|
if(element === requestURL){
|
|
53
|
-
this.
|
|
63
|
+
this.setHeader('access-control-allow-arigin', element);
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
|
|
@@ -63,33 +73,38 @@ class MasterCors{
|
|
|
63
73
|
if(this.options.methods){
|
|
64
74
|
if(this.options.methods.constructor === Array){
|
|
65
75
|
var elements = this.options.methods.join(", ");
|
|
66
|
-
this.
|
|
76
|
+
this.setHeader('access-control-allow-methods', elements);
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
configureAllowedHeaders(){
|
|
72
|
-
var requestheader = this.request.headers["
|
|
82
|
+
var requestheader = this.request.headers["access-control-request-headers"];
|
|
73
83
|
var $that = this;
|
|
74
84
|
if(this.options.allowedHeaders){
|
|
75
85
|
var allowedBool = JSON.parse($that.options.allowedHeaders);
|
|
76
86
|
if(allowedBool === true){
|
|
77
|
-
// get Access-Control-Request-Headers
|
|
78
|
-
|
|
87
|
+
// get Access-Control-Request-Headers
|
|
88
|
+
|
|
89
|
+
$that.request.headers['access-control-allow-headers'] = requestheader;
|
|
90
|
+
this.setHeader("access-control-allow-headers", "*");
|
|
79
91
|
}
|
|
80
92
|
|
|
81
93
|
// remove all headers
|
|
82
94
|
if(allowedBool === false){
|
|
83
|
-
delete $that.request.headers['
|
|
95
|
+
delete $that.request.headers['access-control-allow-headers'];
|
|
96
|
+
this.removeHeader("access-control-allow-headers", "*");
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
if($that.options.allowedHeaders === 'string'){
|
|
87
|
-
$that.request.headers['
|
|
100
|
+
$that.request.headers['access-control-allow-headers'] = $that.options.allowedHeaders;
|
|
101
|
+
this.setHeader("access-control-allow-headers", $that.options.allowedHeaders);
|
|
88
102
|
}
|
|
89
103
|
|
|
90
104
|
if($that.options.allowedHeaders.constructor === Array){
|
|
91
105
|
var elements = $that.options.allowedHeaders.join(", ");
|
|
92
|
-
$that.request.headers['
|
|
106
|
+
$that.request.headers['access-control-allow-headers'] = elements;
|
|
107
|
+
this.setHeader("access-control-allow-headers", elements);
|
|
93
108
|
}
|
|
94
109
|
|
|
95
110
|
}
|
|
@@ -102,16 +117,16 @@ class MasterCors{
|
|
|
102
117
|
var allowedBool = JSON.parse(this.options.exposeHeaders);
|
|
103
118
|
// remove all headers
|
|
104
119
|
if(allowedBool === false){
|
|
105
|
-
this.
|
|
120
|
+
this.removeHeader('access-control-expose-headers');
|
|
106
121
|
}
|
|
107
122
|
|
|
108
123
|
if(this.options.exposeHeaders === 'string'){
|
|
109
|
-
this.
|
|
124
|
+
this.setHeader('access-control-expose-headers', this.options.exposeHeaders);
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
if(this.options.exposeHeaders.constructor === Array){
|
|
113
128
|
var elements = this.options.exposeHeaders.join(", ");
|
|
114
|
-
this.
|
|
129
|
+
this.setHeader('access-control-expose-headers', elements);
|
|
115
130
|
}
|
|
116
131
|
|
|
117
132
|
}
|
|
@@ -121,7 +136,7 @@ class MasterCors{
|
|
|
121
136
|
if(this.options.credentials){
|
|
122
137
|
var credentialsBool = JSON.parse(this.options.credentials);
|
|
123
138
|
if(typeof credentialsBool === "boolean"){
|
|
124
|
-
this.
|
|
139
|
+
this.setHeader('access-control-allow-credentials', credentialsBool);
|
|
125
140
|
}
|
|
126
141
|
}
|
|
127
142
|
}
|
|
@@ -130,7 +145,7 @@ class MasterCors{
|
|
|
130
145
|
if(this.options.maxAge){
|
|
131
146
|
var maxAgeNumber = parseInt(this.options.maxAge);
|
|
132
147
|
if(typeof maxAgeNumber === "number"){
|
|
133
|
-
this.
|
|
148
|
+
this.setHeader('access-control-allow-max-age', maxAgeNumber);
|
|
134
149
|
}
|
|
135
150
|
}
|
|
136
151
|
}
|
package/MasterRequest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
// version 1.0.
|
|
2
|
+
// version 1.0.16
|
|
3
3
|
|
|
4
4
|
var master = require('./MasterControl');
|
|
5
5
|
var url = require('url');
|
|
@@ -87,13 +87,14 @@ class MasterRequest{
|
|
|
87
87
|
$that.textStream(request, function(data){
|
|
88
88
|
$that.parsedURL.formData = {};
|
|
89
89
|
$that.parsedURL.formData.textField = data;
|
|
90
|
-
resolve(
|
|
90
|
+
resolve($that.parsedURL);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
break
|
|
94
94
|
default:
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
var errorMessage = `Cannot parse - We currently support text/html, application/json, multipart/form-data, and application/x-www-form-urlencoded - your sending us = ${contentType.type}`;
|
|
96
|
+
resolve(errorMessage);
|
|
97
|
+
console.log(errorMessage);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_from": "mastercontroller@1.1.
|
|
3
|
-
"_id": "mastercontroller@1.1.
|
|
2
|
+
"_from": "mastercontroller@1.1.12",
|
|
3
|
+
"_id": "mastercontroller@1.1.12",
|
|
4
4
|
"_inBundle": false,
|
|
5
5
|
"_integrity": "sha512-dqqGXFn65iMzgGFKut8M5AuZ36Nm9UgJkqkuc8kr+/ESWKLAyMjEp0BOYhyupMplJ+8iSDmQ7BlIHyL4gaGr1A==",
|
|
6
6
|
"_location": "/mastercontroller",
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
"_requested": {
|
|
9
9
|
"type": "version",
|
|
10
10
|
"registry": true,
|
|
11
|
-
"raw": "mastercontroller@1.1.
|
|
11
|
+
"raw": "mastercontroller@1.1.12",
|
|
12
12
|
"name": "mastercontroller",
|
|
13
13
|
"escapedName": "mastercontroller",
|
|
14
|
-
"rawSpec": "1.1.
|
|
14
|
+
"rawSpec": "1.1.12",
|
|
15
15
|
"saveSpec": null,
|
|
16
|
-
"fetchSpec": "1.1.
|
|
16
|
+
"fetchSpec": "1.1.12"
|
|
17
17
|
},
|
|
18
18
|
"_requiredBy": [
|
|
19
19
|
"#USER",
|
|
20
20
|
"/"
|
|
21
21
|
],
|
|
22
|
-
"_resolved": "https://registry.npmjs.org/mastercontroller/-/mastercontroller-1.1.
|
|
22
|
+
"_resolved": "https://registry.npmjs.org/mastercontroller/-/mastercontroller-1.1.12.tgz",
|
|
23
23
|
"_shasum": "30bdeec92ece92441caca1659fe238ea78991e7c",
|
|
24
|
-
"_spec": "mastercontroller@1.1.
|
|
24
|
+
"_spec": "mastercontroller@1.1.12",
|
|
25
25
|
"_where": "C:\\Users\\rbatista\\Downloads\\kollege\\freshmen",
|
|
26
26
|
"author": {
|
|
27
27
|
"name": "Alexander Rich"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
51
51
|
},
|
|
52
|
-
"version": "1.1.
|
|
52
|
+
"version": "1.1.12"
|
|
53
53
|
}
|