Change image API port, added TLS support, fixed content-type header

This commit is contained in:
Essem 2021-12-02 18:01:33 -06:00
parent 871979105c
commit 38e5a1d9f2
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
6 changed files with 12 additions and 10 deletions

View file

@ -1,5 +1,5 @@
# esmBot Image API
The esmBot image API is a combined HTTP and WebSocket API running on port 8080. The API supports very basic authentication, which is defined on the server via the PASS environment variable and is sent from the client via the Authentication header in both HTTP and WS requests.
The esmBot image API is a combined HTTP and WebSocket API running on port 3762. The API supports very basic authentication, which is defined on the server via the PASS environment variable and is sent from the client via the Authentication header in both HTTP and WS requests.
## HTTP

View file

@ -196,7 +196,8 @@ httpServer.on("request", async (req, res) => {
contentType = "image/webp";
break;
}
res.setHeader("Content-Type", contentType);
if (contentType) res.setHeader("Content-Type", contentType);
else res.setHeader("Content-Type", ext);
const data = jobs.get(id).data;
jobs.delete(id);
return res.end(data, (err) => {
@ -230,8 +231,8 @@ httpServer.on("error", (e) => {
console.error("An HTTP error occurred: ", e);
});
httpServer.listen(8080, () => {
log("HTTP and WS listening on port 8080");
httpServer.listen(3762, () => {
log("HTTP and WS listening on port 3762");
});
const runJob = (job, ws) => {