Something went wrong on our end
Select Git revision
Monster.Constraints.AbstractConstraint.html
-
Volker Schukai authoredVolker Schukai authored
restapi.mjs 6.41 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 {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.
*
* @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.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