From f215aa4f91eed613a06338b2d8675a3104406e62 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Sat, 30 Sep 2023 19:47:53 +0200 Subject: [PATCH] fixup! chore(binding-http): enable eslint/strict-boolean-expressions --- packages/binding-http/src/http-server.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/binding-http/src/http-server.ts b/packages/binding-http/src/http-server.ts index 1bb209a18..4a012d251 100644 --- a/packages/binding-http/src/http-server.ts +++ b/packages/binding-http/src/http-server.ts @@ -418,10 +418,10 @@ export default class HttpServer implements ProtocolServer { } } - for (const actionName in thing.actions) { + for (const [actionName, action] of Object.entries(thing.actions)) { const actionNamePattern = Helpers.updateInteractionNameWithUriVariablePattern( actionName, - thing.actions[actionName].uriVariables, + action.uriVariables, thing.uriVariables ); const href = base + "/" + this.ACTION_DIR + "/" + actionNamePattern; @@ -432,18 +432,17 @@ export default class HttpServer implements ProtocolServer { ); form.op = ["invokeaction"]; const hform: HttpForm = form; - if (hform["htv:methodName"] === undefined) { - hform["htv:methodName"] = "POST"; - } - thing.actions[actionName].forms.push(form); + + hform["htv:methodName"] ??= "POST"; + action.forms.push(form); debug(`HttpServer on port ${this.getPort()} assigns '${href}' to Action '${actionName}'`); - this.addUrlRewriteEndpoints(form, thing.actions[actionName].forms); + this.addUrlRewriteEndpoints(form, action.forms); } - for (const eventName in thing.events) { + for (const [eventName, event] of Object.entries(thing.events)) { const eventNamePattern = Helpers.updateInteractionNameWithUriVariablePattern( eventName, - thing.events[eventName].uriVariables, + event.uriVariables, thing.uriVariables ); const href = base + "/" + this.EVENT_DIR + "/" + eventNamePattern; @@ -454,9 +453,9 @@ export default class HttpServer implements ProtocolServer { ); form.subprotocol = "longpoll"; form.op = ["subscribeevent", "unsubscribeevent"]; - thing.events[eventName].forms.push(form); + event.forms.push(form); debug(`HttpServer on port ${this.getPort()} assigns '${href}' to Event '${eventName}'`); - this.addUrlRewriteEndpoints(form, thing.events[eventName].forms); + this.addUrlRewriteEndpoints(form, event.forms); } } }