Skip to content

Commit

Permalink
Merge pull request #410 from mStirner/dev
Browse files Browse the repository at this point in the history
Working on issues
  • Loading branch information
mStirner committed Jan 12, 2024
2 parents d4de95a + 8d26179 commit c5520a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions postman.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "7b801daa-eb6a-407c-9c0c-66ac044ed8f3",
"_postman_id": "efc273f1-779c-4fce-a23e-82c17555ff65",
"name": "OpenHaus",
"description": "SmartHome/IoT application",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
Expand Down Expand Up @@ -2378,7 +2378,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Store item #1\",\n \"description\": \"Configuration settings for pluginx xyz\",\n \"_id\": \"65818986ca5133d8de2bb4a1\",\n \"config\": [{\n \"_id\": \"6581a14f1c6d01f32129dabc\",\n \"name\": \"Gateway Pairing\",\n \"key\": \"pairing\",\n \"type\": \"boolean\",\n \"value\": false,\n \"description\": \"Is the Gateway ready for pairing?\"\n }, {\n \"_id\": \"6581a1520bcb15659d48b207\",\n \"name\": \"Polling Interval\",\n \"key\": \"interval\",\n \"type\": \"number\",\n \"value\": 3000,\n \"description\": \"Sync intervall for Endpoints\"\n }]\n}",
"raw": "{\n \"_id\": \"65818986ca5133d8de2bb4a1\",\n \"name\": \"Store name\",\n \"config\": [{\n \"_id\": \"6581a14f1c6d01f32129dabc\",\n \"name\": \"Device Pairing\",\n \"key\": \"pairing\",\n \"type\": \"boolean\",\n \"value\": false,\n \"description\": \"Is the Gateway ready for pairing?\"\n }, {\n \"_id\": \"6581a1520bcb15659d48b207\",\n \"name\": \"Polling interval\",\n \"key\": \"interval\",\n \"type\": \"number\",\n \"value\": 3000,\n \"description\": \"Sync intervall for Endpoints\"\n }]\n}",
"options": {
"raw": {
"language": "json"
Expand Down
17 changes: 17 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { ServerResponse } = require("http");
const express = require("express");
const bodyParser = require("body-parser");

Expand Down Expand Up @@ -220,4 +221,20 @@ module.exports = (server) => {
// use express request handler
server.on("request", app);

// fix #408, see:
// https://github.com/OpenHausIO/connector/issues/38
// https://github.com/websockets/ws/issues/2193
server.on("upgrade", (req, socket) => {

let res = new ServerResponse(req);
res.assignSocket(socket);

res.on("finish", () => {
res.socket.destroy();
});

app(req, res);

});

};
2 changes: 1 addition & 1 deletion tests/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("HTTP API", function () {
silent: true,
env: Object.assign({}, process.env, {
UUID: crypto.randomUUID(),
DATABASE_NAME: "/test",
DATABASE_NAME: "test",
VAULT_MASTER_PASSWORD: crypto.randomBytes(24).toString("hex"),
USERS_JWT_SECRET: crypto.randomBytes(24).toString("hex")
})
Expand Down

0 comments on commit c5520a7

Please sign in to comment.