ultimate-express 1.0.1 → 1.0.3

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.
Files changed (193) hide show
  1. package/README.md +18 -1
  2. package/package.json +10 -6
  3. package/src/request.js +1 -1
  4. package/src/router.js +9 -3
  5. package/src/utils.js +5 -2
  6. package/.github/workflows/test.yml +0 -27
  7. package/tests/index.js +0 -64
  8. package/tests/parts/.test/index.html +0 -11
  9. package/tests/parts/big.jpg +0 -0
  10. package/tests/parts/index.art +0 -12
  11. package/tests/parts/index.dot +0 -12
  12. package/tests/parts/index.ejs +0 -12
  13. package/tests/parts/index.handlebars +0 -2
  14. package/tests/parts/index.html +0 -12
  15. package/tests/parts/index.mustache +0 -12
  16. package/tests/parts/index.pug +0 -6
  17. package/tests/parts/index.swig +0 -12
  18. package/tests/parts/layouts/main.handlebars +0 -12
  19. package/tests/preload.cjs +0 -5
  20. package/tests/singular.js +0 -41
  21. package/tests/tests/app/app-engine.js +0 -8
  22. package/tests/tests/app/app-on-mount.js +0 -24
  23. package/tests/tests/app/app-path.js +0 -21
  24. package/tests/tests/app/app-route.js +0 -30
  25. package/tests/tests/app/options.js +0 -16
  26. package/tests/tests/app/setting-inheritance.js +0 -16
  27. package/tests/tests/engines/art-template.js +0 -33
  28. package/tests/tests/engines/dot.js +0 -28
  29. package/tests/tests/engines/ejs.js +0 -25
  30. package/tests/tests/engines/handlebars.js +0 -28
  31. package/tests/tests/engines/mustache.js +0 -28
  32. package/tests/tests/engines/pug.js +0 -25
  33. package/tests/tests/engines/swig.js +0 -28
  34. package/tests/tests/errors/error-handling-middleware.js +0 -22
  35. package/tests/tests/errors/next-error-optimized.js +0 -26
  36. package/tests/tests/errors/next-error.js +0 -26
  37. package/tests/tests/errors/unexpected-error-handling.js +0 -18
  38. package/tests/tests/listen/listen-random.js +0 -11
  39. package/tests/tests/listen/listen-specific.js +0 -17
  40. package/tests/tests/middlewares/body-json.js +0 -31
  41. package/tests/tests/middlewares/body-raw-deflate.js +0 -43
  42. package/tests/tests/middlewares/body-raw-gzip.js +0 -43
  43. package/tests/tests/middlewares/body-raw.js +0 -41
  44. package/tests/tests/middlewares/body-text.js +0 -27
  45. package/tests/tests/middlewares/body-urlencoded.js +0 -30
  46. package/tests/tests/middlewares/cookie-parser-signed.js +0 -31
  47. package/tests/tests/middlewares/cookie-parser.js +0 -28
  48. package/tests/tests/middlewares/cookie-session.js +0 -40
  49. package/tests/tests/middlewares/cors.js +0 -29
  50. package/tests/tests/middlewares/errorhandler.js +0 -26
  51. package/tests/tests/middlewares/express-fileupload-temp.js +0 -46
  52. package/tests/tests/middlewares/express-fileupload.js +0 -28
  53. package/tests/tests/middlewares/express-rate-limit.js +0 -33
  54. package/tests/tests/middlewares/express-session.js +0 -37
  55. package/tests/tests/middlewares/express-static-options.js +0 -72
  56. package/tests/tests/middlewares/express-static.js +0 -40
  57. package/tests/tests/middlewares/method-override.js +0 -33
  58. package/tests/tests/middlewares/multer.js +0 -43
  59. package/tests/tests/middlewares/multiple-middlewares.js +0 -37
  60. package/tests/tests/middlewares/response-time.js +0 -29
  61. package/tests/tests/middlewares/serve-index.js +0 -38
  62. package/tests/tests/middlewares/serve-static.js +0 -38
  63. package/tests/tests/middlewares/vhost.js +0 -50
  64. package/tests/tests/params/array-param.js +0 -30
  65. package/tests/tests/params/nested-params.js +0 -24
  66. package/tests/tests/params/param-errors.js +0 -56
  67. package/tests/tests/params/param-function.js +0 -49
  68. package/tests/tests/params/param-next-route.js +0 -48
  69. package/tests/tests/params/param-optimized.js +0 -38
  70. package/tests/tests/params/param-use.js +0 -39
  71. package/tests/tests/params/param.js +0 -68
  72. package/tests/tests/params/params-regex.js +0 -26
  73. package/tests/tests/params/params-use.js +0 -20
  74. package/tests/tests/params/params.js +0 -35
  75. package/tests/tests/req/req-accepts-charsets.js +0 -40
  76. package/tests/tests/req/req-accepts-encodings.js +0 -36
  77. package/tests/tests/req/req-accepts-languages.js +0 -41
  78. package/tests/tests/req/req-accepts.js +0 -41
  79. package/tests/tests/req/req-app.js +0 -17
  80. package/tests/tests/req/req-baseurl.js +0 -38
  81. package/tests/tests/req/req-connection.js +0 -19
  82. package/tests/tests/req/req-fresh.js +0 -59
  83. package/tests/tests/req/req-get.js +0 -78
  84. package/tests/tests/req/req-headers-distinct.js +0 -72
  85. package/tests/tests/req/req-headers.js +0 -72
  86. package/tests/tests/req/req-host.js +0 -45
  87. package/tests/tests/req/req-hostname.js +0 -45
  88. package/tests/tests/req/req-ip.js +0 -19
  89. package/tests/tests/req/req-is.js +0 -44
  90. package/tests/tests/req/req-original-url.js +0 -29
  91. package/tests/tests/req/req-param.js +0 -29
  92. package/tests/tests/req/req-protocol.js +0 -20
  93. package/tests/tests/req/req-query.js +0 -23
  94. package/tests/tests/req/req-range.js +0 -48
  95. package/tests/tests/req/req-raw-headers.js +0 -72
  96. package/tests/tests/req/req-subdomains.js +0 -48
  97. package/tests/tests/req/req-url-nested.js +0 -27
  98. package/tests/tests/req/req-url-optimized-router.js +0 -26
  99. package/tests/tests/req/req-url-optimized.js +0 -23
  100. package/tests/tests/req/req-url.js +0 -36
  101. package/tests/tests/req/req-xhr.js +0 -23
  102. package/tests/tests/res/head-content-length.js +0 -18
  103. package/tests/tests/res/head.js +0 -47
  104. package/tests/tests/res/injecting.js +0 -25
  105. package/tests/tests/res/piping.js +0 -23
  106. package/tests/tests/res/res-app.js +0 -17
  107. package/tests/tests/res/res-append.js +0 -24
  108. package/tests/tests/res/res-attachment.js +0 -19
  109. package/tests/tests/res/res-clear-cookie.js +0 -18
  110. package/tests/tests/res/res-cookie.js +0 -22
  111. package/tests/tests/res/res-download.js +0 -36
  112. package/tests/tests/res/res-format.js +0 -57
  113. package/tests/tests/res/res-get.js +0 -18
  114. package/tests/tests/res/res-headers-sent.js +0 -18
  115. package/tests/tests/res/res-json.js +0 -17
  116. package/tests/tests/res/res-jsonp.js +0 -25
  117. package/tests/tests/res/res-links.js +0 -21
  118. package/tests/tests/res/res-location.js +0 -34
  119. package/tests/tests/res/res-redirect.js +0 -46
  120. package/tests/tests/res/res-remove-header.js +0 -19
  121. package/tests/tests/res/res-send-file.js +0 -17
  122. package/tests/tests/res/res-send-status.js +0 -17
  123. package/tests/tests/res/res-send.js +0 -69
  124. package/tests/tests/res/res-set.js +0 -28
  125. package/tests/tests/res/res-status.js +0 -18
  126. package/tests/tests/res/res-type.js +0 -19
  127. package/tests/tests/res/res-vary.js +0 -19
  128. package/tests/tests/res/res-write.js +0 -29
  129. package/tests/tests/routers/complex-routers.js +0 -34
  130. package/tests/tests/routers/empty-router.js +0 -25
  131. package/tests/tests/routers/lot-of-routes.js +0 -38
  132. package/tests/tests/routers/mergeparams.js +0 -42
  133. package/tests/tests/routers/nested-routers.js +0 -52
  134. package/tests/tests/routers/router-options.js +0 -68
  135. package/tests/tests/routers/routers.js +0 -45
  136. package/tests/tests/routers/simple-routers.js +0 -35
  137. package/tests/tests/routing/all.js +0 -47
  138. package/tests/tests/routing/array-arguments.js +0 -35
  139. package/tests/tests/routing/array-use.js +0 -33
  140. package/tests/tests/routing/async-use.js +0 -25
  141. package/tests/tests/routing/complex-routes.js +0 -50
  142. package/tests/tests/routing/lot-of-param-routes.js +0 -26
  143. package/tests/tests/routing/lot-of-routes.js +0 -59
  144. package/tests/tests/routing/next-existent-optimized-route.js +0 -29
  145. package/tests/tests/routing/next-existent-route.js +0 -29
  146. package/tests/tests/routing/next-nonexistent-optimized-route.js +0 -19
  147. package/tests/tests/routing/next-nonexistent-route.js +0 -19
  148. package/tests/tests/routing/next-special-cases.js +0 -54
  149. package/tests/tests/routing/next-unoptimized.js +0 -39
  150. package/tests/tests/routing/no-path-use.js +0 -29
  151. package/tests/tests/routing/non-string-routes.js +0 -27
  152. package/tests/tests/routing/req-multiple-mountpaths.js +0 -34
  153. package/tests/tests/routing/simple-routes.js +0 -29
  154. package/tests/tests/routing/simple-use.js +0 -52
  155. package/tests/tests/routing/some-middlewares.js +0 -27
  156. package/tests/tests/routing/special-characters.js +0 -28
  157. package/tests/tests/routing/star.js +0 -31
  158. package/tests/tests/routing/sub-apps.js +0 -32
  159. package/tests/tests/routing/trailing-slash.js +0 -37
  160. package/tests/tests/routing/weird-route-start.js +0 -18
  161. package/tests/tests/send-file/accept-ranges.js +0 -26
  162. package/tests/tests/send-file/callback.js +0 -23
  163. package/tests/tests/send-file/default-error-routing.js +0 -21
  164. package/tests/tests/send-file/dotfiles.js +0 -24
  165. package/tests/tests/send-file/etag.js +0 -19
  166. package/tests/tests/send-file/fs-threads.js +0 -39
  167. package/tests/tests/send-file/head.js +0 -49
  168. package/tests/tests/send-file/headers.js +0 -23
  169. package/tests/tests/send-file/if-match.js +0 -31
  170. package/tests/tests/send-file/if-range.js +0 -37
  171. package/tests/tests/send-file/if-unmodified-since.js +0 -32
  172. package/tests/tests/send-file/immutable.js +0 -22
  173. package/tests/tests/send-file/large-file.js +0 -19
  174. package/tests/tests/send-file/last-modified.js +0 -21
  175. package/tests/tests/send-file/max-age.js +0 -21
  176. package/tests/tests/send-file/path-traversal.js +0 -35
  177. package/tests/tests/send-file/range.js +0 -57
  178. package/tests/tests/send-file/simple.js +0 -18
  179. package/tests/tests/settings/case-sensitive-routing.js +0 -48
  180. package/tests/tests/settings/env-errors.js +0 -38
  181. package/tests/tests/settings/etag.js +0 -36
  182. package/tests/tests/settings/json-escape.js +0 -45
  183. package/tests/tests/settings/json-replacer.js +0 -50
  184. package/tests/tests/settings/json-spaces.js +0 -44
  185. package/tests/tests/settings/query-parser.js +0 -45
  186. package/tests/tests/settings/strict-routing.js +0 -64
  187. package/tests/tests/settings/subdomain-offset.js +0 -38
  188. package/tests/tests/settings/trust-proxy-host.js +0 -58
  189. package/tests/tests/settings/trust-proxy-ip.js +0 -58
  190. package/tests/tests/settings/trust-proxy-ips.js +0 -58
  191. package/tests/tests/settings/trust-proxy-protocol.js +0 -46
  192. package/tests/tests/settings/x-powered-by.js +0 -32
  193. package/tests/uws.js +0 -14
