Source: components/restmodules/LiveStreamRestModule.js

import { API } from '../../LocalConfiguration';
import { errors, handleErrors } from "./RestModuleAPI";
import isUUID from 'validator/lib/isUUID';

const path = API + "/livestream";
/**
 * Livestream Rest API
 * @module LiveStreamRestModule
 */

/**
 * Returns new stream session.
 * @param deviceId
 * @returns {Promise<void | never>}
 */
export function getNewStreamSession(deviceId) {
  if (!isUUID(deviceId)) {
    throw new Error(errors.invalidUUI);
  }

  return fetch(path + "/" + deviceId)
  .then(response => handleErrors(response))
  .then(response => response.json());
}