Skip to content
Snippets Groups Projects
Select Git revision
  • c588de0df48c3f382f51f1049c7adf883c0ef988
  • master default protected
  • 0.5.9
  • 0.5.8
  • 0.5.7
  • 0.5.6
  • 0.5.5
  • 0.5.4
  • 0.5.3
  • 0.5.2
  • 0.5.1
  • 0.5.0
  • 0.4.17
  • 0.4.16
  • 0.4.15
  • 0.4.14
  • 0.4.13
  • 0.4.12
  • 0.4.11
  • 0.4.10
  • 0.4.9
  • 0.4.8
22 results

test.html

Blame
  • restapi.mjs 6.84 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, instanceSymbol } from "../../../constants.mjs";
    import { isObject } from "../../../types/is.mjs";
    import { Server } from "../server.mjs";
    import { WriteError } from "./restapi/writeerror.mjs";
    
    export { RestAPI };
    
    /**
     * The RestAPI is a class that enables a REST API server.
     *
     * @externalExample ../../../../example/data/datasource/server/restapi.mjs
     * @license AGPLv3
     * @since 1.22.0
     * @copyright schukai GmbH
     * @memberOf Monster.Data.Datasource.Server
     * @summary The RestAPI is a class that binds a REST API server.
     */
    class RestAPI extends Server {
        /**
         *
         * @param {Object} [options] options contains definitions for the datasource.
         */
        constructor(options) {
            super();
    
            if (isObject(options)) {
                this.setOptions(options);
            }
        }
    
        /**
         * This method is called by the `instanceof` operator.
         * @returns {symbol}
         * @since 2.1.0
         */
        static get [instanceSymbol]() {
            return Symbol.for("@schukai/monster/data/datasource/server/restapi");
        }
    
        /**
         * @property {Object} write={} Options
         * @property {Object} write.init={} An options object containing any custom settings that you want to apply to the request. The parameters are identical to those of the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request|Request constructor}
         * @property {string} write.init.method=POST
         * @property {Object} write.init.headers Object containing any custom headers that you want to apply to the request.
         * @property {string} write.responseCallback Callback function to be executed after the request has been completed.
         * @property {string} write.acceptedStatus=[200,201]
         * @property {string} write.url URL
         * @property {Object} write.mapping the mapping is applied before writing.
         * @property {String} write.mapping.transformer Transformer to select the appropriate entries
         * @property {Monster.Data.Datasource~exampleCallback[]} write.mapping.callback with the help of the callback, the structures can be adjusted before writing.
         * @property {Object} write.report
         * @property {String} write.report.path Path to validations
         * @property {Object} write.sheathing
         * @property {Object} write.sheathing.object Object to be wrapped
         * @property {string} write.sheathing.path Path to the data
         * @property {Object} read={} Options
         * @property {Object} read.init={} An options object containing any custom settings that you want to apply to the request. The parameters are identical to those of the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request|Request constructor}
         * @property {string} read.init.method=GET
         * @property {string} read.acceptedStatus=[200]
         * @property {string} read.url URL
         * @property {Object} read.mapping the mapping is applied after reading.
         * @property {String} read.mapping.transformer Transformer to select the appropriate entries
         * @property {Monster.Data.Datasource~exampleCallback[]} read.mapping.callback with the help of the callback, the structures can be adjusted after reading.