SponsorBlockServer/test/mocks.ts

61 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-07-12 08:43:46 +02:00
import express from "express";
2021-09-23 00:52:35 +02:00
import { config } from "../src/config";
2021-07-12 08:43:46 +02:00
import { Server } from "http";
import { UserCounter } from "./mocks/UserCounter";
2020-10-17 20:56:54 +02:00
const app = express();
app.post("/webhook/ReportChannel", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
app.post("/webhook/FirstTimeSubmissions", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
2023-02-22 06:08:27 +01:00
});
app.post("/webhook/WarningWebhook", (req, res) => {
res.sendStatus(200);
2020-10-17 20:56:54 +02:00
});
app.post("/webhook/CompletelyIncorrectReport", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
// Testing NeuralBlock
app.post("/webhook/NeuralBlockReject", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
2021-07-12 08:43:46 +02:00
app.get("/NeuralBlock/api/checkSponsorSegments", (req, res) => {
2020-10-17 20:56:54 +02:00
if (req.query.vid === "LevkAjUE6d4") {
res.json({
probabilities: [0.69],
});
return;
}
res.sendStatus(500);
});
//getSponsorSegments is no longer being used for automod
2021-07-12 08:43:46 +02:00
app.get("/NeuralBlock/api/getSponsorSegments", (req, res) => {
2020-10-17 20:56:54 +02:00
if (req.query.vid === "LevkAjUE6d4") {
res.json({
sponsorSegments: [[0.47, 7.549], [264.023, 317.293]],
});
return;
}
res.sendStatus(500);
});
// Testing webhooks
2021-07-12 08:43:46 +02:00
app.post("/CustomWebhook", (req, res) => {
2020-10-17 20:56:54 +02:00
res.sendStatus(200);
});
// mocks
app.use("/UserCounter", UserCounter);
2021-07-05 09:14:05 +02:00
export function createMockServer(callback: () => void): Server {
2020-10-17 20:56:54 +02:00
return app.listen(config.mockPort, callback);
}