rasengan 1.0.0-beta.17 → 1.0.0-beta.19
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.
|
@@ -76,22 +76,33 @@ function handleRequest(req, res) {
|
|
|
76
76
|
return __generator(this, function (_b) {
|
|
77
77
|
switch (_b.label) {
|
|
78
78
|
case 0:
|
|
79
|
-
|
|
79
|
+
console.log({
|
|
80
|
+
cwd: process.cwd()
|
|
81
|
+
});
|
|
82
|
+
// read dir
|
|
83
|
+
console.log({
|
|
84
|
+
readdir: node_fs_1.default.readdirSync(process.cwd()),
|
|
85
|
+
readdir2: node_fs_1.default.readdirSync((0, node_path_1.join)(process.cwd(), "..")),
|
|
86
|
+
readdir3: node_fs_1.default.readdirSync((0, node_path_1.join)(process.cwd(), "..", "..")),
|
|
87
|
+
});
|
|
88
|
+
_b.label = 1;
|
|
89
|
+
case 1:
|
|
90
|
+
_b.trys.push([1, 9, , 10]);
|
|
80
91
|
url = req.url;
|
|
81
92
|
host = req.headers.host;
|
|
82
93
|
appPath = (0, node_path_1.join)(process.cwd(), "..");
|
|
83
|
-
if (!(url === "/robots.txt")) return [3 /*break*/,
|
|
84
|
-
_b.label =
|
|
85
|
-
case 1:
|
|
86
|
-
_b.trys.push([1, 3, , 4]);
|
|
87
|
-
return [4 /*yield*/, promises_1.default.access(node_path_1.default.resolve((0, node_path_1.join)(appPath, "dist/client/robots.txt")))];
|
|
94
|
+
if (!(url === "/robots.txt")) return [3 /*break*/, 5];
|
|
95
|
+
_b.label = 2;
|
|
88
96
|
case 2:
|
|
97
|
+
_b.trys.push([2, 4, , 5]);
|
|
98
|
+
return [4 /*yield*/, promises_1.default.access(node_path_1.default.resolve((0, node_path_1.join)(appPath, "dist/client/robots.txt")))];
|
|
99
|
+
case 3:
|
|
89
100
|
_b.sent();
|
|
90
101
|
return [2 /*return*/, res.send(node_path_1.default.resolve((0, node_path_1.join)(appPath, "dist/client/robots.txt")))];
|
|
91
|
-
case
|
|
102
|
+
case 4:
|
|
92
103
|
err_1 = _b.sent();
|
|
93
104
|
return [2 /*return*/, res.send("\n user-agent: *\n disallow: /downloads/\n disallow: /private/\n allow: /\n \n user-agent: magicsearchbot\n disallow: /uploads/\n ")];
|
|
94
|
-
case
|
|
105
|
+
case 5:
|
|
95
106
|
// ! Sitemap Fix
|
|
96
107
|
if (url === "/sitemap.xml") {
|
|
97
108
|
return [2 /*return*/, res.send(node_path_1.default.resolve((0, node_path_1.join)(appPath, "dist/client/sitemap.xml")))];
|
|
@@ -104,7 +115,7 @@ function handleRequest(req, res) {
|
|
|
104
115
|
serverFilePath = (0, node_path_1.join)(appPath, "dist/server/entry-server.js");
|
|
105
116
|
bootstrapDirPath = (0, node_path_1.join)(appPath, "dist/client/assets");
|
|
106
117
|
return [4 /*yield*/, Promise.resolve("".concat(serverFilePath)).then(function (s) { return __importStar(require(s)); })];
|
|
107
|
-
case
|
|
118
|
+
case 6:
|
|
108
119
|
entry = _b.sent();
|
|
109
120
|
bootstrap = "/assets/" +
|
|
110
121
|
node_fs_1.default
|
|
@@ -118,7 +129,7 @@ function handleRequest(req, res) {
|
|
|
118
129
|
handler = (0, server_js_1.createStaticHandler)(staticRoutes);
|
|
119
130
|
fetchRequest = (0, rasengan_1.createFetchRequest)(req, host);
|
|
120
131
|
return [4 /*yield*/, handler.query(fetchRequest)];
|
|
121
|
-
case
|
|
132
|
+
case 7:
|
|
122
133
|
context = _b.sent();
|
|
123
134
|
status_1 = context.status;
|
|
124
135
|
if (status_1 === 302) {
|
|
@@ -129,7 +140,7 @@ function handleRequest(req, res) {
|
|
|
129
140
|
helmetContext = {};
|
|
130
141
|
router = (0, server_js_1.createStaticRouter)(handler.dataRoutes, context);
|
|
131
142
|
return [4 /*yield*/, render(router, context, helmetContext)];
|
|
132
|
-
case
|
|
143
|
+
case 8:
|
|
133
144
|
rendered = _b.sent();
|
|
134
145
|
// Load template html
|
|
135
146
|
if (!templateHtml) {
|
|
@@ -151,7 +162,7 @@ function handleRequest(req, res) {
|
|
|
151
162
|
"Cache-Control": "max-age=31536000",
|
|
152
163
|
},
|
|
153
164
|
})];
|
|
154
|
-
case
|
|
165
|
+
case 9:
|
|
155
166
|
e_1 = _b.sent();
|
|
156
167
|
console.log(e_1.stack);
|
|
157
168
|
if (res) {
|
|
@@ -160,7 +171,7 @@ function handleRequest(req, res) {
|
|
|
160
171
|
return [2 /*return*/, new Response(e_1.stack, {
|
|
161
172
|
status: 500,
|
|
162
173
|
})];
|
|
163
|
-
case
|
|
174
|
+
case 10: return [2 /*return*/];
|
|
164
175
|
}
|
|
165
176
|
});
|
|
166
177
|
});
|
|
@@ -48,22 +48,33 @@ export default function handleRequest(req, res) {
|
|
|
48
48
|
return __generator(this, function (_b) {
|
|
49
49
|
switch (_b.label) {
|
|
50
50
|
case 0:
|
|
51
|
-
|
|
51
|
+
console.log({
|
|
52
|
+
cwd: process.cwd()
|
|
53
|
+
});
|
|
54
|
+
// read dir
|
|
55
|
+
console.log({
|
|
56
|
+
readdir: fsSync.readdirSync(process.cwd()),
|
|
57
|
+
readdir2: fsSync.readdirSync(join(process.cwd(), "..")),
|
|
58
|
+
readdir3: fsSync.readdirSync(join(process.cwd(), "..", "..")),
|
|
59
|
+
});
|
|
60
|
+
_b.label = 1;
|
|
61
|
+
case 1:
|
|
62
|
+
_b.trys.push([1, 9, , 10]);
|
|
52
63
|
url = req.url;
|
|
53
64
|
host = req.headers.host;
|
|
54
65
|
appPath = join(process.cwd(), "..");
|
|
55
|
-
if (!(url === "/robots.txt")) return [3 /*break*/,
|
|
56
|
-
_b.label =
|
|
57
|
-
case 1:
|
|
58
|
-
_b.trys.push([1, 3, , 4]);
|
|
59
|
-
return [4 /*yield*/, fs.access(path.resolve(join(appPath, "dist/client/robots.txt")))];
|
|
66
|
+
if (!(url === "/robots.txt")) return [3 /*break*/, 5];
|
|
67
|
+
_b.label = 2;
|
|
60
68
|
case 2:
|
|
69
|
+
_b.trys.push([2, 4, , 5]);
|
|
70
|
+
return [4 /*yield*/, fs.access(path.resolve(join(appPath, "dist/client/robots.txt")))];
|
|
71
|
+
case 3:
|
|
61
72
|
_b.sent();
|
|
62
73
|
return [2 /*return*/, res.send(path.resolve(join(appPath, "dist/client/robots.txt")))];
|
|
63
|
-
case
|
|
74
|
+
case 4:
|
|
64
75
|
err_1 = _b.sent();
|
|
65
76
|
return [2 /*return*/, res.send("\n user-agent: *\n disallow: /downloads/\n disallow: /private/\n allow: /\n \n user-agent: magicsearchbot\n disallow: /uploads/\n ")];
|
|
66
|
-
case
|
|
77
|
+
case 5:
|
|
67
78
|
// ! Sitemap Fix
|
|
68
79
|
if (url === "/sitemap.xml") {
|
|
69
80
|
return [2 /*return*/, res.send(path.resolve(join(appPath, "dist/client/sitemap.xml")))];
|
|
@@ -76,7 +87,7 @@ export default function handleRequest(req, res) {
|
|
|
76
87
|
serverFilePath = join(appPath, "dist/server/entry-server.js");
|
|
77
88
|
bootstrapDirPath = join(appPath, "dist/client/assets");
|
|
78
89
|
return [4 /*yield*/, import(serverFilePath)];
|
|
79
|
-
case
|
|
90
|
+
case 6:
|
|
80
91
|
entry = _b.sent();
|
|
81
92
|
bootstrap = "/assets/" +
|
|
82
93
|
fsSync
|
|
@@ -90,7 +101,7 @@ export default function handleRequest(req, res) {
|
|
|
90
101
|
handler = createStaticHandler(staticRoutes);
|
|
91
102
|
fetchRequest = createFetchRequest(req, host);
|
|
92
103
|
return [4 /*yield*/, handler.query(fetchRequest)];
|
|
93
|
-
case
|
|
104
|
+
case 7:
|
|
94
105
|
context = _b.sent();
|
|
95
106
|
status_1 = context.status;
|
|
96
107
|
if (status_1 === 302) {
|
|
@@ -101,7 +112,7 @@ export default function handleRequest(req, res) {
|
|
|
101
112
|
helmetContext = {};
|
|
102
113
|
router = createStaticRouter(handler.dataRoutes, context);
|
|
103
114
|
return [4 /*yield*/, render(router, context, helmetContext)];
|
|
104
|
-
case
|
|
115
|
+
case 8:
|
|
105
116
|
rendered = _b.sent();
|
|
106
117
|
// Load template html
|
|
107
118
|
if (!templateHtml) {
|
|
@@ -123,7 +134,7 @@ export default function handleRequest(req, res) {
|
|
|
123
134
|
"Cache-Control": "max-age=31536000",
|
|
124
135
|
},
|
|
125
136
|
})];
|
|
126
|
-
case
|
|
137
|
+
case 9:
|
|
127
138
|
e_1 = _b.sent();
|
|
128
139
|
console.log(e_1.stack);
|
|
129
140
|
if (res) {
|
|
@@ -132,7 +143,7 @@ export default function handleRequest(req, res) {
|
|
|
132
143
|
return [2 /*return*/, new Response(e_1.stack, {
|
|
133
144
|
status: 500,
|
|
134
145
|
})];
|
|
135
|
-
case
|
|
146
|
+
case 10: return [2 /*return*/];
|
|
136
147
|
}
|
|
137
148
|
});
|
|
138
149
|
});
|