mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
add necessary endpoint for http subscription
This commit is contained in:
@@ -54,6 +54,10 @@ export class DataProvider {
|
||||
return data.osc;
|
||||
}
|
||||
|
||||
static getHttp() {
|
||||
return data.http;
|
||||
}
|
||||
|
||||
static getAliases() {
|
||||
return data.aliases;
|
||||
}
|
||||
@@ -86,6 +90,11 @@ export class DataProvider {
|
||||
await this.persist();
|
||||
}
|
||||
|
||||
static async setHttp(newData) {
|
||||
data.http = { ...newData };
|
||||
await this.persist();
|
||||
}
|
||||
|
||||
static getRundown() {
|
||||
return [...data.rundown];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { PlaybackService } from '../services/PlaybackService.js';
|
||||
import { eventStore } from '../stores/EventStore.js';
|
||||
import { isDocker, resolveDbPath } from '../setup.js';
|
||||
import { oscIntegration } from '../services/integration-service/OscIntegration.js';
|
||||
import { httpIntegration } from '../services/integration-service/HttpIntegration.js';
|
||||
import { logger } from '../classes/Logger.js';
|
||||
import { deleteAllEvents, forceReset } from '../services/rundown-service/RundownService.js';
|
||||
|
||||
@@ -282,15 +283,23 @@ export const getOSC = async (req, res) => {
|
||||
res.status(200).send(osc);
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/ontime/http'
|
||||
// Returns -
|
||||
export const getHTTP = async (req, res) => {
|
||||
const http = DataProvider.getHttp();
|
||||
console.log('get http', http)
|
||||
res.status(200).send(http);
|
||||
};
|
||||
|
||||
export const postOscSubscriptions = async (req, res) => {
|
||||
if (failEmptyObjects(req.body, res)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const oscSubscriptions = req.body;
|
||||
const subscriptions = req.body;
|
||||
const oscSettings = DataProvider.getOsc();
|
||||
oscSettings.subscriptions = oscSubscriptions;
|
||||
oscSettings.subscriptions = subscriptions;
|
||||
await DataProvider.setOsc(oscSettings);
|
||||
|
||||
// TODO: this update could be more granular, checking that relevant data was changed
|
||||
@@ -303,6 +312,27 @@ export const postOscSubscriptions = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const postHttpSubscriptions = async (req, res) => {
|
||||
console.log('http post sub')
|
||||
if (failEmptyObjects(req.body, res)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const subscriptions = req.body;
|
||||
const httpSettings = DataProvider.getHttp();
|
||||
httpSettings.subscriptions = subscriptions;
|
||||
await DataProvider.setHttp(httpSettings);
|
||||
|
||||
const { message } = httpIntegration.init(httpSettings);
|
||||
logger.info(LogOrigin.Tx, message);
|
||||
|
||||
res.send(httpSettings).status(200);
|
||||
} catch (error) {
|
||||
res.status(400).send(error);
|
||||
}
|
||||
};
|
||||
|
||||
// Create controller for POST request to '/ontime/osc'
|
||||
// Returns ACK message
|
||||
export const postOSC = async (req, res) => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
getAliases,
|
||||
getInfo,
|
||||
getOSC,
|
||||
getHTTP,
|
||||
getSettings,
|
||||
getUserFields,
|
||||
getViewSettings,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
postNew,
|
||||
postOSC,
|
||||
postOscSubscriptions,
|
||||
postHttpSubscriptions,
|
||||
postSettings,
|
||||
postUserFields,
|
||||
postViewSettings,
|
||||
@@ -76,5 +78,11 @@ router.post('/osc', validateOSC, postOSC);
|
||||
// create route between controller and '/ontime/osc-subscriptions' endpoint
|
||||
router.post('/osc-subscriptions', validateSubscription, postOscSubscriptions);
|
||||
|
||||
// create route between controller and '/ontime/http' endpoint
|
||||
router.get('/http', getHTTP);
|
||||
|
||||
// create route between controller and '/ontime/osc-subscriptions' endpoint
|
||||
router.post('/http-subscriptions', validateSubscription, postHttpSubscriptions);
|
||||
|
||||
// create route between controller and '/ontime/new' endpoint
|
||||
router.post('/new', projectSanitiser, postNew);
|
||||
|
||||
Reference in New Issue
Block a user