@nattyjs/core 0.0.1-beta.45 → 0.0.1-beta.47
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.
- package/dist/index.cjs +47 -17
- package/dist/index.mjs +47 -17
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -126,13 +126,59 @@ function init(config, appConfig) {
|
|
|
126
126
|
common.commonContainer.setupConfig(config);
|
|
127
127
|
common.commonContainer.setEnvTsDefinition(appConfig.envTsDefinition);
|
|
128
128
|
nattyContainer.setup(config, appConfig.routes, appConfig.resolver);
|
|
129
|
-
|
|
129
|
+
callLifeCycleEvents(config, true);
|
|
130
|
+
const result = initializeModule(config);
|
|
131
|
+
callLifeCycleEvents(config);
|
|
132
|
+
startWebSchedule(config);
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
async function startWebSchedule(config) {
|
|
136
|
+
if (config.webSchedule) {
|
|
137
|
+
const interval = setInterval(async () => {
|
|
138
|
+
try {
|
|
139
|
+
clearInterval(interval);
|
|
140
|
+
await config.webSchedule.scheduleFunction();
|
|
141
|
+
startWebSchedule(config);
|
|
142
|
+
} catch (ex) {
|
|
143
|
+
startWebSchedule(config);
|
|
144
|
+
}
|
|
145
|
+
}, config.webSchedule.interval);
|
|
146
|
+
}
|
|
130
147
|
}
|
|
131
148
|
function initializeModule(config) {
|
|
132
149
|
if (config.app) {
|
|
133
150
|
return config.app.init(config);
|
|
134
151
|
}
|
|
135
152
|
}
|
|
153
|
+
async function callLifeCycleEvents(config, isPreInit = false) {
|
|
154
|
+
if (config.lifeCycle) {
|
|
155
|
+
if (config.lifeCycle.preInit && isPreInit) {
|
|
156
|
+
const preInit = config.lifeCycle.preInit();
|
|
157
|
+
if (preInit) {
|
|
158
|
+
if (preInit.cors) {
|
|
159
|
+
if (!config.cors) {
|
|
160
|
+
const jObject = { origin: [] };
|
|
161
|
+
config.cors = jObject;
|
|
162
|
+
} else if (!config.cors.origin)
|
|
163
|
+
config.cors.origin = [];
|
|
164
|
+
if (preInit.cors.origin)
|
|
165
|
+
preInit.cors.origin.forEach((t) => {
|
|
166
|
+
config.cors?.origin.push(t);
|
|
167
|
+
});
|
|
168
|
+
if (preInit.cors.methods)
|
|
169
|
+
config.cors.methods = preInit.cors.methods;
|
|
170
|
+
if (preInit.cors.optionsSuccessStatus)
|
|
171
|
+
config.cors.optionsSuccessStatus = preInit.cors.optionsSuccessStatus;
|
|
172
|
+
if (preInit.cors.preflightContinue)
|
|
173
|
+
config.cors.preflightContinue = preInit.cors.preflightContinue;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (config.lifeCycle.onStart) {
|
|
178
|
+
config.lifeCycle.onStart();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
136
182
|
|
|
137
183
|
function getPreResponseBody(body, isBuffer = false) {
|
|
138
184
|
let bodyInfo;
|
|
@@ -221,23 +267,7 @@ var RequestPipeline = /* @__PURE__ */ ((RequestPipeline2) => {
|
|
|
221
267
|
return RequestPipeline2;
|
|
222
268
|
})(RequestPipeline || {});
|
|
223
269
|
|
|
224
|
-
function lessThan(value) {
|
|
225
|
-
return value ? value.replace(/</g, "<") : value;
|
|
226
|
-
}
|
|
227
|
-
function greaterThan(value) {
|
|
228
|
-
return value ? value.replace(/>/g, ">") : value;
|
|
229
|
-
}
|
|
230
|
-
function ampersand(value) {
|
|
231
|
-
return value ? value.replace(/&/g, "&") : value;
|
|
232
|
-
}
|
|
233
|
-
function doubleDash(value) {
|
|
234
|
-
return value ? value.replace(/--/g, "") : value;
|
|
235
|
-
}
|
|
236
270
|
function sanitizeSpecialCodes(value) {
|
|
237
|
-
value = ampersand(value);
|
|
238
|
-
value = lessThan(value);
|
|
239
|
-
value = greaterThan(value);
|
|
240
|
-
value = doubleDash(value);
|
|
241
271
|
return value;
|
|
242
272
|
}
|
|
243
273
|
|
package/dist/index.mjs
CHANGED
|
@@ -124,13 +124,59 @@ function init(config, appConfig) {
|
|
|
124
124
|
commonContainer.setupConfig(config);
|
|
125
125
|
commonContainer.setEnvTsDefinition(appConfig.envTsDefinition);
|
|
126
126
|
nattyContainer.setup(config, appConfig.routes, appConfig.resolver);
|
|
127
|
-
|
|
127
|
+
callLifeCycleEvents(config, true);
|
|
128
|
+
const result = initializeModule(config);
|
|
129
|
+
callLifeCycleEvents(config);
|
|
130
|
+
startWebSchedule(config);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
async function startWebSchedule(config) {
|
|
134
|
+
if (config.webSchedule) {
|
|
135
|
+
const interval = setInterval(async () => {
|
|
136
|
+
try {
|
|
137
|
+
clearInterval(interval);
|
|
138
|
+
await config.webSchedule.scheduleFunction();
|
|
139
|
+
startWebSchedule(config);
|
|
140
|
+
} catch (ex) {
|
|
141
|
+
startWebSchedule(config);
|
|
142
|
+
}
|
|
143
|
+
}, config.webSchedule.interval);
|
|
144
|
+
}
|
|
128
145
|
}
|
|
129
146
|
function initializeModule(config) {
|
|
130
147
|
if (config.app) {
|
|
131
148
|
return config.app.init(config);
|
|
132
149
|
}
|
|
133
150
|
}
|
|
151
|
+
async function callLifeCycleEvents(config, isPreInit = false) {
|
|
152
|
+
if (config.lifeCycle) {
|
|
153
|
+
if (config.lifeCycle.preInit && isPreInit) {
|
|
154
|
+
const preInit = config.lifeCycle.preInit();
|
|
155
|
+
if (preInit) {
|
|
156
|
+
if (preInit.cors) {
|
|
157
|
+
if (!config.cors) {
|
|
158
|
+
const jObject = { origin: [] };
|
|
159
|
+
config.cors = jObject;
|
|
160
|
+
} else if (!config.cors.origin)
|
|
161
|
+
config.cors.origin = [];
|
|
162
|
+
if (preInit.cors.origin)
|
|
163
|
+
preInit.cors.origin.forEach((t) => {
|
|
164
|
+
config.cors?.origin.push(t);
|
|
165
|
+
});
|
|
166
|
+
if (preInit.cors.methods)
|
|
167
|
+
config.cors.methods = preInit.cors.methods;
|
|
168
|
+
if (preInit.cors.optionsSuccessStatus)
|
|
169
|
+
config.cors.optionsSuccessStatus = preInit.cors.optionsSuccessStatus;
|
|
170
|
+
if (preInit.cors.preflightContinue)
|
|
171
|
+
config.cors.preflightContinue = preInit.cors.preflightContinue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (config.lifeCycle.onStart) {
|
|
176
|
+
config.lifeCycle.onStart();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
134
180
|
|
|
135
181
|
function getPreResponseBody(body, isBuffer = false) {
|
|
136
182
|
let bodyInfo;
|
|
@@ -219,23 +265,7 @@ var RequestPipeline = /* @__PURE__ */ ((RequestPipeline2) => {
|
|
|
219
265
|
return RequestPipeline2;
|
|
220
266
|
})(RequestPipeline || {});
|
|
221
267
|
|
|
222
|
-
function lessThan(value) {
|
|
223
|
-
return value ? value.replace(/</g, "<") : value;
|
|
224
|
-
}
|
|
225
|
-
function greaterThan(value) {
|
|
226
|
-
return value ? value.replace(/>/g, ">") : value;
|
|
227
|
-
}
|
|
228
|
-
function ampersand(value) {
|
|
229
|
-
return value ? value.replace(/&/g, "&") : value;
|
|
230
|
-
}
|
|
231
|
-
function doubleDash(value) {
|
|
232
|
-
return value ? value.replace(/--/g, "") : value;
|
|
233
|
-
}
|
|
234
268
|
function sanitizeSpecialCodes(value) {
|
|
235
|
-
value = ampersand(value);
|
|
236
|
-
value = lessThan(value);
|
|
237
|
-
value = greaterThan(value);
|
|
238
|
-
value = doubleDash(value);
|
|
239
269
|
return value;
|
|
240
270
|
}
|
|
241
271
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nattyjs/core",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.47",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "ajayojha",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"reflect-metadata": "0.2.2",
|
|
19
19
|
"tsyringe": "^4.7.0",
|
|
20
20
|
"path-to-regexp": "6.2.1",
|
|
21
|
-
"@nattyjs/common": "0.0.1-beta.
|
|
21
|
+
"@nattyjs/common": "0.0.1-beta.47"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"unbuild": "1.2.1"
|