qcobjects-cli 2.4.64 → 2.4.66
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/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.4.
|
|
1
|
+
2.4.66
|
package/package.json
CHANGED
|
@@ -63,7 +63,6 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
63
63
|
};
|
|
64
64
|
if (typeof microservice.route.responseHeaders !== "undefined") {
|
|
65
65
|
headers = Object.assign(headers, microservice.route.responseHeaders);
|
|
66
|
-
console.log(headers);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
stream.respondWithFD(fd, headers);
|
|
@@ -74,8 +73,7 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
74
73
|
stream.end();
|
|
75
74
|
|
|
76
75
|
} catch (e) {
|
|
77
|
-
|
|
78
|
-
logger.debug("[ERROR] Something went wrong when trying to send the response as file " + fileName);
|
|
76
|
+
logger.warn("[ERROR] Something went wrong when trying to send the response as file " + fileName);
|
|
79
77
|
if (e.errno == -2) {
|
|
80
78
|
const headers = {
|
|
81
79
|
":status": 404,
|
|
@@ -96,7 +94,7 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
96
94
|
// read and send file content in the stream
|
|
97
95
|
let headers;
|
|
98
96
|
try {
|
|
99
|
-
|
|
97
|
+
logger.info("trying to read "+ fileName);
|
|
100
98
|
const fd = fs.openSync(fileName, "r");
|
|
101
99
|
const stat = fs.fstatSync(fd);
|
|
102
100
|
headers = {
|
|
@@ -107,7 +105,6 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
107
105
|
};
|
|
108
106
|
if (typeof microservice.route.responseHeaders !== "undefined") {
|
|
109
107
|
headers = Object.assign(headers, microservice.route.responseHeaders);
|
|
110
|
-
console.log(headers);
|
|
111
108
|
}
|
|
112
109
|
|
|
113
110
|
logger.debug("closing file " + fileName);
|
|
@@ -117,7 +114,7 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
117
114
|
|
|
118
115
|
stream.write(fs.readFileSync(fileName));
|
|
119
116
|
stream.on("close", () => {
|
|
120
|
-
|
|
117
|
+
logger.info("closing static file", fileName);
|
|
121
118
|
});
|
|
122
119
|
|
|
123
120
|
} catch (e){
|
|
@@ -129,10 +126,10 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
129
126
|
stream.writeHead(404, headers);
|
|
130
127
|
stream.write("<h1>404 - FILE NOT FOUND</h1>");
|
|
131
128
|
stream.on("close", () => {
|
|
132
|
-
|
|
129
|
+
logger.info("closing static file with error: ", fileName);
|
|
133
130
|
});
|
|
134
131
|
}
|
|
135
|
-
|
|
132
|
+
logger.warn(e);
|
|
136
133
|
stream.end();
|
|
137
134
|
}
|
|
138
135
|
stream.end();
|
|
@@ -171,7 +168,7 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
171
168
|
try {
|
|
172
169
|
resolve();
|
|
173
170
|
} catch (e) {
|
|
174
|
-
|
|
171
|
+
logger.warn("\u{1F926} Something went wrong \u{1F926} when trying to deliver a static path: " + microservice.fileName);
|
|
175
172
|
reject();
|
|
176
173
|
}
|
|
177
174
|
} else {
|
|
@@ -33,6 +33,14 @@
|
|
|
33
33
|
const path = require("path");
|
|
34
34
|
const absolutePath = path.resolve( __dirname, "./" );
|
|
35
35
|
const templatePath = path.resolve( __dirname, "./templates/apps/" )+"/";
|
|
36
|
+
const os = require("os");
|
|
37
|
+
const isWindows = ()=>{
|
|
38
|
+
return os.platform().toLowerCase().startsWith("win");
|
|
39
|
+
};
|
|
40
|
+
const isMac = ()=>{
|
|
41
|
+
return os.platform().toLowerCase().startsWith("darwin");
|
|
42
|
+
};
|
|
43
|
+
|
|
36
44
|
|
|
37
45
|
require("qcobjects");
|
|
38
46
|
|
|
@@ -53,11 +61,19 @@ class Main extends InheritClass {
|
|
|
53
61
|
case "self_signed":
|
|
54
62
|
// stderr is sent to stderr of parent process
|
|
55
63
|
// you can set options.stdio if you want it to go elsewhere
|
|
56
|
-
|
|
64
|
+
if (isWindows()){
|
|
65
|
+
stdout = execSync("openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj \"/CN="+CONFIG.get("domain")+"\" -keyout "+CONFIG.get("private-key-pem")+" -out "+CONFIG.get("private-cert-pem"));
|
|
66
|
+
} else {
|
|
67
|
+
stdout = execSync("openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN="+CONFIG.get("domain")+"' -keyout "+CONFIG.get("private-key-pem")+" -out "+CONFIG.get("private-cert-pem"));
|
|
68
|
+
}
|
|
57
69
|
break;
|
|
58
70
|
case "letsencrypt":
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
if (isWindows()){
|
|
72
|
+
throw Error("Letsencrypt certificate is not supported in Windows");
|
|
73
|
+
} else {
|
|
74
|
+
var prehook_posthook = "--pre-hook \"service qcobjects stop\" --post-hook=\"service qcobjects start\"";
|
|
75
|
+
stdout = execSync(`certbot -n -d ${CONFIG.get("domain")} certonly --standalone ${prehook_posthook}`);
|
|
76
|
+
}
|
|
61
77
|
break;
|
|
62
78
|
default:
|
|
63
79
|
break;
|