@oino-ts/types 0.0.17 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/db/src/OINODb.d.ts +180 -0
  2. package/db/src/OINODbApi.d.ts +82 -0
  3. package/db/src/OINODbConfig.d.ts +52 -0
  4. package/db/src/OINODbDataField.d.ts +202 -0
  5. package/db/src/OINODbDataModel.d.ts +108 -0
  6. package/db/src/OINODbDataSet.d.ts +95 -0
  7. package/db/src/OINODbFactory.d.ts +35 -0
  8. package/db/src/OINODbModelSet.d.ts +51 -0
  9. package/db/src/OINODbParser.d.ts +53 -0
  10. package/db/src/OINODbRequestParams.d.ts +146 -0
  11. package/db/src/OINODbSqlParams.d.ts +147 -0
  12. package/db/src/OINODbSwagger.d.ts +25 -0
  13. package/db/src/index.d.ts +111 -0
  14. package/db-bunsqlite/src/OINODbBunSqlite.d.ts +77 -0
  15. package/db-bunsqlite/src/index.d.ts +1 -0
  16. package/db-mariadb/src/OINODbMariadb.d.ts +78 -0
  17. package/db-mariadb/src/index.d.ts +1 -0
  18. package/db-mssql/src/OINODbMsSql.d.ts +86 -0
  19. package/db-mssql/src/index.d.ts +1 -0
  20. package/db-postgresql/src/OINODbPostgresql.d.ts +76 -0
  21. package/db-postgresql/src/index.d.ts +1 -0
  22. package/hashid/src/OINOHashid.d.ts +40 -0
  23. package/hashid/src/index.d.ts +1 -0
  24. package/index.d.ts +23 -0
  25. package/package.json +5 -8
  26. package/README.md +0 -193
  27. package/dist/cjs/OINOBenchmark.js +0 -108
  28. package/dist/cjs/OINOHtmlTemplate.js +0 -177
  29. package/dist/cjs/OINOLog.js +0 -140
  30. package/dist/cjs/OINOResult.js +0 -216
  31. package/dist/cjs/OINOStr.js +0 -265
  32. package/dist/cjs/index.js +0 -40
  33. package/dist/esm/OINOBenchmark.js +0 -104
  34. package/dist/esm/OINOHtmlTemplate.js +0 -173
  35. package/dist/esm/OINOLog.js +0 -135
  36. package/dist/esm/OINOResult.js +0 -211
  37. package/dist/esm/OINOStr.js +0 -261
  38. package/dist/esm/index.js +0 -29
  39. package/src/OINOBenchmark.ts +0 -112
  40. package/src/OINOHtmlTemplate.ts +0 -186
  41. package/src/OINOLog.ts +0 -160
  42. package/src/OINOResult.ts +0 -234
  43. package/src/OINOStr.ts +0 -254
  44. package/src/index.ts +0 -31
  45. /package/{dist/types → common/src}/OINOBenchmark.d.ts +0 -0
  46. /package/{dist/types → common/src}/OINOHtmlTemplate.d.ts +0 -0
  47. /package/{dist/types → common/src}/OINOLog.d.ts +0 -0
  48. /package/{dist/types → common/src}/OINOResult.d.ts +0 -0
  49. /package/{dist/types → common/src}/OINOStr.d.ts +0 -0
  50. /package/{dist/types → common/src}/index.d.ts +0 -0
