forked from reelyactive/barnowl-minew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (29 loc) · 971 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Barnowl = require("barnowl");
const BarnowlMinew = require("barnowl-minew");
const express = require("express");
const http = require("http");
// Initialize Barnowl with mixing enabled
let barnowl = new Barnowl({ enableMixing: true });
// Create an Express app and HTTP server
let app = express();
let server = http.createServer(app);
// Start the server on port 3001
server.listen(3001, function () {
console.log("Listening on port 3001");
});
// Set up Barnowl-Minew listener options
let options = {
app: app,
express: express,
route: "/minew", // API endpoint
isPreOctetStream: false, // Set true for G1 firmware v2/3
};
// Add the Minew listener to Barnowl
barnowl.addListener(BarnowlMinew, {}, BarnowlMinew.HttpListener, options);
barnowl.on("visibilityEvent", (event) => {
console.log("Received data:", event);
});
// Simple root route for testing the server
app.get("/", (req, res) => {
res.send("Barnowl-Minew Server is running!");
});