@proteinjs/server 1.1.7 → 1.2.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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +5 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/NodeGlobalDataStorage.d.ts +10 -0
- package/dist/src/NodeGlobalDataStorage.d.ts.map +1 -0
- package/dist/src/NodeGlobalDataStorage.js +48 -0
- package/dist/src/NodeGlobalDataStorage.js.map +1 -0
- package/dist/src/envCache.d.ts +3 -0
- package/dist/src/envCache.d.ts.map +1 -0
- package/dist/src/envCache.js +52 -0
- package/dist/src/envCache.js.map +1 -0
- package/dist/src/startServer.d.ts.map +1 -1
- package/dist/src/startServer.js +21 -4
- package/dist/src/startServer.js.map +1 -1
- package/generated/index.ts +9 -8
- package/package.json +6 -5
- package/src/NodeGlobalDataStorage.ts +46 -0
- package/src/envCache.ts +11 -0
- package/src/startServer.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.2.0](https://github.com/proteinjs/server/compare/@proteinjs/server@1.1.8...@proteinjs/server@1.2.0) (2024-05-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* create global data storage and cache ([52725b5](https://github.com/proteinjs/server/commit/52725b52820ae51022ef5a8132e44104e63193a9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.1.6](https://github.com/proteinjs/server/compare/@proteinjs/server@1.1.5...@proteinjs/server@1.1.6) (2024-05-16)
|
|
7
18
|
|
|
8
19
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Brent Bahry
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,eAAe,CAAC;AACvB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,aAAa,CAAC;AACrB,OAAO,eAAe,C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B,OAAO,KAAK,CAAC;AACb,OAAO,MAAM,CAAC;AACd,OAAO,SAAS,CAAC;AACjB,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;AA6BhC,cAAc,UAAU,CAAC"}
|
package/dist/generated/index.js
CHANGED
|
@@ -46,12 +46,16 @@ require("webpack");
|
|
|
46
46
|
require("webpack-dev-middleware");
|
|
47
47
|
require("webpack-hot-middleware");
|
|
48
48
|
/** Generate Source Graph */
|
|
49
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/
|
|
49
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/NodeGlobalDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeGlobalDataStorage\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/NodeGlobalDataStorage.ts\",\"qualifiedName\":\"@proteinjs/server/NodeGlobalDataStorage\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"HOOK_INITIALIZED\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"GLOBAL_DATA\",\"type\":{\"packageName\":\"@proteinjs/server\",\"name\":\"{ [id: string]: GlobalData }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server/{ [id: string]: GlobalData }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"environment\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"setData\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"data\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalData\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"getData\",\"returnType\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalData\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"initHook\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalDataStorage\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalDataStorage\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/GlobalDataStorage\"},{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeSessionDataStorage\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/NodeSessionDataStorage.ts\",\"qualifiedName\":\"@proteinjs/server/NodeSessionDataStorage\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"HOOK_INITIALIZED\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"SESSION_DATA\",\"type\":{\"packageName\":\"@proteinjs/server\",\"name\":\"{ [id: string]: SessionData }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server/{ [id: string]: SessionData }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"environment\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"setData\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"data\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionData\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"getData\",\"returnType\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionData\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionData\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"initHook\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionDataStorage\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionDataStorage\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/SessionDataStorage\"},{\"v\":\"@proteinjs/server/environmentCache\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"environmentCache\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/envCache.ts\",\"qualifiedName\":\"@proteinjs/server/environmentCache\",\"type\":{\"packageName\":\"\",\"name\":\"GlobalDataCache<Env>\",\"filePath\":null,\"qualifiedName\":\"/GlobalDataCache<Env>\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"GlobalDataCache\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/GlobalDataCache\",\"typeParameters\":[\"@proteinjs/server-api/Env\"],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/GlobalDataCache\"},{\"v\":\"/string\"},{\"v\":\"@proteinjs/server/healthCheck\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"healthCheck\",\"filePath\":\"/home/runner/work/server/server/packages/server/src/routes/healthCheck.ts\",\"qualifiedName\":\"@proteinjs/server/healthCheck\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/Route\"}],\"edges\":[{\"v\":\"@proteinjs/server/NodeGlobalDataStorage\",\"w\":\"@proteinjs/server-api/GlobalDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"w\":\"@proteinjs/server-api/SessionDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/environmentCache\",\"w\":\"@proteinjs/server-api/GlobalDataCache\",\"value\":\"has type\"},{\"v\":\"@proteinjs/server/healthCheck\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
|
|
50
50
|
/** Generate Source Links */
|
|
51
|
+
var NodeGlobalDataStorage_1 = require("../src/NodeGlobalDataStorage");
|
|
51
52
|
var NodeSessionDataStorage_1 = require("../src/NodeSessionDataStorage");
|
|
53
|
+
var envCache_1 = require("../src/envCache");
|
|
52
54
|
var healthCheck_1 = require("../src/routes/healthCheck");
|
|
53
55
|
var sourceLinks = {
|
|
56
|
+
'@proteinjs/server/NodeGlobalDataStorage': NodeGlobalDataStorage_1.NodeGlobalDataStorage,
|
|
54
57
|
'@proteinjs/server/NodeSessionDataStorage': NodeSessionDataStorage_1.NodeSessionDataStorage,
|
|
58
|
+
'@proteinjs/server/environmentCache': envCache_1.environmentCache,
|
|
55
59
|
'@proteinjs/server/healthCheck': healthCheck_1.healthCheck,
|
|
56
60
|
};
|
|
57
61
|
/** Load Source Graph and Links */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,gDAA8C;AAC9C,yBAAuB;AACvB,iCAA+B;AAC/B,iCAA+B;AAC/B,2BAAyB;AACzB,gCAA8B;AAC9B,uBAAqB;AACrB,kBAAgB;AAChB,uBAAqB;AACrB,yBAAuB;AACvB,6BAA2B;AAC3B,kBAAgB;AAChB,mBAAiB;AACjB,2BAAyB;AACzB,uBAAqB;AACrB,oBAAkB;AAClB,0BAAwB;AACxB,mBAAiB;AACjB,iBAAe;AACf,wBAAsB;AACtB,yBAAuB;AACvB,oCAAkC;AAClC,6BAA2B;AAC3B,qBAAmB;AACnB,sBAAoB;AACpB,eAAa;AACb,gBAAc;AACd,mBAAiB;AACjB,kCAAgC;AAChC,kCAAgC;AAGhC,4BAA4B;AAE5B,IAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,gDAA8C;AAC9C,yBAAuB;AACvB,iCAA+B;AAC/B,iCAA+B;AAC/B,2BAAyB;AACzB,gCAA8B;AAC9B,uBAAqB;AACrB,kBAAgB;AAChB,uBAAqB;AACrB,yBAAuB;AACvB,6BAA2B;AAC3B,kBAAgB;AAChB,mBAAiB;AACjB,2BAAyB;AACzB,uBAAqB;AACrB,oBAAkB;AAClB,0BAAwB;AACxB,mBAAiB;AACjB,iBAAe;AACf,wBAAsB;AACtB,yBAAuB;AACvB,oCAAkC;AAClC,6BAA2B;AAC3B,qBAAmB;AACnB,sBAAoB;AACpB,eAAa;AACb,gBAAc;AACd,mBAAiB;AACjB,kCAAgC;AAChC,kCAAgC;AAGhC,4BAA4B;AAE5B,IAAM,WAAW,GAAG,g/MAAg/M,CAAC;AAGrgN,4BAA4B;AAE5B,sEAAqE;AACrE,wEAAuE;AACvE,4CAAmD;AACnD,yDAAwD;AAExD,IAAM,WAAW,GAAG;IACnB,yCAAyC,EAAE,6CAAqB;IAChE,0CAA0C,EAAE,+CAAsB;IAClE,oCAAoC,EAAE,2BAAgB;IACtD,+BAA+B,EAAE,yBAAW;CAC5C,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GlobalData, GlobalDataStorage } from '@proteinjs/server-api';
|
|
2
|
+
export declare class NodeGlobalDataStorage implements GlobalDataStorage {
|
|
3
|
+
private static HOOK_INITIALIZED;
|
|
4
|
+
private static readonly GLOBAL_DATA;
|
|
5
|
+
environment: "node";
|
|
6
|
+
setData(data: GlobalData): void;
|
|
7
|
+
getData(): GlobalData;
|
|
8
|
+
private initHook;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=NodeGlobalDataStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeGlobalDataStorage.d.ts","sourceRoot":"","sources":["../../src/NodeGlobalDataStorage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAS;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAoC;IACvE,WAAW,SAAoB;IAE/B,OAAO,CAAC,IAAI,EAAE,UAAU;IAYxB,OAAO,IAAI,UAAU;IAQrB,OAAO,CAAC,QAAQ;CAiBjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NodeGlobalDataStorage = void 0;
|
|
7
|
+
var async_hooks_1 = __importDefault(require("async_hooks"));
|
|
8
|
+
var NodeGlobalDataStorage = /** @class */ (function () {
|
|
9
|
+
function NodeGlobalDataStorage() {
|
|
10
|
+
this.environment = 'node';
|
|
11
|
+
}
|
|
12
|
+
NodeGlobalDataStorage.prototype.setData = function (data) {
|
|
13
|
+
if (!NodeGlobalDataStorage.HOOK_INITIALIZED) {
|
|
14
|
+
this.initHook();
|
|
15
|
+
}
|
|
16
|
+
if (NodeGlobalDataStorage.GLOBAL_DATA[async_hooks_1.default.executionAsyncId()]) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
NodeGlobalDataStorage.GLOBAL_DATA[async_hooks_1.default.executionAsyncId()] = data;
|
|
20
|
+
};
|
|
21
|
+
NodeGlobalDataStorage.prototype.getData = function () {
|
|
22
|
+
if (!NodeGlobalDataStorage.HOOK_INITIALIZED) {
|
|
23
|
+
this.initHook();
|
|
24
|
+
}
|
|
25
|
+
return NodeGlobalDataStorage.GLOBAL_DATA[async_hooks_1.default.executionAsyncId()];
|
|
26
|
+
};
|
|
27
|
+
NodeGlobalDataStorage.prototype.initHook = function () {
|
|
28
|
+
async_hooks_1.default
|
|
29
|
+
.createHook({
|
|
30
|
+
init: function (asyncId, type, triggerAsyncId, resource) {
|
|
31
|
+
if (!NodeGlobalDataStorage.GLOBAL_DATA[triggerAsyncId]) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
NodeGlobalDataStorage.GLOBAL_DATA[asyncId] = NodeGlobalDataStorage.GLOBAL_DATA[triggerAsyncId];
|
|
35
|
+
},
|
|
36
|
+
destroy: function (asyncId) {
|
|
37
|
+
delete NodeGlobalDataStorage.GLOBAL_DATA[asyncId];
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
.enable();
|
|
41
|
+
NodeGlobalDataStorage.HOOK_INITIALIZED = true;
|
|
42
|
+
};
|
|
43
|
+
NodeGlobalDataStorage.HOOK_INITIALIZED = false;
|
|
44
|
+
NodeGlobalDataStorage.GLOBAL_DATA = {};
|
|
45
|
+
return NodeGlobalDataStorage;
|
|
46
|
+
}());
|
|
47
|
+
exports.NodeGlobalDataStorage = NodeGlobalDataStorage;
|
|
48
|
+
//# sourceMappingURL=NodeGlobalDataStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeGlobalDataStorage.js","sourceRoot":"","sources":["../../src/NodeGlobalDataStorage.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAqC;AAGrC;IAAA;QAGE,gBAAW,GAAG,MAAgB,CAAC;IAuCjC,CAAC;IArCC,uCAAO,GAAP,UAAQ,IAAgB;QACtB,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;QAED,IAAI,qBAAqB,CAAC,WAAW,CAAC,qBAAU,CAAC,gBAAgB,EAAE,CAAC,EAAE;YACpE,OAAO;SACR;QAED,qBAAqB,CAAC,WAAW,CAAC,qBAAU,CAAC,gBAAgB,EAAE,CAAC,GAAG,IAAI,CAAC;IAC1E,CAAC;IAED,uCAAO,GAAP;QACE,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;QAED,OAAO,qBAAqB,CAAC,WAAW,CAAC,qBAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEO,wCAAQ,GAAhB;QACE,qBAAU;aACP,UAAU,CAAC;YACV,IAAI,EAAE,UAAC,OAAe,EAAE,IAAY,EAAE,cAAsB,EAAE,QAAgB;gBAC5E,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;oBACtD,OAAO;iBACR;gBAED,qBAAqB,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;YACjG,CAAC;YACD,OAAO,EAAE,UAAC,OAAe;gBACvB,OAAO,qBAAqB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACpD,CAAC;SACF,CAAC;aACD,MAAM,EAAE,CAAC;QACZ,qBAAqB,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAChD,CAAC;IAxCc,sCAAgB,GAAG,KAAK,AAAR,CAAS;IAChB,iCAAW,GAAiC,EAAE,AAAnC,CAAoC;IAwCzE,4BAAC;CAAA,AA1CD,IA0CC;AA1CY,sDAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envCache.d.ts","sourceRoot":"","sources":["../../src/envCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5E,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAQjD,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.environmentCache = void 0;
|
|
40
|
+
var server_api_1 = require("@proteinjs/server-api");
|
|
41
|
+
exports.environmentCache = {
|
|
42
|
+
key: server_api_1.ENV_CACHE_KEY,
|
|
43
|
+
create: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
if (process.env.DEVELOPMENT) {
|
|
46
|
+
return [2 /*return*/, { env: 'dev' }];
|
|
47
|
+
}
|
|
48
|
+
return [2 /*return*/, { env: 'prod' }];
|
|
49
|
+
});
|
|
50
|
+
}); },
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=envCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envCache.js","sourceRoot":"","sources":["../../src/envCache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4E;AAE/D,QAAA,gBAAgB,GAAyB;IACpD,GAAG,EAAE,0BAAa;IAClB,MAAM,EAAE;;YACN,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;gBAC3B,sBAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAC;aACvB;YACD,sBAAO,EAAE,GAAG,EAAE,MAAM,EAAE,EAAC;;SACxB;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.d.ts","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"startServer.d.ts","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":"AAWA,OAAO,EAAsB,YAAY,EAAkC,MAAM,uBAAuB,CAAC;AAQzG,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,iBA8BrD"}
|
package/dist/src/startServer.js
CHANGED
|
@@ -59,14 +59,14 @@ var staticContentPath = '/static/';
|
|
|
59
59
|
var logger = new util_1.Logger('Server');
|
|
60
60
|
function startServer(config) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var routes, server;
|
|
63
|
-
return __generator(this, function (
|
|
64
|
-
switch (
|
|
62
|
+
var routes, server, globalData, _i, _a, globalDataCache, _b, _c;
|
|
63
|
+
return __generator(this, function (_d) {
|
|
64
|
+
switch (_d.label) {
|
|
65
65
|
case 0:
|
|
66
66
|
routes = (0, server_api_1.getRoutes)();
|
|
67
67
|
return [4 /*yield*/, runStartupEvents(config)];
|
|
68
68
|
case 1:
|
|
69
|
-
|
|
69
|
+
_d.sent();
|
|
70
70
|
server = (0, express_1.default)();
|
|
71
71
|
configureRequests(server);
|
|
72
72
|
initializeHotReloading(server, config);
|
|
@@ -76,6 +76,23 @@ function startServer(config) {
|
|
|
76
76
|
configureStaticContentRouter(server, config); // registering here prevents sessions from being created on static content requests
|
|
77
77
|
configureSession(server, config);
|
|
78
78
|
(0, loadRoutes_1.loadRoutes)(routes.filter(function (route) { return !route.useHttp; }), server, config);
|
|
79
|
+
globalData = {};
|
|
80
|
+
_i = 0, _a = (0, server_api_1.getGlobalDataCaches)();
|
|
81
|
+
_d.label = 2;
|
|
82
|
+
case 2:
|
|
83
|
+
if (!(_i < _a.length)) return [3 /*break*/, 5];
|
|
84
|
+
globalDataCache = _a[_i];
|
|
85
|
+
_b = globalData;
|
|
86
|
+
_c = globalDataCache.key;
|
|
87
|
+
return [4 /*yield*/, globalDataCache.create()];
|
|
88
|
+
case 3:
|
|
89
|
+
_b[_c] = _d.sent();
|
|
90
|
+
_d.label = 4;
|
|
91
|
+
case 4:
|
|
92
|
+
_i++;
|
|
93
|
+
return [3 /*break*/, 2];
|
|
94
|
+
case 5:
|
|
95
|
+
server_api_1.Global.setData(globalData);
|
|
79
96
|
(0, loadRoutes_1.loadDefaultStarRoute)(routes, server, config);
|
|
80
97
|
afterRequest(server, config);
|
|
81
98
|
start(server, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAC9B,oEAA6C;AAC7C,4DAAsC;AACtC,gEAAyC;AACzC,4DAAqC;AACrC,sDAAgC;AAChC,kEAA2C;AAC3C,oDAA8B;AAC9B,kFAA0D;AAC1D,kFAA0D;AAC1D,oCAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAC9B,oEAA6C;AAC7C,4DAAsC;AACtC,gEAAyC;AACzC,4DAAqC;AACrC,sDAAgC;AAChC,kEAA2C;AAC3C,oDAA8B;AAC9B,kFAA0D;AAC1D,kFAA0D;AAC1D,oCAAmC;AACnC,oDAAyG;AACzG,2CAAgE;AAChE,wCAAyC;AACzC,qDAAuD;AAEvD,IAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,IAAM,MAAM,GAAG,IAAI,aAAM,CAAC,QAAQ,CAAC,CAAC;AAEpC,SAAsB,WAAW,CAAC,MAAoB;;;;;;oBAC9C,MAAM,GAAG,IAAA,sBAAS,GAAE,CAAC;oBAC3B,qBAAM,gBAAgB,CAAC,MAAM,CAAC,EAAA;;oBAA9B,SAA8B,CAAC;oBACzB,MAAM,GAAG,IAAA,iBAAO,GAAE,CAAC;oBACzB,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC1B,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBACvC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC9B,IAAA,uBAAU,EACR,MAAM,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC,EACvC,MAAM,EACN,MAAM,CACP,CAAC;oBACF,cAAc,CAAC,MA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ACL,CAAC"}
|
package/generated/index.ts
CHANGED
|
@@ -31,27 +31,28 @@ import 'webpack';
|
|
|
31
31
|
import 'webpack-dev-middleware';
|
|
32
32
|
import 'webpack-hot-middleware';
|
|
33
33
|
|
|
34
|
-
|
|
35
34
|
/** Generate Source Graph */
|
|
36
35
|
|
|
37
|
-
const sourceGraph =
|
|
38
|
-
|
|
36
|
+
const sourceGraph =
|
|
37
|
+
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/server/NodeGlobalDataStorage","value":{"packageName":"@proteinjs/server","name":"NodeGlobalDataStorage","filePath":"/home/runner/work/server/server/packages/server/src/NodeGlobalDataStorage.ts","qualifiedName":"@proteinjs/server/NodeGlobalDataStorage","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"HOOK_INITIALIZED","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"GLOBAL_DATA","type":{"packageName":"@proteinjs/server","name":"{ [id: string]: GlobalData }","filePath":null,"qualifiedName":"@proteinjs/server/{ [id: string]: GlobalData }","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"environment","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"setData","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"data","type":{"packageName":"@proteinjs/server-api","name":"GlobalData","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalData","typeParameters":null,"directParents":null}}]},{"name":"getData","returnType":{"packageName":"@proteinjs/server-api","name":"GlobalData","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalData","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"initHook","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/server-api","name":"GlobalDataStorage","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalDataStorage","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/server-api/GlobalDataStorage"},{"v":"@proteinjs/server/NodeSessionDataStorage","value":{"packageName":"@proteinjs/server","name":"NodeSessionDataStorage","filePath":"/home/runner/work/server/server/packages/server/src/NodeSessionDataStorage.ts","qualifiedName":"@proteinjs/server/NodeSessionDataStorage","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"HOOK_INITIALIZED","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"SESSION_DATA","type":{"packageName":"@proteinjs/server","name":"{ [id: string]: SessionData }","filePath":null,"qualifiedName":"@proteinjs/server/{ [id: string]: SessionData }","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"environment","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"setData","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"data","type":{"packageName":"@proteinjs/server-api","name":"SessionData","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionData","typeParameters":null,"directParents":null}}]},{"name":"getData","returnType":{"packageName":"@proteinjs/server-api","name":"SessionData","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionData","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"initHook","returnType":null,"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/server-api","name":"SessionDataStorage","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionDataStorage","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/server-api/SessionDataStorage"},{"v":"@proteinjs/server/environmentCache","value":{"packageName":"@proteinjs/server","name":"environmentCache","filePath":"/home/runner/work/server/server/packages/server/src/envCache.ts","qualifiedName":"@proteinjs/server/environmentCache","type":{"packageName":"","name":"GlobalDataCache<Env>","filePath":null,"qualifiedName":"/GlobalDataCache<Env>","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"GlobalDataCache","filePath":null,"qualifiedName":"@proteinjs/server-api/GlobalDataCache","typeParameters":["@proteinjs/server-api/Env"],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/GlobalDataCache"},{"v":"/string"},{"v":"@proteinjs/server/healthCheck","value":{"packageName":"@proteinjs/server","name":"healthCheck","filePath":"/home/runner/work/server/server/packages/server/src/routes/healthCheck.ts","qualifiedName":"@proteinjs/server/healthCheck","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/Route"}],"edges":[{"v":"@proteinjs/server/NodeGlobalDataStorage","w":"@proteinjs/server-api/GlobalDataStorage","value":"implements interface"},{"v":"@proteinjs/server/NodeSessionDataStorage","w":"@proteinjs/server-api/SessionDataStorage","value":"implements interface"},{"v":"@proteinjs/server/environmentCache","w":"@proteinjs/server-api/GlobalDataCache","value":"has type"},{"v":"@proteinjs/server/healthCheck","w":"@proteinjs/server-api/Route","value":"has type"}]}';
|
|
39
38
|
|
|
40
39
|
/** Generate Source Links */
|
|
41
40
|
|
|
41
|
+
import { NodeGlobalDataStorage } from '../src/NodeGlobalDataStorage';
|
|
42
42
|
import { NodeSessionDataStorage } from '../src/NodeSessionDataStorage';
|
|
43
|
+
import { environmentCache } from '../src/envCache';
|
|
43
44
|
import { healthCheck } from '../src/routes/healthCheck';
|
|
44
45
|
|
|
45
46
|
const sourceLinks = {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
'@proteinjs/server/NodeGlobalDataStorage': NodeGlobalDataStorage,
|
|
48
|
+
'@proteinjs/server/NodeSessionDataStorage': NodeSessionDataStorage,
|
|
49
|
+
'@proteinjs/server/environmentCache': environmentCache,
|
|
50
|
+
'@proteinjs/server/healthCheck': healthCheck,
|
|
48
51
|
};
|
|
49
52
|
|
|
50
|
-
|
|
51
53
|
/** Load Source Graph and Links */
|
|
52
54
|
|
|
53
55
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
54
56
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
export * from '../index';
|
|
58
|
+
export * from '../index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A server impl",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
|
25
|
-
"@proteinjs/db": "1.0.
|
|
25
|
+
"@proteinjs/db": "1.0.20",
|
|
26
26
|
"@proteinjs/reflection": "1.1.5",
|
|
27
|
-
"@proteinjs/server-api": "^1.
|
|
27
|
+
"@proteinjs/server-api": "^1.2.0",
|
|
28
28
|
"@proteinjs/util": "1.1.2",
|
|
29
29
|
"@proteinjs/util-node": "1.2.2",
|
|
30
30
|
"body-parser": "1.19.0",
|
|
@@ -72,5 +72,6 @@
|
|
|
72
72
|
"eslint-plugin-prettier": "5.1.3"
|
|
73
73
|
},
|
|
74
74
|
"main": "./dist/generated/index.js",
|
|
75
|
-
"types": "./dist/generated/index.d.ts"
|
|
76
|
-
|
|
75
|
+
"types": "./dist/generated/index.d.ts",
|
|
76
|
+
"gitHead": "3c75f0c8a34b7f0330374d16e8e3ca1fcaa13165"
|
|
77
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import asyncHooks from 'async_hooks';
|
|
2
|
+
import { GlobalData, GlobalDataStorage } from '@proteinjs/server-api';
|
|
3
|
+
|
|
4
|
+
export class NodeGlobalDataStorage implements GlobalDataStorage {
|
|
5
|
+
private static HOOK_INITIALIZED = false;
|
|
6
|
+
private static readonly GLOBAL_DATA: { [id: string]: GlobalData } = {};
|
|
7
|
+
environment = 'node' as 'node';
|
|
8
|
+
|
|
9
|
+
setData(data: GlobalData) {
|
|
10
|
+
if (!NodeGlobalDataStorage.HOOK_INITIALIZED) {
|
|
11
|
+
this.initHook();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (NodeGlobalDataStorage.GLOBAL_DATA[asyncHooks.executionAsyncId()]) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
NodeGlobalDataStorage.GLOBAL_DATA[asyncHooks.executionAsyncId()] = data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getData(): GlobalData {
|
|
22
|
+
if (!NodeGlobalDataStorage.HOOK_INITIALIZED) {
|
|
23
|
+
this.initHook();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return NodeGlobalDataStorage.GLOBAL_DATA[asyncHooks.executionAsyncId()];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private initHook() {
|
|
30
|
+
asyncHooks
|
|
31
|
+
.createHook({
|
|
32
|
+
init: (asyncId: number, type: string, triggerAsyncId: number, resource: Object) => {
|
|
33
|
+
if (!NodeGlobalDataStorage.GLOBAL_DATA[triggerAsyncId]) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
NodeGlobalDataStorage.GLOBAL_DATA[asyncId] = NodeGlobalDataStorage.GLOBAL_DATA[triggerAsyncId];
|
|
38
|
+
},
|
|
39
|
+
destroy: (asyncId: number) => {
|
|
40
|
+
delete NodeGlobalDataStorage.GLOBAL_DATA[asyncId];
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
.enable();
|
|
44
|
+
NodeGlobalDataStorage.HOOK_INITIALIZED = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/envCache.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ENV_CACHE_KEY, Env, GlobalDataCache } from '@proteinjs/server-api';
|
|
2
|
+
|
|
3
|
+
export const environmentCache: GlobalDataCache<Env> = {
|
|
4
|
+
key: ENV_CACHE_KEY,
|
|
5
|
+
create: async (): Promise<Env> => {
|
|
6
|
+
if (process.env.DEVELOPMENT) {
|
|
7
|
+
return { env: 'dev' };
|
|
8
|
+
}
|
|
9
|
+
return { env: 'prod' };
|
|
10
|
+
},
|
|
11
|
+
};
|
package/src/startServer.ts
CHANGED
|
@@ -9,7 +9,7 @@ import webpack from 'webpack';
|
|
|
9
9
|
import webpackDevMiddleware from 'webpack-dev-middleware';
|
|
10
10
|
import webpackHotMiddleware from 'webpack-hot-middleware';
|
|
11
11
|
import { Db } from '@proteinjs/db';
|
|
12
|
-
import { ServerConfig, getRoutes } from '@proteinjs/server-api';
|
|
12
|
+
import { Global, GlobalData, ServerConfig, getGlobalDataCaches, getRoutes } from '@proteinjs/server-api';
|
|
13
13
|
import { loadRoutes, loadDefaultStarRoute } from './loadRoutes';
|
|
14
14
|
import { Logger } from '@proteinjs/util';
|
|
15
15
|
import { setNodeModulesPath } from './nodeModulesPath';
|
|
@@ -37,6 +37,13 @@ export async function startServer(config: ServerConfig) {
|
|
|
37
37
|
server,
|
|
38
38
|
config
|
|
39
39
|
);
|
|
40
|
+
|
|
41
|
+
const globalData: GlobalData = {};
|
|
42
|
+
for (const globalDataCache of getGlobalDataCaches()) {
|
|
43
|
+
globalData[globalDataCache.key] = await globalDataCache.create();
|
|
44
|
+
}
|
|
45
|
+
Global.setData(globalData);
|
|
46
|
+
|
|
40
47
|
loadDefaultStarRoute(routes, server, config);
|
|
41
48
|
afterRequest(server, config);
|
|
42
49
|
start(server, config);
|