@jwn-js/common 2.1.4 → 2.1.7
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/docs/assets/search.js +1 -1
- package/docs/classes/ApiError.html +1 -1
- package/docs/classes/AsyncJwt.html +1 -1
- package/docs/classes/Controller.html +4 -4
- package/docs/classes/Jwt.html +1 -1
- package/docs/classes/Memcached.html +1 -1
- package/docs/classes/Model.html +3 -3
- package/docs/classes/Server.html +1 -1
- package/docs/classes/Ssr.html +1 -1
- package/docs/classes/Web.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/ApiErrorMessage.html +1 -1
- package/docs/interfaces/ContextSsr.html +1 -1
- package/docs/interfaces/ContextWeb.html +1 -1
- package/docs/interfaces/OptionsSsr.html +1 -1
- package/docs/interfaces/OptionsWeb.html +1 -1
- package/docs/interfaces/ResponseOptions.html +1 -1
- package/docs/interfaces/Route.html +1 -1
- package/docs/interfaces/Schema.html +1 -1
- package/docs/interfaces/ServerHandler.html +1 -1
- package/docs/interfaces/ServerOptions.html +1 -1
- package/docs/interfaces/ServerWebsocket.html +1 -1
- package/docs/modules.html +3 -3
- package/index.d.ts +6 -0
- package/index.js +18 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -659,6 +659,11 @@ declare class Model {
|
|
|
659
659
|
getDb(): Record<string, Query>;
|
|
660
660
|
getHome(): Query;
|
|
661
661
|
getPool(key?: string): Query;
|
|
662
|
+
getStack(): {
|
|
663
|
+
[key: string]: any;
|
|
664
|
+
memcached?: Memcached | undefined;
|
|
665
|
+
redis?: any;
|
|
666
|
+
};
|
|
662
667
|
setResponseHeader(key: string, value: string): any;
|
|
663
668
|
setCookieHeader(name: string, value: any, options?: Record<string, any>): any;
|
|
664
669
|
}
|
|
@@ -959,6 +964,7 @@ declare const helpers: {
|
|
|
959
964
|
head: any;
|
|
960
965
|
body: any;
|
|
961
966
|
};
|
|
967
|
+
readJsonConfigsSync: <T extends Record<string, any>>(configs: string[], input?: Partial<T>) => T;
|
|
962
968
|
};
|
|
963
969
|
|
|
964
970
|
export { ApiError, ApiErrorMessage, AsyncJwt, ContextWeb, Controller$1 as Controller, Jwt, Memcached, Model, OptionsSsr, OptionsWeb, ResponseOptions, Route, Schema, Server, Handler as ServerHandler, Options as ServerOptions, Routes as ServerRoutes, WebSocket as ServerWebsocket, Ssr, Web, action, body, codeToStatus, config, connection, context, controller, cookies, db, headers, helpers, home, hostname, http, init, json, logerror, method, mixin, mountWithContext as mount, pool, protocol, request, selectControllersSchema, stream, subaction, url, xml };
|
package/index.js
CHANGED
|
@@ -45,6 +45,7 @@ var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
|
45
45
|
var querystring__default = /*#__PURE__*/_interopDefaultLegacy(querystring);
|
|
46
46
|
var formidable__default = /*#__PURE__*/_interopDefaultLegacy(formidable);
|
|
47
47
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
48
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
48
49
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
49
50
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
50
51
|
var xmljs__default = /*#__PURE__*/_interopDefaultLegacy(xmljs);
|
|
@@ -796,6 +797,14 @@ async function staticBody(res, req, base) {
|
|
|
796
797
|
}
|
|
797
798
|
}
|
|
798
799
|
|
|
800
|
+
const readJsonConfigsSync = (configs, input = {}) => {
|
|
801
|
+
for (const config of configs) {
|
|
802
|
+
const filePath = path__namespace.resolve(config);
|
|
803
|
+
Object.assign(input, JSON.parse(fs__namespace.readFileSync(filePath).toString()));
|
|
804
|
+
}
|
|
805
|
+
return input;
|
|
806
|
+
};
|
|
807
|
+
|
|
799
808
|
class Ssr {
|
|
800
809
|
constructor(res, req, context, entry) {
|
|
801
810
|
this.res = res;
|
|
@@ -1378,7 +1387,6 @@ class Web {
|
|
|
1378
1387
|
}
|
|
1379
1388
|
}
|
|
1380
1389
|
|
|
1381
|
-
const config$1 = readConfigSync("./connect.json");
|
|
1382
1390
|
const mountWithContext = async ($class, $context, request = {}) => {
|
|
1383
1391
|
const initComponent = async (obj2) => {
|
|
1384
1392
|
let out;
|
|
@@ -1393,12 +1401,12 @@ const mountWithContext = async ($class, $context, request = {}) => {
|
|
|
1393
1401
|
}
|
|
1394
1402
|
};
|
|
1395
1403
|
$context = Object.assign({
|
|
1396
|
-
config:
|
|
1404
|
+
config: {},
|
|
1397
1405
|
getRequest: () => request,
|
|
1398
1406
|
method: "get",
|
|
1399
1407
|
...request.controller && request.subaction && $context.db?.home ? await selectControllerParams($context.db.home, $context.method || "get", request.controller, request.subaction) : {},
|
|
1400
1408
|
cookies: {},
|
|
1401
|
-
hostname:
|
|
1409
|
+
hostname: $context.config?.server?.development?.host,
|
|
1402
1410
|
protocol: "http",
|
|
1403
1411
|
headers: {}
|
|
1404
1412
|
}, $context);
|
|
@@ -1507,6 +1515,7 @@ class Controller {
|
|
|
1507
1515
|
getRequest: this.$context.getRequest,
|
|
1508
1516
|
config: this.$context.config,
|
|
1509
1517
|
db: this.$context.db,
|
|
1518
|
+
stack: this.$context.stack,
|
|
1510
1519
|
headers: this.$context.headers,
|
|
1511
1520
|
cookies: this.$context.cookies,
|
|
1512
1521
|
controller: this.$context.controller,
|
|
@@ -1603,6 +1612,7 @@ class Model {
|
|
|
1603
1612
|
getRequest: this.$context.getRequest,
|
|
1604
1613
|
config: this.$context.config,
|
|
1605
1614
|
db: this.$context.db,
|
|
1615
|
+
stack: this.$context.stack,
|
|
1606
1616
|
headers: this.$context.headers,
|
|
1607
1617
|
cookies: this.$context.cookies,
|
|
1608
1618
|
controller: this.$context.controller,
|
|
@@ -1656,6 +1666,9 @@ class Model {
|
|
|
1656
1666
|
getPool(key = "home") {
|
|
1657
1667
|
return this.getDb()[key];
|
|
1658
1668
|
}
|
|
1669
|
+
getStack() {
|
|
1670
|
+
return this.$context.stack;
|
|
1671
|
+
}
|
|
1659
1672
|
setResponseHeader(key, value) {
|
|
1660
1673
|
return this.$context.setResponseHeader(key, value);
|
|
1661
1674
|
}
|
|
@@ -1940,7 +1953,8 @@ const helpers = {
|
|
|
1940
1953
|
staticBody,
|
|
1941
1954
|
extensions,
|
|
1942
1955
|
getExt,
|
|
1943
|
-
jwtDecode
|
|
1956
|
+
jwtDecode,
|
|
1957
|
+
readJsonConfigsSync
|
|
1944
1958
|
};
|
|
1945
1959
|
|
|
1946
1960
|
exports.ApiError = ApiError.ApiError;
|