-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93e4cea
commit 966176e
Showing
15 changed files
with
251 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
'use strict' | ||
'use strict'; | ||
|
||
/* UI Params */ | ||
const Params = [ | ||
] | ||
const Params = []; | ||
|
||
/* Metadata */ | ||
const Name = "Console Output"; | ||
const Icon = "icon.png"; | ||
const Name = 'Console Output'; | ||
const Icon = 'icon.png'; | ||
|
||
/* Route Class */ | ||
class ConsoleClass { | ||
|
||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
statusnotify(true) | ||
} | ||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
statusnotify(true); | ||
} | ||
} | ||
|
||
ConsoleClass.prototype.process = async function (payload) { | ||
console.log(payload) | ||
} | ||
console.log(payload); | ||
}; | ||
|
||
ConsoleClass.prototype.close = function (reason) { | ||
} | ||
ConsoleClass.prototype.close = function (reason) {}; | ||
|
||
module.exports = { | ||
"Route": ConsoleClass, | ||
"Inputs": Params, | ||
"Name": Name, | ||
"Icon": Icon | ||
} | ||
Route: ConsoleClass, | ||
Inputs: Params, | ||
Name: Name, | ||
Icon: Icon | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,62 @@ | ||
'use strict' | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
/* UI Params */ | ||
const Params = [ | ||
{ | ||
id: "directory", | ||
label: "Storage Location/Directoy" | ||
} | ||
] | ||
{ | ||
id: 'directory', | ||
label: 'Storage Location/Directoy' | ||
} | ||
]; | ||
|
||
/* Metadata */ | ||
const Name = "File Output"; | ||
const Icon = "icon.png"; | ||
const Name = 'File Output'; | ||
const Icon = 'icon.png'; | ||
|
||
/* Route Class */ | ||
class File { | ||
|
||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
this.Route = route; | ||
statusnotify(true) | ||
} | ||
|
||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
this.Route = route; | ||
statusnotify(true); | ||
} | ||
} | ||
|
||
File.prototype.process = async function (payload) { | ||
const JSONs = JSON.stringify(payload); | ||
|
||
let JSONs = JSON.stringify(payload); | ||
const Directory = this.Route.directory.replace( | ||
'{{AccessoryID}}', | ||
payload.accessory.AccessoryID | ||
); | ||
|
||
let Directory = this.Route.directory.replace("{{AccessoryID}}", payload.accessory.AccessoryID) | ||
if (!fs.existsSync(Directory)) { | ||
try { | ||
fs.mkdirSync(Directory, { recursive: true }); | ||
} catch (err) { | ||
console.log(' FILE Route error: ' + err); | ||
return; | ||
} | ||
} | ||
|
||
if (!fs.existsSync(Directory)) { | ||
try { | ||
fs.mkdirSync(Directory, { recursive: true }); | ||
} | ||
catch (err) { | ||
console.log(" FILE Route error: "+err) | ||
return; | ||
} | ||
} | ||
const DT = new Date().getTime(); | ||
const FileName = DT + '_' + payload.accessory.AccessoryID + '.json'; | ||
|
||
let DT = new Date().getTime(); | ||
let FileName = DT + '_' + payload.accessory.AccessoryID + ".json" | ||
const _Path = path.join(Directory, FileName); | ||
|
||
let _Path = path.join(Directory, FileName); | ||
try { | ||
fs.writeFileSync(_Path, JSONs, 'utf8'); | ||
} catch (err) { | ||
console.log(' FILE Route error: ' + err); | ||
} | ||
}; | ||
|
||
try { | ||
fs.writeFileSync(_Path, JSONs, 'utf8') | ||
} | ||
catch (err) { | ||
console.log(" FILE Route error: "+err) | ||
} | ||
} | ||
|
||
File.prototype.close = function (reason) { | ||
} | ||
File.prototype.close = function (reason) {}; | ||
|
||
module.exports = { | ||
"Route": File, | ||
"Inputs": Params, | ||
"Name": Name, | ||
"Icon": Icon | ||
} | ||
Route: File, | ||
Inputs: Params, | ||
Name: Name, | ||
Icon: Icon | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,53 @@ | ||
'use strict' | ||
const axios = require('axios') | ||
'use strict'; | ||
const axios = require('axios'); | ||
|
||
/* UI Params */ | ||
const Params = [ | ||
{ | ||
id: "destinationURI", | ||
label: "HTTP URI" | ||
} | ||
] | ||
{ | ||
id: 'destinationURI', | ||
label: 'HTTP URI' | ||
} | ||
]; | ||
|
||
/* Metadata */ | ||
const Name = "HTTP POST Output"; | ||
const Icon = "icon.png"; | ||
const Name = 'HTTP POST Output'; | ||
const Icon = 'icon.png'; | ||
|
||
/* Route Class */ | ||
class HTTPRoute { | ||
|
||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
this.Route = route | ||
statusnotify(true) | ||
} | ||
/* Constructor */ | ||
constructor(route, statusnotify) { | ||
this.Route = route; | ||
statusnotify(true); | ||
} | ||
} | ||
|
||
HTTPRoute.prototype.process = async function (payload) { | ||
|
||
let CFG = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'User-Agent': 'HAP Router' | ||
}, | ||
method: 'post', | ||
url: this.Route.destinationURI.replace('{{AccessoryID}}', payload.accessory.AccessoryID), | ||
data: payload | ||
} | ||
|
||
try{ | ||
let Res = await axios.request(CFG) | ||
} | ||
catch(err){ | ||
console.log(" HTTP Route error: "+err) | ||
} | ||
|
||
} | ||
|
||
HTTPRoute.prototype.close = function (reason) { | ||
} | ||
const CFG = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'User-Agent': 'HAP Router' | ||
}, | ||
method: 'post', | ||
url: this.Route.destinationURI.replace( | ||
'{{AccessoryID}}', | ||
payload.accessory.AccessoryID | ||
), | ||
data: payload | ||
}; | ||
|
||
try { | ||
await axios.request(CFG); | ||
} catch (err) { | ||
console.log(' HTTP Route error: ' + err); | ||
} | ||
}; | ||
|
||
HTTPRoute.prototype.close = function (reason) {}; | ||
|
||
module.exports = { | ||
"Route": HTTPRoute, | ||
"Inputs": Params, | ||
"Name": Name, | ||
"Icon": Icon | ||
} | ||
Route: HTTPRoute, | ||
Inputs: Params, | ||
Name: Name, | ||
Icon: Icon | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.