rasengan 1.0.0-beta.16 → 1.0.0-beta.18

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