@proteinjs/server 1.0.16 → 1.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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +2 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/loadRoutes.js +2 -2
- package/dist/src/loadRoutes.js.map +1 -1
- package/dist/src/routes/reactApp.d.ts.map +1 -1
- package/dist/src/routes/reactApp.js +43 -17
- package/dist/src/routes/reactApp.js.map +1 -1
- package/generated/index.ts +2 -1
- package/package.json +8 -6
- package/src/loadRoutes.ts +1 -1
- package/src/routes/reactApp.ts +17 -7
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.1.0](https://github.com/proteinjs/server/compare/@proteinjs/server@1.0.17...@proteinjs/server@1.1.0) (2024-05-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* `ServerConfig` now accepts a bundles directory instead of bundle paths (deprecated) so the server can support dynamic bundle names (ie. when you generate a hash as part of the bundle name for cache busting) ([f3d7cef](https://github.com/proteinjs/server/commit/f3d7cefd58cb0b220470e886e161fbc028ca2df9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.0.11](https://github.com/proteinjs/server/compare/@proteinjs/server@1.0.10...@proteinjs/server@1.0.11) (2024-04-24)
|
|
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,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,aAAa,CAAC;AACrB,OAAO,eAAe,CAAC;AACvB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,QAAQ,CAAC;AAChB,OAAO,SAAS,CAAC;AACjB,OAAO,iBAAiB,CAAC;AACzB,OAAO,aAA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C,OAAO,wBAAwB,CAAC;AAyBhC,cAAc,UAAU,CAAC"}
|
package/dist/generated/index.js
CHANGED
|
@@ -20,6 +20,7 @@ require("@proteinjs/db");
|
|
|
20
20
|
require("@proteinjs/reflection");
|
|
21
21
|
require("@proteinjs/server-api");
|
|
22
22
|
require("@proteinjs/util");
|
|
23
|
+
require("@proteinjs/util-node");
|
|
23
24
|
require("body-parser");
|
|
24
25
|
require("buffer");
|
|
25
26
|
require("compression");
|
|
@@ -45,7 +46,7 @@ require("webpack");
|
|
|
45
46
|
require("webpack-dev-middleware");
|
|
46
47
|
require("webpack-hot-middleware");
|
|
47
48
|
/** Generate Source Graph */
|
|
48
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeSessionDataStorage\",\"filePath\":\"/
|
|
49
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"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\":\"/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/NodeSessionDataStorage\",\"w\":\"@proteinjs/server-api/SessionDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/healthCheck\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
|
|
49
50
|
/** Generate Source Links */
|
|
50
51
|
var NodeSessionDataStorage_1 = require("../src/NodeSessionDataStorage");
|
|
51
52
|
var healthCheck_1 = require("../src/routes/healthCheck");
|
|
@@ -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,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,sxGAAsxG,CAAC;AAG3yG,4BAA4B;AAE5B,wEAAuE;AACvE,yDAAwD;AAExD,IAAM,WAAW,GAAG;IACnB,0CAA0C,EAAE,+CAAsB;IAClE,+BAA+B,EAAE,yBAAW;CAC5C,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
package/dist/src/loadRoutes.js
CHANGED
|
@@ -70,7 +70,7 @@ function loadRoutes(routes, server, config) {
|
|
|
70
70
|
}
|
|
71
71
|
exports.loadRoutes = loadRoutes;
|
|
72
72
|
function loadDefaultStarRoute(routes, server, config) {
|
|
73
|
-
var _a;
|
|
73
|
+
var _a, _b;
|
|
74
74
|
var starRouteSpecified = false;
|
|
75
75
|
for (var _i = 0, routes_2 = routes; _i < routes_2.length; _i++) {
|
|
76
76
|
var route = routes_2[_i];
|
|
@@ -79,7 +79,7 @@ function loadDefaultStarRoute(routes, server, config) {
|
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
if (!starRouteSpecified && ((_a = config.staticContent) === null || _a === void 0 ? void 0 : _a.bundlePaths)) {
|
|
82
|
+
if (!starRouteSpecified && (((_a = config.staticContent) === null || _a === void 0 ? void 0 : _a.bundlePaths) || ((_b = config.staticContent) === null || _b === void 0 ? void 0 : _b.bundlesDir))) {
|
|
83
83
|
var reactApp = (0, reactApp_1.createReactApp)(config);
|
|
84
84
|
server[reactApp.method](reactApp.path, wrapRoute(reactApp.on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K,CAAC,CAAC;;;wBAEzB,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;8BAEH,EAAhB,qCAAgB;;;6BAAhB,CAAA,8BAAgB,CAAA;wBAA5B,QAAQ;wBACf,IAAI,CAAC,QAAQ,CAAC,YAAY;4BACtB,yBAAS;;;;wBAGT,qBAAM,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAA;;wBAA9C,SAA8C,CAAC;;;;wBAE/C,MAAM,CAAC,KAAK,CAAC,kDAAkD,EAAE,OAAK,CAAC,CAAC;;;wBAPzD,IAAgB,CAAA;;;wBAWvC,IAAI,EAAE,CAAC;;;;;KACV,CAAC;AACN,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAwB;IAClD,IAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpE,IAAA,KAAuB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAA1E,QAAQ,QAAA,EAAE,QAAQ,QAAwD,CAAC;IAClF,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QACtB,OAAO,IAAI,CAAC;IAEhB,OAAO,EAAE,QAAQ,UAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactApp.d.ts","sourceRoot":"","sources":["../../../src/routes/reactApp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"reactApp.d.ts","sourceRoot":"","sources":["../../../src/routes/reactApp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,uBAAuB,CAAC;AAG/E,eAAO,MAAM,cAAc,iBAAkB,YAAY;;;yBAItB,GAAG,YAAY,GAAG,KAAG,QAAQ,IAAI,CAAC;CA4BpE,CAAA"}
|
|
@@ -43,26 +43,30 @@ exports.createReactApp = void 0;
|
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var react_helmet_1 = __importDefault(require("react-helmet"));
|
|
45
45
|
var server_api_1 = require("@proteinjs/server-api");
|
|
46
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
46
47
|
var createReactApp = function (serverConfig) {
|
|
47
48
|
return {
|
|
48
49
|
path: '*',
|
|
49
50
|
method: 'get',
|
|
50
51
|
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
-
var helmet, _a, _b, _c, _d;
|
|
52
|
-
var
|
|
53
|
-
return __generator(this, function (
|
|
54
|
-
switch (
|
|
52
|
+
var helmet, _a, _b, _c, _d, _e, _f;
|
|
53
|
+
var _g, _h, _j;
|
|
54
|
+
return __generator(this, function (_k) {
|
|
55
|
+
switch (_k.label) {
|
|
55
56
|
case 0:
|
|
56
57
|
if (request.path.startsWith('/static'))
|
|
57
58
|
return [2 /*return*/];
|
|
58
|
-
if (!((
|
|
59
|
-
throw new Error("ServerConfig.bundlePath must be provided to serve react app");
|
|
59
|
+
if (!(((_g = serverConfig.staticContent) === null || _g === void 0 ? void 0 : _g.bundlePaths) || ((_h = serverConfig.staticContent) === null || _h === void 0 ? void 0 : _h.bundlesDir)))
|
|
60
|
+
throw new Error("ServerConfig.bundlePath or ServerConfig.bundlesDir must be provided to serve a react app");
|
|
60
61
|
helmet = react_helmet_1.default.renderStatic();
|
|
61
62
|
_b = (_a = response).send;
|
|
62
|
-
|
|
63
|
+
_e = (_d = "<!DOCTYPE html>\n <html ".concat(helmet.htmlAttributes, ">\n <head>\n <meta charset='utf-8' />\n <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n <link href='").concat(((_j = serverConfig.staticContent) === null || _j === void 0 ? void 0 : _j.faviconPath) ? path_1.default.join('/static/', serverConfig.staticContent.faviconPath) : '', "' rel='icon' type='image/x-icon' />\n ").concat(helmet.title.toString(), "\n ").concat(helmet.meta.toString(), "\n ").concat(helmet.link.toString(), "\n </head>\n <body ").concat(helmet.bodyAttributes.toString(), ">\n <div id='app'></div>\n <script>proteinjs = {};</script>\n ")).concat;
|
|
63
64
|
return [4 /*yield*/, serverRenderedScriptTags()];
|
|
64
65
|
case 1:
|
|
65
|
-
|
|
66
|
+
_f = (_c = _e.apply(_d, [_k.sent(), "\n "])).concat;
|
|
67
|
+
return [4 /*yield*/, bundleScriptTags(serverConfig)];
|
|
68
|
+
case 2:
|
|
69
|
+
_b.apply(_a, [_f.apply(_c, [_k.sent(), "\n </body>\n </html>"])]);
|
|
66
70
|
return [2 /*return*/];
|
|
67
71
|
}
|
|
68
72
|
});
|
|
@@ -71,15 +75,37 @@ var createReactApp = function (serverConfig) {
|
|
|
71
75
|
};
|
|
72
76
|
exports.createReactApp = createReactApp;
|
|
73
77
|
function bundleScriptTags(serverConfig) {
|
|
74
|
-
var _a;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
var _a, _b, _c, _d, _e;
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var scriptTags, _i, _f, bundlePath, resolvedBundlesDir, filePaths, _g, filePaths_1, filePath, relativePath;
|
|
81
|
+
return __generator(this, function (_h) {
|
|
82
|
+
switch (_h.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!(((_a = serverConfig.staticContent) === null || _a === void 0 ? void 0 : _a.bundlePaths) || ((_b = serverConfig.staticContent) === null || _b === void 0 ? void 0 : _b.bundlesDir)))
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
scriptTags = [];
|
|
87
|
+
if (!((_c = serverConfig.staticContent) === null || _c === void 0 ? void 0 : _c.bundlePaths)) return [3 /*break*/, 1];
|
|
88
|
+
for (_i = 0, _f = serverConfig.staticContent.bundlePaths; _i < _f.length; _i++) {
|
|
89
|
+
bundlePath = _f[_i];
|
|
90
|
+
scriptTags.push("<script src='".concat(path_1.default.join('/static/', bundlePath), "'></script>"));
|
|
91
|
+
}
|
|
92
|
+
return [3 /*break*/, 3];
|
|
93
|
+
case 1:
|
|
94
|
+
if (!(((_d = serverConfig.staticContent) === null || _d === void 0 ? void 0 : _d.bundlesDir) && ((_e = serverConfig.staticContent) === null || _e === void 0 ? void 0 : _e.staticContentDir))) return [3 /*break*/, 3];
|
|
95
|
+
resolvedBundlesDir = path_1.default.join(serverConfig.staticContent.staticContentDir, serverConfig.staticContent.bundlesDir);
|
|
96
|
+
return [4 /*yield*/, util_node_1.Fs.getFilePathsMatchingGlob(resolvedBundlesDir, '**/*.js')];
|
|
97
|
+
case 2:
|
|
98
|
+
filePaths = _h.sent();
|
|
99
|
+
for (_g = 0, filePaths_1 = filePaths; _g < filePaths_1.length; _g++) {
|
|
100
|
+
filePath = filePaths_1[_g];
|
|
101
|
+
relativePath = path_1.default.relative(serverConfig.staticContent.staticContentDir, filePath);
|
|
102
|
+
scriptTags.push("<script src='".concat(path_1.default.join('/static/', relativePath), "'></script>"));
|
|
103
|
+
}
|
|
104
|
+
_h.label = 3;
|
|
105
|
+
case 3: return [2 /*return*/, scriptTags.join('\n')];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
83
109
|
}
|
|
84
110
|
function serverRenderedScriptTags() {
|
|
85
111
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactApp.js","sourceRoot":"","sources":["../../../src/routes/reactApp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,8DAAuC;AACvC,oDAA+E;
|
|
1
|
+
{"version":3,"file":"reactApp.js","sourceRoot":"","sources":["../../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;;;;;oBAC7B,OAAO,GAAG,IAAA,qCAAwB,GAAE,CAAC;oBACrC,UAAU,GAAa,EAAE,CAAC;0BACJ,EAAP,mBAAO;;;yBAAP,CAAA,qBAAO,CAAA;oBAAjB,MAAM;oBACb,KAAA,CAAA,KAAA,UAAU,CAAA,CAAC,IAAI,CAAA;;oBAAY,qBAAM,MAAM,CAAC,MAAM,EAAE,EAAA;;oBAAhD,cAAgB,sBAAW,SAAqB,eAAW,EAAC,CAAC;;;oBAD5C,IAAO,CAAA;;wBAG5B,sBAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC;;;;CAChC"}
|
package/generated/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import '@proteinjs/db';
|
|
|
5
5
|
import '@proteinjs/reflection';
|
|
6
6
|
import '@proteinjs/server-api';
|
|
7
7
|
import '@proteinjs/util';
|
|
8
|
+
import '@proteinjs/util-node';
|
|
8
9
|
import 'body-parser';
|
|
9
10
|
import 'buffer';
|
|
10
11
|
import 'compression';
|
|
@@ -33,7 +34,7 @@ import 'webpack-hot-middleware';
|
|
|
33
34
|
|
|
34
35
|
/** Generate Source Graph */
|
|
35
36
|
|
|
36
|
-
const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/server/NodeSessionDataStorage\",\"value\":{\"packageName\":\"@proteinjs/server\",\"name\":\"NodeSessionDataStorage\",\"filePath\":\"/
|
|
37
|
+
const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"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\":\"/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/NodeSessionDataStorage\",\"w\":\"@proteinjs/server-api/SessionDataStorage\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/server/healthCheck\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
/** Generate Source Links */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/server",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A server impl",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,10 +22,11 @@
|
|
|
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.11",
|
|
26
26
|
"@proteinjs/reflection": "1.0.7",
|
|
27
|
-
"@proteinjs/server-api": "^1.0
|
|
27
|
+
"@proteinjs/server-api": "^1.1.0",
|
|
28
28
|
"@proteinjs/util": "1.1.0",
|
|
29
|
+
"@proteinjs/util-node": "1.2.0",
|
|
29
30
|
"body-parser": "1.19.0",
|
|
30
31
|
"buffer": "6.0.3",
|
|
31
32
|
"compression": "1.7.4",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"webpack-hot-middleware": "2.26.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@proteinjs/reflection-build": "1.0.
|
|
56
|
+
"@proteinjs/reflection-build": "1.0.13",
|
|
56
57
|
"@types/body-parser": "1.19.0",
|
|
57
58
|
"@types/compression": "1.7.0",
|
|
58
59
|
"@types/cookie-parser": "1.4.2",
|
|
@@ -66,5 +67,6 @@
|
|
|
66
67
|
"@types/webpack-hot-middleware": "2.25.9"
|
|
67
68
|
},
|
|
68
69
|
"main": "./dist/generated/index.js",
|
|
69
|
-
"types": "./dist/generated/index.d.ts"
|
|
70
|
-
|
|
70
|
+
"types": "./dist/generated/index.d.ts",
|
|
71
|
+
"gitHead": "7ddcd8abe723f52cd645851d93dcf6b5f7b1e17e"
|
|
72
|
+
}
|
package/src/loadRoutes.ts
CHANGED
|
@@ -40,7 +40,7 @@ export function loadDefaultStarRoute(routes: Route[], server: express.Express, c
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (!starRouteSpecified && config.staticContent?.bundlePaths) {
|
|
43
|
+
if (!starRouteSpecified && (config.staticContent?.bundlePaths || config.staticContent?.bundlesDir)) {
|
|
44
44
|
const reactApp = createReactApp(config);
|
|
45
45
|
server[reactApp.method](reactApp.path, wrapRoute(reactApp.onRequest, config));
|
|
46
46
|
}
|
package/src/routes/reactApp.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import ReactHelmet from 'react-helmet';
|
|
3
3
|
import { ServerConfig, getServerRenderedScripts } from '@proteinjs/server-api';
|
|
4
|
+
import { Fs } from '@proteinjs/util-node';
|
|
4
5
|
|
|
5
6
|
export const createReactApp = (serverConfig: ServerConfig) => {
|
|
6
7
|
return {
|
|
@@ -10,8 +11,8 @@ export const createReactApp = (serverConfig: ServerConfig) => {
|
|
|
10
11
|
if (request.path.startsWith('/static'))
|
|
11
12
|
return;
|
|
12
13
|
|
|
13
|
-
if (!serverConfig.staticContent?.bundlePaths)
|
|
14
|
-
throw new Error(`ServerConfig.bundlePath must be provided to serve react app`);
|
|
14
|
+
if (!(serverConfig.staticContent?.bundlePaths || serverConfig.staticContent?.bundlesDir))
|
|
15
|
+
throw new Error(`ServerConfig.bundlePath or ServerConfig.bundlesDir must be provided to serve a react app`);
|
|
15
16
|
|
|
16
17
|
const helmet = ReactHelmet.renderStatic();
|
|
17
18
|
response.send(`<!DOCTYPE html>
|
|
@@ -28,7 +29,7 @@ export const createReactApp = (serverConfig: ServerConfig) => {
|
|
|
28
29
|
<div id='app'></div>
|
|
29
30
|
<script>proteinjs = {};</script>
|
|
30
31
|
${await serverRenderedScriptTags()}
|
|
31
|
-
${bundleScriptTags(serverConfig)}
|
|
32
|
+
${await bundleScriptTags(serverConfig)}
|
|
32
33
|
</body>
|
|
33
34
|
</html>`
|
|
34
35
|
);
|
|
@@ -36,13 +37,22 @@ export const createReactApp = (serverConfig: ServerConfig) => {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
function bundleScriptTags(serverConfig: ServerConfig) {
|
|
40
|
-
if (!serverConfig.staticContent?.bundlePaths)
|
|
40
|
+
async function bundleScriptTags(serverConfig: ServerConfig) {
|
|
41
|
+
if (!(serverConfig.staticContent?.bundlePaths || serverConfig.staticContent?.bundlesDir))
|
|
41
42
|
return;
|
|
42
43
|
|
|
43
44
|
const scriptTags: string[] = [];
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (serverConfig.staticContent?.bundlePaths) {
|
|
46
|
+
for (const bundlePath of serverConfig.staticContent.bundlePaths)
|
|
47
|
+
scriptTags.push(`<script src='${path.join('/static/', bundlePath)}'></script>`);
|
|
48
|
+
} else if (serverConfig.staticContent?.bundlesDir && serverConfig.staticContent?.staticContentDir) {
|
|
49
|
+
const resolvedBundlesDir = path.join(serverConfig.staticContent.staticContentDir, serverConfig.staticContent.bundlesDir);
|
|
50
|
+
const filePaths = await Fs.getFilePathsMatchingGlob(resolvedBundlesDir, '**/*.js');
|
|
51
|
+
for (const filePath of filePaths) {
|
|
52
|
+
const relativePath = path.relative(serverConfig.staticContent.staticContentDir, filePath);
|
|
53
|
+
scriptTags.push(`<script src='${path.join('/static/', relativePath)}'></script>`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
return scriptTags.join('\n');
|
|
48
58
|
}
|