Skip to content

Commit

Permalink
Add fjadapter
Browse files Browse the repository at this point in the history
  • Loading branch information
frankjoke committed Apr 8, 2021
1 parent 4946353 commit 0238b19
Show file tree
Hide file tree
Showing 5 changed files with 3,743 additions and 2,296 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"eslint.enable": true
"eslint.enable": true,
"i18n-ally.localesPaths": [
"src/locales"
]
}
32 changes: 16 additions & 16 deletions acceptdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// The adapter-core module gives you access to the core ioBroker functions
// you need to create an adapter
const utils = require("@iobroker/adapter-core");
const A = require("./fjadapter.js");
const express = require("express");
const bodyParser = require("body-parser");
const getRawBody = require("raw-body");
const { inspect } = require("util");
const app = express();

Expand Down Expand Up @@ -251,7 +253,7 @@ class Acceptdata extends utils.Adapter {
// })
// );

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
Expand All @@ -271,8 +273,7 @@ class Acceptdata extends utils.Adapter {
if (!name) name = path;
if (enabled) {
convert = convert || "$";
if (typeof path == "string" && path.startsWith("/"))
path = path.slice(1);
if (typeof path == "string" && path.startsWith("/")) path = path.slice(1);
this.log.info(
`Installed ${name} path: '${path}' with ${method}-method and convert: ${convert}`
);
Expand Down Expand Up @@ -358,16 +359,17 @@ class Acceptdata extends utils.Adapter {
}

app.get("/*", (request, response) => {
this.log.debug(
"get unknown data received for '" +
request._parsedUrl.pathname +
"' with " +
inspect(request.query, {
depth: 2,
color: true,
})
);
response.send("success");
const str =
"get unknown path '" +
request._parsedUrl.pathname +
"' with " +
inspect(request.query, {
depth: 2,
color: true,
});

this.log.debug(str);
response.send(str);
// response.send("Hello from Express!");
});

Expand Down Expand Up @@ -420,9 +422,7 @@ class Acceptdata extends utils.Adapter {
if (state) {
if (!state.from.endsWith(this.namespace))
// The state was changed from somebody else!
this.log.info(
`state ${id} changed: ${state.val} (ack = ${state.ack}, from=${state.from})`
);
this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack}, from=${state.from})`);
} else {
// The state was deleted
this.log.info(`state ${id} deleted`);
Expand Down
Loading

0 comments on commit 0238b19

Please sign in to comment.