Something went wrong on our end
Select Git revision
_header.scss
-
Volker Schukai authoredVolker Schukai authored
restapi.mjs 8.24 KiB
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../constants.mjs";
import {isObject} from "../../types/is.mjs";
import {Datasource} from "../datasource.mjs";
import {Pathfinder} from "../pathfinder.mjs";
import {Pipe} from "../pipe.mjs";
import {WriteError} from "./restapi/writeerror.mjs";
export {RestAPI}
/**
* The RestAPI is a class that enables a REST API server.
*
* ```
* <script type="module">
* import {RestAPI} from '@schukai/monster/source/data/datasource/restapi.mjs';
* new RestAPI()
* </script>
* ```
*
* @example
*
* import {RestAPI} from '@schukai/monster/source/data/datasource/restapi.mjs';
*
* const ds = new RestAPI({
* url: 'https://httpbin.org/get'
* },{
* url: 'https://httpbin.org/post'
* });
*
* ds.set({flag:true})
* ds.write().then(()=>console.log('done'));
* ds.read().then(()=>console.log('done'));
*
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource
* @summary The LocalStorage class encapsulates the access to data objects.
*/
class RestAPI extends Datasource {
/**
*
* @param {Object} [readDefinition] An options object containing any custom settings that you want to apply to the read request.
* @param {Object} [writeDefinition] An options object containing any custom settings that you want to apply to the write request.
* @throws {TypeError} value is not a string
*/
constructor(readDefinition, writeDefinition) {
super();
const options = {}
if (isObject(readDefinition)) options.read = readDefinition;
if (isObject(writeDefinition)) options.write = writeDefinition;
this.setOptions(options);
}
/**