ultimate-express 1.0.0 → 1.0.2

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 (191) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +2 -1
  3. package/package.json +8 -4
  4. package/.github/workflows/test.yml +0 -27
  5. package/tests/index.js +0 -64
  6. package/tests/parts/.test/index.html +0 -11
  7. package/tests/parts/big.jpg +0 -0
  8. package/tests/parts/index.art +0 -12
  9. package/tests/parts/index.dot +0 -12
  10. package/tests/parts/index.ejs +0 -12
  11. package/tests/parts/index.handlebars +0 -2
  12. package/tests/parts/index.html +0 -12
  13. package/tests/parts/index.mustache +0 -12
  14. package/tests/parts/index.pug +0 -6
  15. package/tests/parts/index.swig +0 -12
  16. package/tests/parts/layouts/main.handlebars +0 -12
  17. package/tests/preload.cjs +0 -5
  18. package/tests/singular.js +0 -41
  19. package/tests/tests/app/app-engine.js +0 -8
  20. package/tests/tests/app/app-on-mount.js +0 -24
  21. package/tests/tests/app/app-path.js +0 -21
  22. package/tests/tests/app/app-route.js +0 -30
  23. package/tests/tests/app/options.js +0 -16
  24. package/tests/tests/app/setting-inheritance.js +0 -16
  25. package/tests/tests/engines/art-template.js +0 -33
  26. package/tests/tests/engines/dot.js +0 -28
  27. package/tests/tests/engines/ejs.js +0 -25
  28. package/tests/tests/engines/handlebars.js +0 -28
  29. package/tests/tests/engines/mustache.js +0 -28
  30. package/tests/tests/engines/pug.js +0 -25
  31. package/tests/tests/engines/swig.js +0 -28
  32. package/tests/tests/errors/error-handling-middleware.js +0 -22
  33. package/tests/tests/errors/next-error-optimized.js +0 -26
  34. package/tests/tests/errors/next-error.js +0 -26
  35. package/tests/tests/errors/unexpected-error-handling.js +0 -18
  36. package/tests/tests/listen/listen-random.js +0 -11
  37. package/tests/tests/listen/listen-specific.js +0 -17
  38. package/tests/tests/middlewares/body-json.js +0 -31
  39. package/tests/tests/middlewares/body-raw-deflate.js +0 -43
  40. package/tests/tests/middlewares/body-raw-gzip.js +0 -43
  41. package/tests/tests/middlewares/body-raw.js +0 -41
  42. package/tests/tests/middlewares/body-text.js +0 -27
  43. package/tests/tests/middlewares/body-urlencoded.js +0 -30
  44. package/tests/tests/middlewares/cookie-parser-signed.js +0 -31
  45. package/tests/tests/middlewares/cookie-parser.js +0 -28
  46. package/tests/tests/middlewares/cookie-session.js +0 -40
  47. package/tests/tests/middlewares/cors.js +0 -29
  48. package/tests/tests/middlewares/errorhandler.js +0 -26
  49. package/tests/tests/middlewares/express-fileupload-temp.js +0 -46
  50. package/tests/tests/middlewares/express-fileupload.js +0 -28
  51. package/tests/tests/middlewares/express-rate-limit.js +0 -33
  52. package/tests/tests/middlewares/express-session.js +0 -37
  53. package/tests/tests/middlewares/express-static-options.js +0 -72
  54. package/tests/tests/middlewares/express-static.js +0 -40
  55. package/tests/tests/middlewares/method-override.js +0 -33
  56. package/tests/tests/middlewares/multer.js +0 -43
  57. package/tests/tests/middlewares/multiple-middlewares.js +0 -37
  58. package/tests/tests/middlewares/response-time.js +0 -29
  59. package/tests/tests/middlewares/serve-index.js +0 -38
  60. package/tests/tests/middlewares/serve-static.js +0 -38
  61. package/tests/tests/middlewares/vhost.js +0 -50
  62. package/tests/tests/params/array-param.js +0 -30
  63. package/tests/tests/params/nested-params.js +0 -24
  64. package/tests/tests/params/param-errors.js +0 -56
  65. package/tests/tests/params/param-function.js +0 -49
  66. package/tests/tests/params/param-next-route.js +0 -48
  67. package/tests/tests/params/param-optimized.js +0 -38
  68. package/tests/tests/params/param-use.js +0 -39
  69. package/tests/tests/params/param.js +0 -68
  70. package/tests/tests/params/params-regex.js +0 -26
  71. package/tests/tests/params/params-use.js +0 -20
  72. package/tests/tests/params/params.js +0 -35
  73. package/tests/tests/req/req-accepts-charsets.js +0 -40
  74. package/tests/tests/req/req-accepts-encodings.js +0 -36
  75. package/tests/tests/req/req-accepts-languages.js +0 -41
  76. package/tests/tests/req/req-accepts.js +0 -41
  77. package/tests/tests/req/req-app.js +0 -17
  78. package/tests/tests/req/req-baseurl.js +0 -38
  79. package/tests/tests/req/req-connection.js +0 -19
  80. package/tests/tests/req/req-fresh.js +0 -59
  81. package/tests/tests/req/req-get.js +0 -78
  82. package/tests/tests/req/req-headers-distinct.js +0 -72
  83. package/tests/tests/req/req-headers.js +0 -72
  84. package/tests/tests/req/req-host.js +0 -45
  85. package/tests/tests/req/req-hostname.js +0 -45
  86. package/tests/tests/req/req-ip.js +0 -19
  87. package/tests/tests/req/req-is.js +0 -44
  88. package/tests/tests/req/req-original-url.js +0 -29
  89. package/tests/tests/req/req-param.js +0 -29
  90. package/tests/tests/req/req-protocol.js +0 -20
  91. package/tests/tests/req/req-query.js +0 -23
  92. package/tests/tests/req/req-range.js +0 -48
  93. package/tests/tests/req/req-raw-headers.js +0 -72
  94. package/tests/tests/req/req-subdomains.js +0 -48
  95. package/tests/tests/req/req-url-nested.js +0 -27
  96. package/tests/tests/req/req-url-optimized-router.js +0 -26
  97. package/tests/tests/req/req-url-optimized.js +0 -23
  98. package/tests/tests/req/req-url.js +0 -36
  99. package/tests/tests/req/req-xhr.js +0 -23
  100. package/tests/tests/res/head-content-length.js +0 -18
  101. package/tests/tests/res/head.js +0 -47
  102. package/tests/tests/res/injecting.js +0 -25
  103. package/tests/tests/res/piping.js +0 -23
  104. package/tests/tests/res/res-app.js +0 -17
  105. package/tests/tests/res/res-append.js +0 -24
  106. package/tests/tests/res/res-attachment.js +0 -19
  107. package/tests/tests/res/res-clear-cookie.js +0 -18
  108. package/tests/tests/res/res-cookie.js +0 -22
  109. package/tests/tests/res/res-download.js +0 -36
  110. package/tests/tests/res/res-format.js +0 -57
  111. package/tests/tests/res/res-get.js +0 -18
  112. package/tests/tests/res/res-headers-sent.js +0 -18
  113. package/tests/tests/res/res-json.js +0 -17
  114. package/tests/tests/res/res-jsonp.js +0 -25
  115. package/tests/tests/res/res-links.js +0 -21
  116. package/tests/tests/res/res-location.js +0 -34
  117. package/tests/tests/res/res-redirect.js +0 -46
  118. package/tests/tests/res/res-remove-header.js +0 -19
  119. package/tests/tests/res/res-send-file.js +0 -17
  120. package/tests/tests/res/res-send-status.js +0 -17
  121. package/tests/tests/res/res-send.js +0 -69
  122. package/tests/tests/res/res-set.js +0 -28
  123. package/tests/tests/res/res-status.js +0 -18
  124. package/tests/tests/res/res-type.js +0 -19
  125. package/tests/tests/res/res-vary.js +0 -19
  126. package/tests/tests/res/res-write.js +0 -29
  127. package/tests/tests/routers/complex-routers.js +0 -34
  128. package/tests/tests/routers/empty-router.js +0 -25
  129. package/tests/tests/routers/lot-of-routes.js +0 -38
  130. package/tests/tests/routers/mergeparams.js +0 -42
  131. package/tests/tests/routers/nested-routers.js +0 -52
  132. package/tests/tests/routers/router-options.js +0 -68
  133. package/tests/tests/routers/routers.js +0 -45
  134. package/tests/tests/routers/simple-routers.js +0 -35
  135. package/tests/tests/routing/all.js +0 -47
  136. package/tests/tests/routing/array-arguments.js +0 -35
  137. package/tests/tests/routing/array-use.js +0 -33
  138. package/tests/tests/routing/async-use.js +0 -25
  139. package/tests/tests/routing/complex-routes.js +0 -50
  140. package/tests/tests/routing/lot-of-param-routes.js +0 -26
  141. package/tests/tests/routing/lot-of-routes.js +0 -59
  142. package/tests/tests/routing/next-existent-optimized-route.js +0 -29
  143. package/tests/tests/routing/next-existent-route.js +0 -29
  144. package/tests/tests/routing/next-nonexistent-optimized-route.js +0 -19
  145. package/tests/tests/routing/next-nonexistent-route.js +0 -19
  146. package/tests/tests/routing/next-special-cases.js +0 -54
  147. package/tests/tests/routing/next-unoptimized.js +0 -39
  148. package/tests/tests/routing/no-path-use.js +0 -29
  149. package/tests/tests/routing/non-string-routes.js +0 -27
  150. package/tests/tests/routing/req-multiple-mountpaths.js +0 -34
  151. package/tests/tests/routing/simple-routes.js +0 -29
  152. package/tests/tests/routing/simple-use.js +0 -52
  153. package/tests/tests/routing/some-middlewares.js +0 -27
  154. package/tests/tests/routing/special-characters.js +0 -28
  155. package/tests/tests/routing/star.js +0 -31
  156. package/tests/tests/routing/sub-apps.js +0 -32
  157. package/tests/tests/routing/trailing-slash.js +0 -37
  158. package/tests/tests/routing/weird-route-start.js +0 -18
  159. package/tests/tests/send-file/accept-ranges.js +0 -26
  160. package/tests/tests/send-file/callback.js +0 -23
  161. package/tests/tests/send-file/default-error-routing.js +0 -21
  162. package/tests/tests/send-file/dotfiles.js +0 -24
  163. package/tests/tests/send-file/etag.js +0 -19
  164. package/tests/tests/send-file/fs-threads.js +0 -39
  165. package/tests/tests/send-file/head.js +0 -49
  166. package/tests/tests/send-file/headers.js +0 -23
  167. package/tests/tests/send-file/if-match.js +0 -31
  168. package/tests/tests/send-file/if-range.js +0 -37
  169. package/tests/tests/send-file/if-unmodified-since.js +0 -32
  170. package/tests/tests/send-file/immutable.js +0 -22
  171. package/tests/tests/send-file/large-file.js +0 -19
  172. package/tests/tests/send-file/last-modified.js +0 -21
  173. package/tests/tests/send-file/max-age.js +0 -21
  174. package/tests/tests/send-file/path-traversal.js +0 -35
  175. package/tests/tests/send-file/range.js +0 -57
  176. package/tests/tests/send-file/simple.js +0 -18
  177. package/tests/tests/settings/case-sensitive-routing.js +0 -48
  178. package/tests/tests/settings/env-errors.js +0 -38
  179. package/tests/tests/settings/etag.js +0 -36
  180. package/tests/tests/settings/json-escape.js +0 -45
  181. package/tests/tests/settings/json-replacer.js +0 -50
  182. package/tests/tests/settings/json-spaces.js +0 -44
  183. package/tests/tests/settings/query-parser.js +0 -45
  184. package/tests/tests/settings/strict-routing.js +0 -64
  185. package/tests/tests/settings/subdomain-offset.js +0 -38
  186. package/tests/tests/settings/trust-proxy-host.js +0 -58
  187. package/tests/tests/settings/trust-proxy-ip.js +0 -58
  188. package/tests/tests/settings/trust-proxy-ips.js +0 -58
  189. package/tests/tests/settings/trust-proxy-protocol.js +0 -46
  190. package/tests/tests/settings/x-powered-by.js +0 -32
  191. package/tests/uws.js +0 -14
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2024 dimden.dev
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -6,9 +6,10 @@ This library is a very fast re-implementation of Express.js 4.
6
6
  It is designed to be a drop-in replacement for Express.js, with the same API and functionality, while being much faster. It is not a fork of Express.js.
