textbrowser 0.44.0 → 0.45.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/CHANGES.md +8 -0
- package/package.json +1 -1
- package/server/main.js +15 -8
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGES to `textbrowser`
|
|
2
2
|
|
|
3
|
+
## 0.45.0
|
|
4
|
+
|
|
5
|
+
- fix: proper use of `await`
|
|
6
|
+
- fix: avoid extra problematic static server call
|
|
7
|
+
- fix: allow for empty router
|
|
8
|
+
- fix: allow fall-through to express if http server fails to match
|
|
9
|
+
- fix: pass on `next` to express
|
|
10
|
+
|
|
3
11
|
## 0.44.0
|
|
4
12
|
|
|
5
13
|
- fix: allow passing on if middleware does not match
|
package/package.json
CHANGED
package/server/main.js
CHANGED
|
@@ -133,27 +133,34 @@ const srv = http.createServer(async (req, res) => {
|
|
|
133
133
|
const runHttpServer = async function () {
|
|
134
134
|
// eslint-disable-next-line no-unsanitized/method -- Site-specified plugin
|
|
135
135
|
const server = (await import(userParams.httpServer)).default();
|
|
136
|
-
server(
|
|
136
|
+
return await server(
|
|
137
|
+
req,
|
|
138
|
+
res,
|
|
139
|
+
// For express, we'll first give a chance to other static servers
|
|
140
|
+
// they might supply
|
|
141
|
+
userParams.expressServer ? () => {
|
|
142
|
+
// Empty
|
|
143
|
+
} : next
|
|
144
|
+
);
|
|
137
145
|
};
|
|
138
146
|
if (userParams.expressServer) {
|
|
139
147
|
// eslint-disable-next-line no-unsanitized/method -- Site-specified plugin
|
|
140
148
|
const app = (await import(userParams.expressServer)).default();
|
|
141
149
|
|
|
142
|
-
if (userParams.httpServer && !app._router.stack.some(({regexp}) => {
|
|
150
|
+
if (userParams.httpServer && (!app._router || !app._router.stack.some(({regexp}) => {
|
|
143
151
|
// Hack to ignore middleware like jsonParser (and hopefully
|
|
144
152
|
// not get any other)
|
|
145
153
|
return regexp.source !== '^\\/?(?=\\/|$)' && regexp.test(req.url);
|
|
146
|
-
})) {
|
|
147
|
-
runHttpServer();
|
|
148
|
-
return;
|
|
154
|
+
}))) {
|
|
155
|
+
await runHttpServer();
|
|
149
156
|
}
|
|
150
157
|
|
|
151
|
-
app.get('*', staticServer);
|
|
152
|
-
app(req, res);
|
|
158
|
+
// app.get('*', staticServer);
|
|
159
|
+
app(req, res, next);
|
|
153
160
|
|
|
154
161
|
return;
|
|
155
162
|
} else if (userParams.httpServer) {
|
|
156
|
-
runHttpServer();
|
|
163
|
+
await runHttpServer();
|
|
157
164
|
return;
|
|
158
165
|
}
|
|
159
166
|
|