@blaasvaer/frmwrk 0.2.4 → 0.2.5
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/handle-request.js +11 -8
- package/package.json +1 -1
package/handle-request.js
CHANGED
|
@@ -51,12 +51,12 @@ async function handleRequest( req, res ) {
|
|
|
51
51
|
*/
|
|
52
52
|
if (request_url.pathname === '/service-worker.js') {
|
|
53
53
|
// TODO: Set theme dynamically
|
|
54
|
-
var
|
|
54
|
+
var worker = path.join('', 'service-worker.js');
|
|
55
55
|
res.statusCode = 200;
|
|
56
56
|
res.setHeader('Content-Type', 'text/javascript');
|
|
57
57
|
|
|
58
|
-
if ( fs.existsSync(
|
|
59
|
-
fs.createReadStream(
|
|
58
|
+
if ( fs.existsSync( worker ) ) {
|
|
59
|
+
fs.createReadStream( worker ).pipe( res );
|
|
60
60
|
return;
|
|
61
61
|
} else {
|
|
62
62
|
return;
|
|
@@ -81,6 +81,13 @@ async function handleRequest( req, res ) {
|
|
|
81
81
|
|
|
82
82
|
let response_output = 'Nothing here …';
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Set Content Type
|
|
86
|
+
*/
|
|
87
|
+
if ( controller?.route?.params?.type ) {
|
|
88
|
+
content_type = controller?.route?.params?.type;
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
switch ( method ) {
|
|
85
92
|
case 'GET':
|
|
86
93
|
if ( ! controller.route.params?.authorize ) {
|
|
@@ -110,10 +117,6 @@ async function handleRequest( req, res ) {
|
|
|
110
117
|
// route.params.redirect.call();
|
|
111
118
|
// response_output = 'Access denied';
|
|
112
119
|
}
|
|
113
|
-
|
|
114
|
-
if ( controller.route.params.type ) {
|
|
115
|
-
content_type = controller.route.params.type;
|
|
116
|
-
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
res.statusCode = status_code;
|
|
@@ -145,7 +148,7 @@ async function handleRequest( req, res ) {
|
|
|
145
148
|
res.setHeader( 'Content-Type', content_types[content_type] );
|
|
146
149
|
|
|
147
150
|
// Cookies
|
|
148
|
-
res.setHeader( 'Set-Cookie','uuid=1234-1324-1234-1234-1234; Max-Age=3000; SameSite=lax; Secure' );
|
|
151
|
+
// res.setHeader( 'Set-Cookie','uuid=1234-1324-1234-1234-1234; Max-Age=3000; SameSite=lax; Secure' );
|
|
149
152
|
res.setHeader( 'Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, DELETE, OPTIONS' );
|
|
150
153
|
// res.setHeader( 'Content-Security-Policy', "default-src 'self'; img-src 'self';");
|
|
151
154
|
|