UNPKG

azurite

Version:

An open source Azure Storage API compatible server

80 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Context holds generated server context information. * Every incoming HTTP request will initialize a new context. * * @export * @class Context */ class Context { constructor(holderOrContext, path = "context", req, res) { if (holderOrContext instanceof Context) { this.context = holderOrContext.context; this.path = holderOrContext.path; } else { const context = holderOrContext; this.path = path; if (context[this.path] === undefined) { context[this.path] = {}; } if (typeof context[this.path] !== "object") { throw new TypeError(`Initialize Context error because holder.${this.path} is not an object.`); } this.context = context[this.path]; this.request = req; this.response = res; } } get operation() { return this.context.operation; } set operation(operation) { this.context.operation = operation; } set request(request) { this.context.request = request; } get request() { return this.context.request; } get dispatchPattern() { return this.context.dispatchPattern; } set dispatchPattern(path) { this.context.dispatchPattern = path; } set response(response) { this.context.response = response; } get response() { return this.context.response; } get handlerParameters() { return this.context.handlerParameters; } set handlerParameters(handlerParameters) { this.context.handlerParameters = handlerParameters; } get handlerResponses() { return this.context.handlerResponses; } set handlerResponses(handlerResponses) { this.context.handlerResponses = handlerResponses; } get contextId() { return this.context.contextID; } set contextId(contextID) { this.context.contextID = contextID; } set startTime(startTime) { this.context.startTime = startTime; } get startTime() { return this.context.startTime; } } exports.default = Context; //# sourceMappingURL=Context.js.map