textbrowser 0.43.0 → 0.44.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 CHANGED
@@ -1,4 +1,8 @@
1
- # textbrowser CHANGES
1
+ # CHANGES to `textbrowser`
2
+
3
+ ## 0.44.0
4
+
5
+ - fix: allow passing on if middleware does not match
2
6
 
3
7
  ## 0.43.0
4
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textbrowser",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Multilinear text browser",
5
5
  "type": "module",
6
6
  "main": "dist/index-es.min.js",
package/server/main.js CHANGED
@@ -122,6 +122,19 @@ const srv = http.createServer(async (req, res) => {
122
122
  }
123
123
  fileServer.serve(req, res);
124
124
  };
125
+
126
+ const next = function () {
127
+ req.addListener('end', staticServer).resume();
128
+ };
129
+
130
+ /**
131
+ * @returns {Promise<void>}
132
+ */
133
+ const runHttpServer = async function () {
134
+ // eslint-disable-next-line no-unsanitized/method -- Site-specified plugin
135
+ const server = (await import(userParams.httpServer)).default();
136
+ server(req, res, next);
137
+ };
125
138
  if (userParams.expressServer) {
126
139
  // eslint-disable-next-line no-unsanitized/method -- Site-specified plugin
127
140
  const app = (await import(userParams.expressServer)).default();
@@ -131,18 +144,20 @@ const srv = http.createServer(async (req, res) => {
131
144
  // not get any other)
132
145
  return regexp.source !== '^\\/?(?=\\/|$)' && regexp.test(req.url);
133
146
  })) {
134
- // eslint-disable-next-line no-unsanitized/method -- Site-specified plugin
135
- const server = (await import(userParams.httpServer)).default();
136
- server(req, res);
147
+ runHttpServer();
137
148
  return;
138
149
  }
139
150
 
140
151
  app.get('*', staticServer);
141
152
  app(req, res);
142
153
 
154
+ return;
155
+ } else if (userParams.httpServer) {
156
+ runHttpServer();
143
157
  return;
144
158
  }
145
- req.addListener('end', staticServer).resume();
159
+
160
+ next();
146
161
  /*
147
162
  res.writeHead(404, {'Content-Type': 'text/html'});
148
163
  res.end('<h1>File not found</h1>');