7
7
  To make sure µExpress matches behavior of Express in all cases, we run all tests with Express first, and then with µExpress and compare results to make sure they match.
8
8
 
9
- `npm install ultimate-express`
9
+ [`npm install ultimate-express`](https://npmjs.com/package/ultimate-express)
10
10
 
11
11
  ![Node.js >= 16.0.0](https://img.shields.io/badge/Node.js-%3E=16.0.0-green)
12
+ [![npm](https://img.shields.io/npm/v/ultimate-express)](https://npmjs.com/package/ultimate-express)
12
13
 
13
14
  ## Difference from similar projects
14
15
 
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The Ultimate Express. Fastest http server with full Express compatibility, based on uWebSockets.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "test": "node tests/index.js"
8
8
  },
9
+ "files": [
10
+ "src",
11
+ "EXPRESS_LICENSE"
12
+ ],
9
13
  "repository": {
10
14
  "type": "git",
11
15
  "url": "git+https://github.com/dimdenGD/u-express.git"
@@ -25,7 +29,7 @@
25
29
  "uws"
26
30
  ],
27
31
  "author": "dimden.dev",
28
- "license": "UNLICENSED",
32
+ "license": "Apache-2.0",
29
33
  "bugs": {
30
34
  "url": "https://github.com/dimdenGD/u-express/issues"
31
35
  },
@@ -34,10 +38,8 @@
34
38
  "accepts": "^1.3.8",
35
39
  "body-parser": "^1.20.3",
36
40
  "cookie": "^0.6.0",
37
- "cookie-session": "^2.1.0",
38
41
  "cookie-signature": "^1.2.1",
39
42
  "etag": "^1.8.1",
40
- "express-rate-limit": "^7.4.0",
41
43
  "fresh": "^0.5.2",
42
44
  "mime-types": "^2.1.35",
43
45
  "ms": "^2.1.3",
@@ -52,6 +54,7 @@
52
54
  },
53
55
  "devDependencies": {
54
56
  "cookie-parser": "^1.4.6",
57
+ "cookie-session": "^2.1.0",
55
58
  "cors": "^2.8.5",
56
59
  "ejs": "^3.1.10",
57
60
  "errorhandler": "^1.5.1",
@@ -61,6 +64,7 @@
61
64
  "express-dot-engine": "^1.0.8",
62
65
  "express-fileupload": "^1.5.1",
63
66
  "express-handlebars": "^8.0.1",
67
+ "express-rate-limit": "^7.4.0",
64
68
  "express-session": "^1.18.0",
65
69
  "method-override": "^3.0.0",
66
70
  "multer": "^1.4.5-lts.1",
@@ -1,27 +0,0 @@
1
- name: Run tests
2
-
3
- on:
4
- push:
5
- branches: [ "main" ]
6
- pull_request:
7
- branches: [ "main" ]
8
-
9
- jobs:
10
- test:
11
-
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - name: Checkout Source Tree
16
- uses: actions/checkout@v3
17
-
18
- - name: Setup Node.js environment
19
- uses: actions/setup-node@v4
20
- with:
21
- node-version: 20
22
-
23
- - name: Install dependencies
24
- run: npm install --include=dev
25
-
26
- - name: Run tests
27
- run: npm run test
package/tests/index.js DELETED
@@ -1,64 +0,0 @@
1
- // npm run test - runs all tests
2
- // npm run test routing - runs all tests in the routing category
3
- // npm run test tests/tests/routing - runs all tests in the routing category
4
- // npm run test tests/tests/listen/listen-random.js - runs the test at tests/tests/listen/listen-random.js
5
-
6
- const fs = require("fs");
7
- const path = require("path");
8
- const test = require("node:test");
9
- const childProcess = require("node:child_process");
10
- const assert = require("node:assert");
11
-
12
- const testPath = path.join(__dirname, 'tests');
13
-
14
- let testCategories = fs.readdirSync(testPath).sort((a, b) => parseInt(a) - parseInt(b));
15
- const filterPath = process.argv[2];
16
-
17
- if(filterPath) {
18
- if(!filterPath.endsWith('.js')) {
19
- testCategories = testCategories.filter(category => category.startsWith(path.basename(filterPath)));
20
- } else {
21
- testCategories = [path.dirname(filterPath).split(path.sep).pop()];
22
- }
23
- }
24
-
25
- for (const testCategory of testCategories) {
26
- test(testCategory, async () => {
27
- let tests = fs.readdirSync(path.join(__dirname, 'tests', testCategory)).sort((a, b) => parseInt(a) - parseInt(b));
28
- for (const testName of tests) {
29
- if(filterPath && filterPath.endsWith('.js')) {
30
- if(path.basename(testName) !== path.basename(filterPath)) {
31
- continue;
32
- }
33
- }
34
- let testPath = path.join(__dirname, 'tests', testCategory, testName);
35
- let testCode = fs.readFileSync(testPath, 'utf8').replace(`const express = require("../../../src/index.js");`, 'const express = require("express");');
36
- fs.writeFileSync(testPath, testCode);
37
- let testDescription = testCode.split('\n')[0].slice(2).trim();
38
- if(testDescription.endsWith('OFF')) {
39
- return true;
40
- }
41
-
42
- await new Promise(resolve => {
43
- test(testDescription, () => {
44
- process.stdout.write(testDescription + '...');
45
- try {
46
- let expressOutput = childProcess.execSync(`node ${testPath}`).toString();
47
-
48
- fs.writeFileSync(testPath, testCode.replace(`const express = require("express");`, `const express = require("../../../src/index.js");`));
49
- let uExpressOutput = childProcess.execSync(`node ${testPath}`).toString();
50
-
51
- assert.strictEqual(uExpressOutput, expressOutput);
52
- console.log('\x1b[32mOK\x1b[0m');
53
- } catch (error) {
54
- console.log('\x1b[31mFAIL\x1b[0m');
55
- throw error;
56
- } finally {
57
- fs.writeFileSync(testPath, testCode);
58
- resolve();
59
- }
60
- });
61
- });
62
- }
63
- });
64
- }
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document</title>
7
- </head>
8
- <body>
9
- test
10
- </body>
11
- </html>
Binary file
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>{{ title }}</title>
7
- </head>
8
- <body>
9
- <h1>{{ message }}</h1>
10
- <span>{{ asdf }}</span>
11
- </body>
12
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>[[= title ]]</title>
7
- </head>
8
- <body>
9
- <h1>[[= message ]]</h1>
10
- <span>[[= asdf ]]</span>
11
- </body>
12
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title><%= title %></title>
7
- </head>
8
- <body>
9
- <h1><%= message %></h1>
10
- <span><%= asdf %></span>
11
- </body>
12
- </html>
@@ -1,2 +0,0 @@
1
- <h1>{{{ message }}}</h1>
2
- <span>{{{ asdf }}}</span>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>test</title>
7
- </head>
8
- <body>
9
- <h1>test</h1>
10
- <span>index test</span>
11
- </body>
12
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>{{ title }}</title>
7
- </head>
8
- <body>
9
- <h1>{{ message }}</h1>
10
- <span>{{ asdf }}</span>
11
- </body>
12
- </html>
@@ -1,6 +0,0 @@
1
- html
2
- head
3
- title= title
4
- body
5
- h1= message
6
- span= asdf
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>{{ title }}</title>
7
- </head>
8
- <body>
9
- <h1>{{ message }}</h1>
10
- <span>{{ asdf }}</span>
11
- </body>
12
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Example App</title>
6
- </head>
7
- <body>
8
-
9
- {{{body}}}
10
-
11
- </body>
12
- </html>
package/tests/preload.cjs DELETED
@@ -1,5 +0,0 @@
1
- let _processExit = process.exit;
2
- process.exit = (...args) => {
3
- console.log('process.exit', ...args);
4
- // _processExit(...args);
5
- };
package/tests/singular.js DELETED
@@ -1,41 +0,0 @@
1
- const childProcess = require("child_process");
2
- const fs = require("fs");
3
- const exitHook = require("exit-hook");
4
- const { exit } = require("process");
5
-
6
- let args = process.argv.slice(2);
7
-
8
- let u = args.some(arg => arg === '-u');
9
- args = args.filter(arg => arg !== '-u');
10
-
11
- let path = args[0];
12
-
13
- if (!path) {
14
- console.error('Usage: node singular.js [-u] <path>');
15
- process.exit(1);
16
- }
17
-
18
- if (u) {
19
- console.log('Running as µExpress');
20
- let code = fs.readFileSync(path, 'utf8');
21
- fs.writeFileSync(path, code.replace('const express = require("express");', 'const express = require("../../../src/index.js");'));
22
- } else {
23
- let code = fs.readFileSync(path, 'utf8');
24
- fs.writeFileSync(path, code.replace(`const express = require("../../../src/index.js");`, `const express = require("express");`));
25
- console.log('Running as normal Express');
26
- }
27
-
28
- let node = childProcess.spawn('node', ['-r', './tests/preload.cjs', path]);
29
-
30
- node.stdout.on('data', data => {
31
- console.log(data.toString());
32
- });
33
-
34
- node.stderr.on('data', data => {
35
- console.error(data.toString());
36
- });
37
-
38
- exitHook(() => {
39
- let code = fs.readFileSync(path, 'utf8');
40
- fs.writeFileSync(path, code.replaceAll(`const express = require("../../../src/index.js");`, `const express = require("express");`));
41
- });
@@ -1,8 +0,0 @@
1
- // must support app.engine()
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.engine('asdf', function test() {});
7
-
8
- console.log(app.engines);
@@ -1,24 +0,0 @@
1
- // must emit 'mount' when using subapp
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const student = express();
7
- const teacher = express();
8
-
9
- teacher.on('mount', (parent) => {
10
- console.log('aaaaaaaaaaaaaaaaaaaaaaaaaa');
11
- });
12
-
13
- student.on('mount', (parent) => {
14
- console.log('dewd');
15
- });
16
-
17
- app.use('/student', student);
18
- app.use('/teacher', teacher);
19
-
20
- app.listen(13333, (err) => {
21
- console.log("Server is running on port 13333");
22
-
23
- process.exit(0);
24
- });
@@ -1,21 +0,0 @@
1
- // must support app.path()
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const app2 = express();
7
- const app3 = express();
8
- const router = express.Router();
9
-
10
- app.use('/abc', app2);
11
- app2.use('/def', app3);
12
-
13
- app.use((req, res, next) => {
14
- res.send('404');
15
- });
16
-
17
- console.log(app.path());
18
- console.log(app2.path());
19
- console.log(app3.path());
20
- console.log(router?.path?.());
21
- console.log(app.mountpath, app2.mountpath, app3.mountpath);
@@ -1,30 +0,0 @@
1
- // must support app.route()
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.get('/asdf', (req, res) => {
8
- res.send('asdf');
9
- });
10
-
11
- app.route('/test')
12
- .get((req, res) => {
13
- res.send('test1');
14
- })
15
- .post((req, res) => {
16
- res.send('test2');
17
- });
18
-
19
- app.listen(13333, async () => {
20
- console.log('Server is running on port 13333');
21
-
22
- let outputs = await Promise.all([
23
- fetch('http://localhost:13333/asdf').then(res => res.text()),
24
- fetch('http://localhost:13333/test').then(res => res.text()),
25
- fetch('http://localhost:13333/test', { method: 'POST' }).then(res => res.text()),
26
- ]);
27
-
28
- console.log(outputs.join(' '));
29
- process.exit(0);
30
- });
@@ -1,16 +0,0 @@
1
- // must support setting and getting options
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
-
7
- app.set('case sensitive routing', true);
8
- console.log(app.get('case sensitive routing'));
9
-
10
- app.enable('x-powered-by');
11
- console.log(app.enabled('x-powered-by'));
12
-
13
- app.disable('x-powered-by');
14
- console.log(app.enabled('x-powered-by'));
15
-
16
- console.log(app.disabled('x-powered-by'));
@@ -1,16 +0,0 @@
1
- // must support app.path()
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- const app2 = express();
7
-
8
- app.set('case sensitive routing', true);
9
- app.set('jsonp callback name', 'cb');
10
-
11
- app.use('/abc', app2);
12
-
13
-
14
- console.log(app2.get('case sensitive routing'));
15
- console.log(app2.get('jsonp callback name'));
16
-
@@ -1,33 +0,0 @@
1
- // must support art template engine
2
-
3
- const express = require("express");
4
- const artTemplate = require("express-art-template");
5
-
6
- const app = express();
7
-
8
- app.engine('art', artTemplate);
9
- app.set('views', 'tests/parts');
10
- app.set('view engine', 'art');
11
- app.set('view options', {
12
- debug: process.env.NODE_ENV !== 'production',
13
- ignore: ['Math', 'Date', 'JSON', 'encodeURIComponent'],
14
- minimize: false
15
- });
16
-
17
- app.get('/test', (req, res) => {
18
- res.locals.asdf = 'locals test';
19
- res.render('index', { title: 'Hey', message: 'Hello there!' });
20
- });
21
-
22
- app.use((err, req, res, next) => {
23
- console.log(err);
24
- res.status(500).send(`whoops!`);
25
- });
26
-
27
- app.listen(13333, async () => {
28
- console.log('Server is running on port 13333');
29
-
30
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
31
- console.log(response);
32
- process.exit(0);
33
- });
@@ -1,28 +0,0 @@
1
- // must support doT engine
2
-
3
- const express = require("express");
4
- const dot = require("express-dot-engine");
5
-
6
- const app = express();
7
-
8
- app.engine('dot', dot.__express);
9
- app.set('view engine', 'dot');
10
- app.set('views', 'tests/parts');
11
-
12
- app.get('/test', (req, res) => {
13
- res.locals.asdf = 'locals test';
14
- res.render('index.ejs', { title: 'Hey', message: 'Hello there!' });
15
- });
16
-
17
- app.use((err, req, res, next) => {
18
- console.log(err);
19
- res.status(500).send(`whoops!`);
20
- });
21
-
22
- app.listen(13333, async () => {
23
- console.log('Server is running on port 13333');
24
-
25
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
26
- console.log(response);
27
- process.exit(0);
28
- });
@@ -1,25 +0,0 @@
1
- // must support ejs engine
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('view engine', 'ejs');
7
- app.set('views', 'tests/parts');
8
-
9
- app.get('/test', (req, res) => {
10
- res.locals.asdf = 'locals test';
11
- res.render('index.ejs', { title: 'Hey', message: 'Hello there!' });
12
- });
13
-
14
- app.use((err, req, res, next) => {
15
- console.log(err);
16
- res.status(500).send(`whoops!`);
17
- });
18
-
19
- app.listen(13333, async () => {
20
- console.log('Server is running on port 13333');
21
-
22
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
23
- console.log(response);
24
- process.exit(0);
25
- });
@@ -1,28 +0,0 @@
1
- // must support handlebars engine
2
-
3
- const express = require("express");
4
- const { engine } = require("express-handlebars");
5
-
6
- const app = express();
7
-
8
- app.engine('handlebars', engine());
9
- app.set('view engine', 'handlebars');
10
- app.set('views', 'tests/parts');
11
-
12
- app.get('/test', (req, res) => {
13
- res.locals.asdf = 'locals test';
14
- res.render('index', { title: 'Hey', message: 'Hello there!' });
15
- });
16
-
17
- app.use((err, req, res, next) => {
18
- console.log(err);
19
- res.status(500).send(`whoops!`);
20
- });
21
-
22
- app.listen(13333, async () => {
23
- console.log('Server is running on port 13333');
24
-
25
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
26
- console.log(response);
27
- process.exit(0);
28
- });
@@ -1,28 +0,0 @@
1
- // must support mustache engine
2
-
3
- const express = require("express");
4
- const mustacheExpress = require("mustache-express");
5
-
6
- const app = express();
7
-
8
- app.engine('mustache', mustacheExpress());
9
- app.set('view engine', 'mustache');
10
- app.set('views', 'tests/parts');
11
-
12
- app.get('/test', (req, res) => {
13
- res.locals.asdf = 'locals test';
14
- res.render('index', { title: 'Hey', message: 'Hello there!' });
15
- });
16
-
17
- app.use((err, req, res, next) => {
18
- console.log(err);
19
- res.status(500).send(`whoops!`);
20
- });
21
-
22
- app.listen(13333, async () => {
23
- console.log('Server is running on port 13333');
24
-
25
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
26
- console.log(response);
27
- process.exit(0);
28
- });
@@ -1,25 +0,0 @@
1
- // must support pug engine
2
-
3
- const express = require("express");
4
-
5
- const app = express();
6
- app.set('view engine', 'pug');
7
- app.set('views', 'tests/parts');
8
-
9
- app.get('/test', (req, res) => {
10
- res.locals.asdf = 'locals test';
11
- res.render('index', { title: 'Hey', message: 'Hello there!' });
12
- });
13
-
14
- app.use((err, req, res, next) => {
15
- console.log(err);
16
- res.status(500).send(`whoops!`);
17
- });
18
-
19
- app.listen(13333, async () => {
20
- console.log('Server is running on port 13333');
21
-
22
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
23
- console.log(response);
24
- process.exit(0);
25
- });
@@ -1,28 +0,0 @@
1
- // must support swig engine
2
-
3
- const express = require("express");
4
- const swig = require("swig");
5
-
6
- const app = express();
7
-
8
- app.engine('swig', swig.renderFile);
9
- app.set('view engine', 'swig');
10
- app.set('views', 'tests/parts');
11
-
12
- app.get('/test', (req, res) => {
13
- res.locals.asdf = 'locals test';
14
- res.render('index', { title: 'Hey', message: 'Hello there!' });
15
- });
16
-
17
- app.use((err, req, res, next) => {
18
- console.log(err);
19
- res.status(500).send(`whoops!`);
20
- });
21
-
22
- app.listen(13333, async () => {
23
- console.log('Server is running on port 13333');
24
-
25
- const response = await fetch('http://localhost:13333/test').then(res => res.text());
26
- console.log(response);
27
- process.exit(0);
28
- });