Skip to content

Commit 50bd8e1

Browse files
authored
Merge pull request #570 from OpenHausIO/dev
Minor bug fixes
2 parents 6000c04 + 16210dc commit 50bd8e1

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

routes/router.api.endpoints.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ module.exports = (app, router) => {
3939
router.post("/:_id/commands/:_cid", (req, res) => {
4040
if (req.cmd) {
4141

42+
// fix #565
43+
if (Object.keys(req.body).length === 0 && req.body.constructor === Object) {
44+
req.body = [];
45+
}
46+
47+
if (!Array.isArray(req.body)) {
48+
return res.status(400).json({
49+
error: "Array expected in request body"
50+
});
51+
}
52+
4253
req.cmd.trigger(req.body, (err, success) => {
4354
if (err) {
4455
if (err.code === "NO_INTERFACE") {

system/init/init.database.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ module.exports = (logger) => {
7171

7272
}).catch((err) => {
7373

74+
logger.error(err, "Could not connecto to database");
75+
7476
if (err?.code == 13) {
7577
logger.error("Invalid database credentials!");
7678
}
7779

78-
mongodb.client.emit("error", err);
80+
//mongodb.client.emit("error", err);
7981
reject(err);
8082

8183
});

tests/http-api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("HTTP API", function () {
2121
silent: true,
2222
env: Object.assign({}, process.env, {
2323
UUID: crypto.randomUUID(),
24-
DATABASE_NAME: crypto.randomBytes(8).toString("hex"),
24+
//DATABASE_NAME: crypto.randomBytes(8).toString("hex"), // fix #560
2525
VAULT_MASTER_PASSWORD: crypto.randomBytes(24).toString("hex"),
2626
USERS_JWT_SECRET: crypto.randomBytes(24).toString("hex")
2727
})

0 commit comments

Comments
 (0)