@@ -1,59 +0,0 @@
1
- // must support a lot of routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const router = express.Router();
7
- const router2 = express.Router();
8
-
9
- for(let i = 0; i < 1000; i++) {
10
- router.get(`/${i}`, (req, res) => {
11
- res.send(i.toString());
12
- });
13
- }
14
-
15
- app.use("/rou+ter", router);
16
-
17
- for(let i = 0; i < 1000; i++) {
18
- router2.get(`/${i}`, (req, res) => {
19
- res.send(i.toString());
20
- });
21
- }
22
-
23
- app.use("/b", router2);
24
-
25
- for(let i = 0; i < 1000; i++) {
26
- app.get(`/${i}`, (req, res) => {
27
- res.send(i.toString());
28
- });
29
- }
30
-
31
- for(let i = 0; i < 1000; i++) {
32
- app.use((req, res, next) => {
33
- next();
34
- });
35
- }
36
-
37
- for(let i = 1000; i < 2000; i++) {
38
- app.get(`/${i}`, (req, res) => {
39
- res.send(i.toString());
40
- });
41
- }
42
-
43
- app.listen(13333, async () => {
44
- console.log('Server is running on port 13333');
45
-
46
- let res = await fetch('http://localhost:13333/999');
47
- console.log(await res.text());
48
-
49
- res = await fetch('http://localhost:13333/1999');
50
- console.log(await res.text());
51
-
52
- res = await fetch('http://localhost:13333/rouuuter/999');
53
- console.log(await res.text());
54
-
55
- res = await fetch('http://localhost:13333/b/999');
56
- console.log(await res.text());
57
-
58
- process.exit(0);
59
- })
@@ -1,29 +0,0 @@
1
- // must support existent next("route") (optimized)
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('/test', (req, res, next) => {
9
- console.log('1');
10
- next("route");
11
- });
12
-
13
- app.get('/test', (req, res) => {
14
- console.log('2');
15
- res.send('Hello World');
16
- });
17
-
18
- app.get('/test', (req, res) => {
19
- console.log('3');
20
- res.send('Hello World');
21
- });
22
-
23
- app.listen(13333, async () => {
24
- console.log('Server is running on port 13333');
25
-
26
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
27
- console.log(response);
28
- process.exit(0);
29
- });
@@ -1,29 +0,0 @@
1
- // must support existent next("route")
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('/te*st', (req, res, next) => {
9
- console.log('1');
10
- next("route");
11
- });
12
-
13
- app.get('/te*st', (req, res) => {
14
- console.log('2');
15
- res.send('Hello World');
16
- });
17
-
18
- app.get('/te*st', (req, res) => {
19
- console.log('3');
20
- res.send('Hello World');
21
- });
22
-
23
- app.listen(13333, async () => {
24
- console.log('Server is running on port 13333');
25
-
26
- const response = await fetch('http://localhost:13333/teest').then(res => res.text());
27
- console.log(response);
28
- process.exit(0);
29
- });
@@ -1,19 +0,0 @@
1
- // must support non-existent next("route") (optimized)
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('/test', (req, res, next) => {
9
- console.log('1');
10
- next("route");
11
- });
12
-
13
- app.listen(13333, async () => {
14
- console.log('Server is running on port 13333');
15
-
16
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
17
- console.log(response);
18
- process.exit(0);
19
- });
@@ -1,19 +0,0 @@
1
- // must support non-existent next("route")
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('te*st', (req, res, next) => {
9
- console.log('1');
10
- next("route");
11
- });
12
-
13
- app.listen(13333, async () => {
14
- console.log('Server is running on port 13333');
15
-
16
- const response = await fetch('http://localhost:13333/teest').then(res => res.text());
17
- console.log(response);
18
- process.exit(0);
19
- });
@@ -1,54 +0,0 @@
1
- // special cases for next()
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('/test', (req, res, next) => {
9
- console.log('first');
10
- next();
11
- });
12
-
13
- app.get('/test', (req, res, next) => {
14
- console.log('second');
15
- next('route');
16
- });
17
-
18
- app.get('/test', (req, res, next) => {
19
- console.log('third');
20
- next('route');
21
- });
22
-
23
- app.get('/test', (req, res, next) => {
24
- console.log('fourth');
25
- next('route');
26
- }, (req, res, next) => {
27
- console.log('fifth');
28
- next();
29
- });
30
-
31
- app.get('/test', (req, res, next) => {
32
- console.log('sixth');
33
- res.send('done');
34
- });
35
-
36
- app.get('/error', (req, res, next) => {
37
- next(new Error('test error'));
38
- });
39
-
40
- app.use((err, req, res, next) => {
41
- console.log(err.message);
42
- res.send('error');
43
- });
44
-
45
-
46
- app.listen(13333, async () => {
47
- console.log('Server is running on port 13333');
48
-
49
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
50
- console.log(response);
51
- const response2 = await fetch('http://localhost:13333/error').then(res => res.text());
52
- console.log(response2);
53
- process.exit(0);
54
- });
@@ -1,39 +0,0 @@
1
- // must support unoptimized after optimized
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('env', 'production');
7
-
8
- app.get('/test',
9
- (req, res, next) => {
10
- console.log('1');
11
- next();
12
- },
13
- (req, res, next) => {
14
- console.log('2');
15
- next('route');
16
- },
17
- (req, res, next) => {
18
- console.log('3');
19
- next();
20
- }
21
- );
22
-
23
- app.get('/test', (req, res, next) => {
24
- console.log('4');
25
- next();
26
- });
27
-
28
- app.get('/:test', (req, res) => {
29
- console.log('5');
30
- res.send('Hello World');
31
- });
32
-
33
- app.listen(13333, async () => {
34
- console.log('Server is running on port 13333');
35
-
36
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
37
- console.log(response);
38
- process.exit(0);
39
- });
@@ -1,29 +0,0 @@
1
- // must support use without path
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.use(async (req, res, next) => {
8
- console.log('use');
9
- next();
10
- });
11
-
12
- app.get('/test', (req, res, next) => {
13
- res.send('test');
14
- });
15
-
16
- app.get('/test/test', (req, res, next) => {
17
- res.send('test/test');
18
- });
19
-
20
- app.listen(13333, async () => {
21
- console.log('Server is running on port 13333');
22
-
23
- let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
24
- let output2 = await fetch('http://localhost:13333/test/test').then(res => res.text());
25
-
26
- console.log(output1);
27
- console.log(output2);
28
- process.exit(0);
29
- });
@@ -1,27 +0,0 @@
1
- // must support array and regex routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get(['/a', '/b'], (req, res) => {
8
- res.send('1');
9
- });
10
-
11
- app.get(/^\/c|\/d$/, (req, res) => {
12
- res.send('2');
13
- });
14
-
15
- app.listen(13333, async () => {
16
- console.log('Server is running on port 13333');
17
-
18
- let outputs = await Promise.all([
19
- fetch('http://localhost:13333/a').then(res => res.text()),
20
- fetch('http://localhost:13333/b').then(res => res.text()),
21
- fetch('http://localhost:13333/c').then(res => res.text()),
22
- fetch('http://localhost:13333/d').then(res => res.text()),
23
- ]);
24
-
25
- console.log(outputs.join(' '));
26
- process.exit(0);
27
- });
@@ -1,34 +0,0 @@
1
- // must support multiple mountpaths
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const router = express();
7
-
8
- router.get('/asdf', (req, res) => {
9
- res.send('asdf');
10
- });
11
-
12
- app.use('/abc', router);
13
- app.use('/def', router);
14
-
15
- app.use((req, res, next) => {
16
- res.send('404');
17
- });
18
-
19
- console.log(router.mountpath); // should be last one
20
-
21
- app.listen(13333, async () => {
22
- console.log('Server is running on port 13333');
23
-
24
- let res = await fetch('http://localhost:13333/abc/asdf');
25
- console.log(await res.text());
26
-
27
- res = await fetch('http://localhost:13333/def/asdf');
28
- console.log(await res.text());
29
-
30
- res = await fetch('http://localhost:13333/ghi/asdf');
31
- console.log(await res.text());
32
-
33
- process.exit(0);
34
- })
@@ -1,29 +0,0 @@
1
- // must support simple routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/', (req, res) => {
8
- res.send('Hello World');
9
- });
10
-
11
- app.get('/test', (req, res) => {
12
- res.send('test');
13
- });
14
-
15
- app.get('/test/testy', (req, res) => {
16
- res.send('testy');
17
- });
18
-
19
- app.listen(13333, async () => {
20
- console.log('Server is running on port 13333');
21
-
22
- let r1 = await fetch('http://localhost:13333/').then(res => res.text());
23
- let r2 = await fetch('http://localhost:13333/test').then(res => res.text());
24
- let r3 = await fetch('http://localhost:13333/testy').then(res => res.text());
25
- let r4 = await fetch('http://localhost:13333/test/testy').then(res => res.text());
26
-
27
- console.log(r1, r2, r3, r4);
28
- process.exit(0);
29
- });
@@ -1,52 +0,0 @@
1
- // must support simple "use"
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.use((req, res, next) => {
8
- console.log('u1');
9
- next();
10
- });
11
-
12
- app.use('/', (req, res, next) => {
13
- console.log('u2');
14
- next();
15
- });
16
-
17
- app.use('/tes', (req, res, next) => {
18
- console.log('u3');
19
- next();
20
- });
21
-
22
- app.use('/test', (req, res, next) => {
23
- console.log('u4');
24
- next();
25
- });
26
-
27
- app.get('/test', (req, res) => {
28
- res.send('test');
29
- });
30
-
31
- app.use('/asdf', (req, res, next) => {
32
- console.log('u5');
33
- next();
34
- });
35
-
36
- app.get('/asdf/asdf', (req, res) => {
37
- res.send('asdf');
38
- });
39
-
40
- app.use((req, res, next) => {
41
- console.log('404')
42
- });
43
-
44
- app.listen(13333, async () => {
45
- console.log('Server is running on port 13333');
46
-
47
- let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
48
- let output2 = await fetch('http://localhost:13333/asdf/asdf').then(res => res.text());
49
-
50
- console.log(output1, output2);
51
- process.exit(0);
52
- });
@@ -1,27 +0,0 @@
1
- // must support 10 nested middlewares
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- let middleware = (req, res, next) => {
7
- next();
8
- };
9
- let middlewares = [];
10
- for(let i = 0; i < 10; i++) {
11
- middlewares.push(middleware);
12
- }
13
-
14
- for(let i = 0; i < 100; i++) {
15
- app.get(`/${i}`, ...middlewares, (req, res) => {
16
- res.send(i.toString());
17
- });
18
- }
19
-
20
-
21
- app.listen(13333, async () => {
22
- console.log('Server is running on port 13333');
23
-
24
- let res = await fetch('http://localhost:13333/90');
25
- console.log(await res.text());
26
- process.exit(0);
27
- })
@@ -1,28 +0,0 @@
1
- // must support . and - in routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/test/hi.bye*a', (req, res) => {
8
- res.send('hi.bye');
9
- });
10
-
11
- app.get('/hi-bye*a', (req, res) => {
12
- res.send('hi-bye');
13
- });
14
-
15
- app.listen(13333, async () => {
16
- console.log('Server is running on port 13333');
17
-
18
- let res = await fetch('http://localhost:13333/test/hi.byeaa');
19
- console.log(await res.text());
20
-
21
- res = await fetch('http://localhost:13333/hi-byeaa');
22
- console.log(await res.text());
23
-
24
- res = await fetch('http://localhost:13333/test/hiAbyeaa');
25
- console.log(await res.text());
26
-
27
- process.exit(0);
28
- })
@@ -1,31 +0,0 @@
1
- // must support /* in routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/test/*', (req, res) => {
8
- res.send('test');
9
- });
10
-
11
- app.get('/*', (req, res) => {
12
- res.send('*');
13
- });
14
-
15
- app.listen(13333, async () => {
16
- console.log('Server is running on port 13333');
17
-
18
- let res = await fetch('http://localhost:13333/test/999');
19
- console.log(await res.text());
20
-
21
- res = await fetch('http://localhost:13333/test/sdfs/1999');
22
- console.log(await res.text());
23
-
24
- res = await fetch('http://localhost:13333/999');
25
- console.log(await res.text());
26
-
27
- res = await fetch('http://localhost:13333/sdfs/1999');
28
- console.log(await res.text());
29
-
30
- process.exit(0);
31
- })
@@ -1,32 +0,0 @@
1
- // must support sub-apps
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const app2 = express();
7
-
8
- app.get('/test', (req, res) => {
9
- res.send('test1');
10
- });
11
-
12
- app2.get('/test', (req, res) => {
13
- res.send('test2');
14
- });
15
-
16
- app.use('/asdf', app2);
17
-
18
- app.use((req, res, next) => {
19
- res.send('404');
20
- });
21
-
22
- app.listen(13333, async () => {
23
- console.log('Server is running on port 13333');
24
-
25
- const outputs = await Promise.all([
26
- fetch('http://localhost:13333/test').then(res => res.text()),
27
- fetch('http://localhost:13333/asdf/test').then(res => res.text()),
28
- ]);
29
-
30
- console.log(outputs.join(' '));
31
- process.exit(0);
32
- });
@@ -1,37 +0,0 @@
1
- // must support trailing slash in routes
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/test', (req, res) => {
8
- res.send('test');
9
- });
10
-
11
- app.get("/baba/", (req, res) => {
12
- res.send("baba");
13
- });
14
-
15
- app.listen(13333, async () => {
16
- console.log('Server is running on port 13333');
17
-
18
- let res = await fetch('http://localhost:13333/test');
19
- console.log(await res.text());
20
-
21
- res = await fetch('http://localhost:13333/test/');
22
- console.log(await res.text());
23
-
24
- res = await fetch('http://localhost:13333/test/test');
25
- console.log(await res.text());
26
-
27
- res = await fetch('http://localhost:13333/baba');
28
- console.log(await res.text());
29
-
30
- res = await fetch('http://localhost:13333/baba/');
31
- console.log(await res.text());
32
-
33
- res = await fetch('http://localhost:13333/test/?test=1');
34
- console.log(await res.text());
35
-
36
- process.exit(0);
37
- })
@@ -1,18 +0,0 @@
1
- // must match express behavior for non-slash route start
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get("test", (req, res) => {
8
- res.send("test");
9
- });
10
-
11
- app.listen(13333, async () => {
12
- console.log('Server is running on port 13333');
13
-
14
- let res = await fetch('http://localhost:13333/test');
15
- console.log(await res.text());
16
-
17
- process.exit(0);
18
- })
@@ -1,26 +0,0 @@
1
- // must support acceptRanges option
2
-
3
- const express = require("express");
4
- const path = require("path");
5
-
6
- const app = express();
7
-
8
- app.get('/test', (req, res) => {
9
- res.sendFile('src/index.js', { root: '.', acceptRanges: false });
10
- });
11
-
12
- app.use((err, req, res, next) => {
13
- res.status(500).send(err.message);
14
- });
15
-
16
- app.listen(13333, async () => {
17
- console.log('Server is running on port 13333');
18
-
19
- const response = await fetch('http://localhost:13333/test', {
20
- headers: {
21
- Range: 'bytes=0-10'
22
- }
23
- });
24
- console.log(await response.text(), response.headers.get('Content-Range'), response.headers.get('Content-Length'), response.status);
25
- process.exit(0);
26
- });
@@ -1,23 +0,0 @@
1
- // must support callback
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/test', (req, res) => {
8
- res.sendFile('src/asdf.js', { root: '.' }, (err) => {
9
- res.status(500).send(err?.message ? `caught error: ${err.message}` : 'no error');
10
- });
11
- });
12
-
13
- app.use((err, req, res, next) => {
14
- res.status(500).send(`uncaught error: ${err.message}`);
15
- });
16
-
17
- app.listen(13333, async () => {
18
- console.log('Server is running on port 13333');
19
-
20
- const response = await fetch('http://localhost:13333/test');
21
- console.log(await response.text());
22
- process.exit(0);
23
- });
@@ -1,21 +0,0 @@
1
- // must continue routing by default
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/test', (req, res) => {
8
- res.sendFile('src/asdf.js', { root: '.' });
9
- });
10
-
11
- app.use((err, req, res, next) => {
12
- res.status(404).send('404: File not found');
13
- });
14
-
15
- app.listen(13333, async () => {
16
- console.log('Server is running on port 13333');
17
-
18
- const response = await fetch('http://localhost:13333/test');
19
- console.log(await response.text());
20
- process.exit(0);
21
- });