Allow webhook connections
This commit is contained in:
parent
3e2e31e4a4
commit
aed9113b8d
2 changed files with 19 additions and 0 deletions
|
@ -2,6 +2,7 @@ require('dotenv').config();
|
|||
const express = require('express');
|
||||
const { createServer } = require('node:http');
|
||||
const { Server } = require('socket.io');
|
||||
const { fork } = require("child_process");
|
||||
|
||||
const app = express();
|
||||
const server = createServer(app);
|
||||
|
@ -15,6 +16,23 @@ io.on('connection', (socket) => {
|
|||
})
|
||||
});
|
||||
|
||||
app.get("/webscrobbler", (req, res) => {
|
||||
res.status(204).end();
|
||||
})
|
||||
|
||||
app.post("/webscrobbler", (req, res) => {
|
||||
if (req.query.password === process.env.NOTIFICATION_SERVER_PASSWORD) {
|
||||
const process = fork("./index.js");
|
||||
process.on('error', function (err) {
|
||||
res.status(500).end();
|
||||
});
|
||||
process.on('exit', function (code) {
|
||||
res.status(204).end();
|
||||
});
|
||||
}
|
||||
else res.status(403).end();
|
||||
})
|
||||
|
||||
server.listen(process.env.NOTIFICATION_SERVER_PORT, () => {
|
||||
console.log(`server running on port ${process.env.NOTIFICATION_SERVER_PORT}`);
|
||||
});
|
|
@ -9,6 +9,7 @@
|
|||
"author": "abtmtr.link",
|
||||
"license": "KKPL-2.2",
|
||||
"dependencies": {
|
||||
"child_process": "^1.0.2",
|
||||
"commander": "^12.0.0",
|
||||
"dotenv": "^16.4.4",
|
||||
"express": "^4.18.2",
|
||||
|
|
Loading…
Reference in a new issue