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