UNPKG

gypsum

Version:

Simple and easy lightweight typescript server side framework on Node.js.

31 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const api_types_1 = require("./api-types"); const response_codes_1 = require("./response-codes"); class Response { constructor(options) { this.rid = options.rid || null; this.data = options.data; this.code = options.code || (options.error ? options.error.code : response_codes_1.RESPONSE_CODES.OK); this.success = this.success !== undefined ? !!options.success : (this.code >= 200 && this.code < 300 ? true : false); this.domain = options.domain || 0; this.crud = options.crud || 'read'; this.apiType = options.apiType || api_types_1.API_TYPES.REST; this.service = options.event || ""; this.room = options.room || ""; this.type = options.type || 'json'; this.error = options.error; if (options.count !== undefined) this.count === options.count; else this.count = Array.isArray(this.data) ? this.data.length : (this.data ? 1 : 0); if (!this.count && this.data) { if (Array.isArray(this.data)) this.count = this.data.length; else this.count = 1; } } } exports.Response = Response; //# sourceMappingURL=response.js.map