update API - part 1 (#709)

* api: `test-ontime` -> `version`

* api: `ontime-poll` -> `poll`

* api: `start-next` -> `startnext`

* api: `start-next` ->  `startnext`

---------

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
Alex Christoffer Rasmussen
2024-01-23 08:43:00 +01:00
committed by GitHub
parent cb8ba776e2
commit 0cd2ca4191
23 changed files with 432 additions and 393 deletions
+10 -2
View File
@@ -2,6 +2,7 @@ import express from 'express';
import { dispatchFromAdapter } from '../controllers/integrationController.js';
import { logger } from '../classes/Logger.js';
import { LogOrigin } from 'ontime-types';
import { objectFromPath } from '../adapters/utils/parse.js';
export const router = express.Router();
@@ -14,8 +15,15 @@ router.get('/', (_req, res) => {
// any GET request in /api is sent to the integration controller
router.get('/*', (req, res) => {
const action = req.path.substring(1);
const params = { payload: req.query };
let action = req.path.substring(1);
const actionArray = action.split('/');
const params = { payload: req.query as object };
if (actionArray.length > 1) {
action = actionArray.shift();
params.payload = objectFromPath(actionArray, params.payload);
}
try {
const reply = dispatchFromAdapter(action, params, 'http');