@@ -1,108 +0,0 @@
1
- "use strict";
2
- /*
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.OINOBenchmark = void 0;
9
- /**
10
- * Static class for benchmarking functions.
11
- *
12
- */
13
- class OINOBenchmark {
14
- static _benchmarkCount = {};
15
- static _benchmarkData = {};
16
- static _benchmarkEnabled = {};
17
- static _benchmarkStart = {};
18
- /**
19
- * Reset benchmark data (but not what is enabled).
20
- *
21
- */
22
- static reset() {
23
- this._benchmarkData = {};
24
- this._benchmarkCount = {};
25
- }
26
- /**
27
- * Set benchmark names that are enabled.
28
- *
29
- * @param module array of those benchmarks that are enabled
30
- */
31
- static setEnabled(module) {
32
- this._benchmarkEnabled = {};
33
- module.forEach(module_name => {
34
- this._benchmarkEnabled[module_name] = true;
35
- });
36
- }
37
- /**
38
- * Start benchmark timing.
39
- *
40
- * @param module of the benchmark
41
- * @param method of the benchmark
42
- */
43
- static start(module, method) {
44
- const name = module + "." + method;
45
- if (this._benchmarkEnabled[module]) {
46
- if (this._benchmarkCount[name] == undefined) {
47
- this._benchmarkCount[name] = 0;
48
- this._benchmarkData[name] = 0;
49
- }
50
- this._benchmarkStart[name] = performance.now();
51
- }
52
- }
53
- /**
54
- * Complete benchmark timing
55
- *
56
- * @param module of the benchmark
57
- * @param method of the benchmark
58
- * @param category optional subcategory of the benchmark
59
- */
60
- static end(module, method, category) {
61
- const name = module + "." + method;
62
- let result = 0;
63
- if (this._benchmarkEnabled[module]) {
64
- const duration = performance.now() - this._benchmarkStart[name];
65
- this._benchmarkCount[name] += 1;
66
- this._benchmarkData[name] += duration;
67
- if (category) {
68
- const category_name = name + "." + category;
69
- if (this._benchmarkCount[category_name] == undefined) {
70
- this._benchmarkCount[category_name] = 0;
71
- this._benchmarkData[category_name] = 0;
72
- }
73
- this._benchmarkCount[category_name] += 1;
74
- this._benchmarkData[category_name] += duration;
75
- }
76
- result = this._benchmarkData[name] / this._benchmarkCount[name];
77
- }
78
- return result;
79
- }
80
- /**
81
- * Get given benchmark data.
82
- *
83
- * @param module of the benchmark
84
- * @param method of the benchmark
85
- *
86
- */
87
- static get(module, method) {
88
- const name = module + "." + method;
89
- if (this._benchmarkEnabled[module]) {
90
- return this._benchmarkData[module] / this._benchmarkCount[module];
91
- }
92
- return -1;
93
- }
94
- /**
95
- * Get all benchmark data.
96
- *
97
- */
98
- static getAll() {
99
- let result = {};
100
- for (const name in this._benchmarkData) {
101
- if (this._benchmarkCount[name] > 0) {
102
- result[name] = this._benchmarkData[name] / this._benchmarkCount[name];
103
- }
104
- }
105
- return result;
106
- }
107
- }
108
- exports.OINOBenchmark = OINOBenchmark;
@@ -1,177 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OINOHtmlTemplate = void 0;
4
- const _1 = require(".");
5
- /**
6
- * Class for rendering HTML from data.
7
- */
8
- class OINOHtmlTemplate {
9
- _tag;
10
- _tagCleanRegex;
11
- _variables = {};
12
- /** HTML template string */
13
- template;
14
- /** Cache modified value for template */
15
- modified;
16
- /** Cache expiration value for template */
17
- expires;
18
- /**
19
- * Creates HTML Response from a key-value-pair.
20
- *
21
- * @param template template string
22
- * @param tag tag to identify variables in template
23
- *
24
- */
25
- constructor(template, tag = "###") {
26
- this.template = template;
27
- this.modified = 0;
28
- this.expires = 0;
29
- this._tag = tag;
30
- this._tagCleanRegex = new RegExp(tag + ".*" + tag, "g");
31
- }
32
- /**
33
- * @returns whether template is empty
34
- */
35
- isEmpty() {
36
- return this.template == "";
37
- }
38
- _createHttpResult(html, removeUnusedTags) {
39
- if (removeUnusedTags) {
40
- html = html.replace(this._tagCleanRegex, "");
41
- }
42
- const result = new _1.OINOHttpResult(html);
43
- if (this.expires >= 1) {
44
- result.expires = Math.round(this.expires);
45
- }
46
- if (this.modified >= 1) {
47
- result.lastModified = this.modified;
48
- }
49
- return result;
50
- }
51
- _renderHtml() {
52
- let html = this.template;
53
- for (let key in this._variables) {
54
- const value = this._variables[key];
55
- html = html.replaceAll(this._tag + key + this._tag, value);
56
- }
57
- return html;
58
- }
59
- /**
60
- * Clear template variables.
61
- *
62
- */
63
- clearVariables() {
64
- this._variables = {};
65
- }
66
- /**
67
- * Sets template variable from a key-value-pair.
68
- *
69
- * @param variable key
70
- * @param value value
71
- * @param escapeValue whether to escape value
72
- *
73
- */
74
- setVariableFromValue(variable, value, escapeValue = true) {
75
- if (escapeValue) {
76
- value = _1.OINOStr.encode(value, _1.OINOContentType.html);
77
- }
78
- this._variables[variable] = value;
79
- }
80
- /**
81
- * Sets template variables from object properties.
82
- *
83
- * @param object any object
84
- * @param escapeValue whether to escape value
85
- *
86
- */
87
- setVariableFromProperties(object, escapeValue = true) {
88
- if (object) {
89
- for (let key in object) {
90
- if (escapeValue) {
91
- this._variables[key] = _1.OINOStr.encode(object[key], _1.OINOContentType.html);
92
- }
93
- else {
94
- this._variables[key] = object[key];
95
- }
96
- }
97
- }
98
- }
99
- /**
100
- * Creates HTML Response from set variables.
101
- *
102
- * @param removeUnusedTags whether to remove unused tags
103
- *
104
- */
105
- render(removeUnusedTags = true) {
106
- return this._createHttpResult(this._renderHtml(), removeUnusedTags);
107
- }
108
- /**
109
- * Creates HTML Response from a key-value-pair.
110
- *
111
- * @param key key
112
- * @param value value
113
- * @param removeUnusedTags whether to remove unused tags
114
- *
115
- */
116
- renderFromKeyValue(key, value, removeUnusedTags = true) {
117
- _1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromKeyValue");
118
- this.setVariableFromValue(key, value);
119
- const result = this.render(removeUnusedTags);
120
- _1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromKeyValue");
121
- return result;
122
- }
123
- /**
124
- * Creates HTML Response from object properties.
125
- *
126
- * @param object object
127
- * @param removeUnusedTags whether to remove unused tags
128
- *
129
- */
130
- renderFromObject(object, removeUnusedTags = true) {
131
- _1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromObject");
132
- this.setVariableFromProperties(object);
133
- const result = this.render(removeUnusedTags);
134
- _1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromObject");
135
- return result;
136
- }
137
- /**
138
- * Creates HTML Response from API result.
139
- *
140
- * @param result OINOResult-object
141
- * @param removeUnusedTags whether to remove unused tags
142
- * @param messageSeparator HTML separator for messages
143
- * @param includeErrorMessages include debug messages in result
144
- * @param includeWarningMessages include debug messages in result
145
- * @param includeInfoMessages include debug messages in result
146
- * @param includeDebugMessages include debug messages in result
147
- *
148
- */
149
- renderFromResult(result, removeUnusedTags = true, messageSeparator, includeErrorMessages = false, includeWarningMessages = false, includeInfoMessages = false, includeDebugMessages = false) {
150
- _1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromResult");
151
- this.setVariableFromValue("statusCode", result.statusCode.toString());
152
- this.setVariableFromValue("statusMessage", result.statusMessage.toString());
153
- let messages = [];
154
- for (let i = 0; i < result.messages.length; i++) {
155
- if (includeErrorMessages && result.messages[i].startsWith(_1.OINO_ERROR_PREFIX)) {
156
- messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
157
- }
158
- if (includeWarningMessages && result.messages[i].startsWith(_1.OINO_WARNING_PREFIX)) {
159
- messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
160
- }
161
- if (includeInfoMessages && result.messages[i].startsWith(_1.OINO_INFO_PREFIX)) {
162
- messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
163
- }
164
- if (includeDebugMessages && result.messages[i].startsWith(_1.OINO_DEBUG_PREFIX)) {
165
- messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
166
- }
167
- }
168
- if (messages.length > 0) {
169
- this.setVariableFromValue("messages", messages.join(messageSeparator), false); // messages have been escaped already
170
- }
171
- const http_result = this.render(removeUnusedTags);
172
- _1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromResult");
173
- return http_result;
174
- }
175
- }
176
- exports.OINOHtmlTemplate = OINOHtmlTemplate;
177
- ;
@@ -1,140 +0,0 @@
1
- "use strict";
2
- /*
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.OINOConsoleLog = exports.OINOLog = exports.OINOLogLevel = void 0;
9
- /** Logging levels */
10
- var OINOLogLevel;
11
- (function (OINOLogLevel) {
12
- /** Debug messages */
13
- OINOLogLevel[OINOLogLevel["debug"] = 0] = "debug";
14
- /** Informational messages */
15
- OINOLogLevel[OINOLogLevel["info"] = 1] = "info";
16
- /** Warning messages */
17
- OINOLogLevel[OINOLogLevel["warn"] = 2] = "warn";
18
- /** Error messages */
19
- OINOLogLevel[OINOLogLevel["error"] = 3] = "error";
20
- })(OINOLogLevel || (exports.OINOLogLevel = OINOLogLevel = {}));
21
- /**
22
- * Abstract base class for logging implementations supporting
23
- * - error, warning, info and debug channels
24
- * - setting level of logs outputted
25
- *
26
- */
27
- class OINOLog {
28
- static _instance;
29
- _logLevel = OINOLogLevel.warn;
30
- /**
31
- * Abstract logging method to implement the actual logging operation.
32
- *
33
- * @param logLevel level of the log events
34
- *
35
- */
36
- constructor(logLevel = OINOLogLevel.warn) {
37
- // console.log("OINOLog.constructor: logLevel=" + logLevel)
38
- this._logLevel = logLevel;
39
- }
40
- /**
41
- * Abstract logging method to implement the actual logging operation.
42
- *
43
- * @param level level of the log event
44
- * @param levelStr level string of the log event
45
- * @param message message of the log event
46
- * @param data structured data associated with the log event
47
- *
48
- */
49
- static _log(level, levelStr, message, data) {
50
- // console.log("_log: level=" + level + ", levelStr=" + levelStr + ", message=" + message + ", data=" + data)
51
- if ((OINOLog._instance) && (OINOLog._instance._logLevel <= level)) {
52
- OINOLog._instance?._writeLog(levelStr, message, data);
53
- }
54
- }
55
- /**
56
- * Set active logger and log level.
57
- *
58
- * @param logger logger instance
59
- *
60
- */
61
- static setLogger(logger) {
62
- // console.log("setLogger: " + log)
63
- if (logger) {
64
- OINOLog._instance = logger;
65
- }
66
- }
67
- /**
68
- * Set log level.
69
- *
70
- * @param logLevel log level to use
71
- *
72
- */
73
- static setLogLevel(logLevel) {
74
- if (OINOLog._instance) {
75
- OINOLog._instance._logLevel = logLevel;
76
- }
77
- }
78
- /**
79
- * Log error event.
80
- *
81
- * @param message message of the log event
82
- * @param data structured data associated with the log event
83
- *
84
- */
85
- static error(message, data) {
86
- OINOLog._log(OINOLogLevel.error, "ERROR", message, data);
87
- }
88
- /**
89
- * Log warning event.
90
- *
91
- * @param message message of the log event
92
- * @param data structured data associated with the log event
93
- *
94
- */
95
- static warning(message, data) {
96
- OINOLog._log(OINOLogLevel.warn, "WARN", message, data);
97
- }
98
- /**
99
- * Log info event.
100
- *
101
- * @param message message of the log event
102
- * @param data structured data associated with the log event
103
- *
104
- */
105
- static info(message, data) {
106
- OINOLog._log(OINOLogLevel.info, "INFO", message, data);
107
- }
108
- /**
109
- * Log debug event.
110
- *
111
- * @param message message of the log event
112
- * @param data structured data associated with the log event
113
- *
114
- */
115
- static debug(message, data) {
116
- OINOLog._log(OINOLogLevel.debug, "DEBUG", message, data);
117
- }
118
- }
119
- exports.OINOLog = OINOLog;
120
- /**
121
- * Logging implementation based on console.log.
122
- *
123
- */
124
- class OINOConsoleLog extends OINOLog {
125
- /**
126
- * Constructor of `OINOConsoleLog`
127
- * @param logLevel logging level
128
- */
129
- constructor(logLevel = OINOLogLevel.warn) {
130
- super(logLevel);
131
- }
132
- _writeLog(level, message, data) {
133
- let log = "OINOLog " + level + ": " + message;
134
- if (data) {
135
- log += " " + JSON.stringify(data);
136
- }
137
- console.log(log);
138
- }
139
- }
140
- exports.OINOConsoleLog = OINOConsoleLog;
@@ -1,216 +0,0 @@
1
- "use strict";
2
- /*
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.OINOHttpResult = exports.OINOResult = void 0;
9
- const node_crypto_1 = require("node:crypto");
10
- const _1 = require(".");
11
- /**
12
- * OINO API request result object with returned data and/or http status code/message and
13
- * error / warning messages.
14
- *
15
- */
16
- class OINOResult {
17
- /** Wheter request was successfully executed */
18
- success;
19
- /** HTTP status code */
20
- statusCode;
21
- /** HTTP status message */
22
- statusMessage;
23
- /** Error / warning messages */
24
- messages;
25
- /**
26
- * Constructor of OINOResult.
27
- *
28
- */
29
- constructor() {
30
- this.success = true;
31
- this.statusCode = 200;
32
- this.statusMessage = "OK";
33
- this.messages = [];
34
- }
35
- /**
36
- * Copy values from different result.
37
- *
38
- * @param result source value
39
- */
40
- copy(result) {
41
- this.success = result.success;
42
- this.statusCode = result.statusCode;
43
- this.statusMessage = result.statusMessage;
44
- this.messages = result.messages.slice();
45
- }
46
- /**
47
- * Set HTTP OK status (does not reset messages).
48
- *
49
- */
50
- setOk() {
51
- this.success = true;
52
- this.statusCode = 200;
53
- this.statusMessage = "OK";
54
- }
55
- /**
56
- * Set HTTP error status using given code and message. Returns self reference for chaining.
57
- *
58
- * @param statusCode HTTP status code
59
- * @param statusMessage HTTP status message
60
- * @param operation operation where error occured
61
- *
62
- */
63
- setError(statusCode, statusMessage, operation) {
64
- this.success = false;
65
- this.statusCode = statusCode;
66
- if (this.statusMessage != "OK") {
67
- this.messages.push(this.statusMessage); // latest error becomes status, but if there was something non-trivial, add it to the messages
68
- }
69
- if (statusMessage.startsWith(_1.OINO_ERROR_PREFIX)) {
70
- this.statusMessage = statusMessage;
71
- }
72
- else {
73
- this.statusMessage = _1.OINO_ERROR_PREFIX + " (" + operation + "): " + statusMessage;
74
- }
75
- return this;
76
- }
77
- /**
78
- * Add warning message. Returns self reference for chaining.
79
- *
80
- * @param message HTTP status message
81
- * @param operation operation where warning occured
82
- *
83
- */
84
- addWarning(message, operation) {
85
- message = message.trim();
86
- if (message) {
87
- this.messages.push(_1.OINO_WARNING_PREFIX + " (" + operation + "): " + message);
88
- }
89
- return this;
90
- }
91
- /**
92
- * Add info message. Returns self reference for chaining.
93
- *
94
- * @param message HTTP status message
95
- * @param operation operation where info occured
96
- *
97
- */
98
- addInfo(message, operation) {
99
- message = message.trim();
100
- if (message) {
101
- this.messages.push(_1.OINO_INFO_PREFIX + " (" + operation + "): " + message);
102
- }
103
- return this;
104
- }
105
- /**
106
- * Add debug message. Returns self reference for chaining.
107
- *
108
- * @param message HTTP status message
109
- * @param operation operation where debug occured
110
- *
111
- */
112
- addDebug(message, operation) {
113
- message = message.trim();
114
- if (message) {
115
- this.messages.push(_1.OINO_DEBUG_PREFIX + " (" + operation + "): " + message);
116
- }
117
- return this;
118
- }
119
- /**
120
- * Copy given messages to HTTP headers.
121
- *
122
- * @param headers HTTP headers
123
- * @param copyErrors wether error messages should be copied (default true)
124
- * @param copyWarnings wether warning messages should be copied (default false)
125
- * @param copyInfos wether info messages should be copied (default false)
126
- * @param copyDebug wether debug messages should be copied (default false)
127
- *
128
- */
129
- copyMessagesToHeaders(headers, copyErrors = true, copyWarnings = false, copyInfos = false, copyDebug = false) {
130
- let j = 1;
131
- for (let i = 0; i < this.messages.length; i++) {
132
- const message = this.messages[i].replaceAll("\r", " ").replaceAll("\n", " ");
133
- if (copyErrors && message.startsWith(_1.OINO_ERROR_PREFIX)) {
134
- headers.append('X-OINO-MESSAGE-' + j, message);
135
- j++;
136
- }
137
- if (copyWarnings && message.startsWith(_1.OINO_WARNING_PREFIX)) {
138
- headers.append('X-OINO-MESSAGE-' + j, message);
139
- j++;
140
- }
141
- if (copyInfos && message.startsWith(_1.OINO_INFO_PREFIX)) {
142
- headers.append('X-OINO-MESSAGE-' + j, message);
143
- j++;
144
- }
145
- if (copyDebug && message.startsWith(_1.OINO_DEBUG_PREFIX)) {
146
- headers.append('X-OINO-MESSAGE-' + j, message);
147
- j++;
148
- }
149
- }
150
- }
151
- /**
152
- * Print result for logging.
153
- *
154
- */
155
- printLog() {
156
- return "OINOResult: statusCode=" + this.statusCode + ", statusMessage=" + this.statusMessage + ", messages=[" + this.messages.join(", ") + "]";
157
- }
158
- }
159
- exports.OINOResult = OINOResult;
160
- /**
161
- * Specialized result for HTTP responses.
162
- */
163
- class OINOHttpResult extends OINOResult {
164
- _etag;
165
- /** HTTP body data */
166
- body;
167
- /** HTTP cache expiration value */
168
- expires;
169
- /** HTTP cache last-modified value */
170
- lastModified;
171
- /**
172
- * Constructor for a `OINOHttpResult`
173
- *
174
- * @param body HTTP body
175
- *
176
- */
177
- constructor(body) {
178
- super();
179
- this.body = body;
180
- this.expires = 0;
181
- this.lastModified = 0;
182
- this._etag = "";
183
- }
184
- /**
185
- * Get the ETag value for the body opportunistically, i.e. don't calculate until requested and reuse value.
186
- *
187
- */
188
- getEtag() {
189
- if (this._etag == "") {
190
- const hash = (0, node_crypto_1.createHash)("sha256");
191
- this._etag = hash.update(this.body).digest("hex");
192
- }
193
- return this._etag;
194
- }
195
- /**
196
- * Get a Response object from the result values.
197
- *
198
- * @param headers HTTP headers (overrides existing values)
199
- */
200
- getResponse(headers) {
201
- const result = new Response(this.body, { status: this.statusCode, statusText: this.statusMessage, headers: headers });
202
- result.headers.set('Content-Length', this.body.length.toString());
203
- if (this.lastModified > 0) {
204
- result.headers.set('Last-Modified', new Date(this.lastModified).toUTCString());
205
- }
206
- if (this.expires >= 0) {
207
- result.headers.set('Expires', Math.round(this.expires).toString());
208
- if (this.expires == 0) {
209
- result.headers.set('Pragma', 'no-cache');
210
- }
211
- }
212
- result.headers.set("ETag", this.getEtag());
213
- return result;
214
- }
215
- }
216
- exports.OINOHttpResult = OINOHttpResult;