Skip to content
Snippets Groups Projects
Select Git revision
  • 915588e010f77961f85da9fac12e3340b9b7d9a6
  • master default protected
  • 1.2.4
  • 1.2.3
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • v1.1.0
8 results

_header.scss

Blame
  • 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);
    
        }
    
        /**