ultimate-express 1.0.1 → 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.
- package/package.json +7 -3
- package/.github/workflows/test.yml +0 -27
- package/tests/index.js +0 -64
- package/tests/parts/.test/index.html +0 -11
- package/tests/parts/big.jpg +0 -0
- package/tests/parts/index.art +0 -12
- package/tests/parts/index.dot +0 -12
- package/tests/parts/index.ejs +0 -12
- package/tests/parts/index.handlebars +0 -2
- package/tests/parts/index.html +0 -12
- package/tests/parts/index.mustache +0 -12
- package/tests/parts/index.pug +0 -6
- package/tests/parts/index.swig +0 -12
- package/tests/parts/layouts/main.handlebars +0 -12
- package/tests/preload.cjs +0 -5
- package/tests/singular.js +0 -41
- package/tests/tests/app/app-engine.js +0 -8
- package/tests/tests/app/app-on-mount.js +0 -24
- package/tests/tests/app/app-path.js +0 -21
- package/tests/tests/app/app-route.js +0 -30
- package/tests/tests/app/options.js +0 -16
- package/tests/tests/app/setting-inheritance.js +0 -16
- package/tests/tests/engines/art-template.js +0 -33
- package/tests/tests/engines/dot.js +0 -28
- package/tests/tests/engines/ejs.js +0 -25
- package/tests/tests/engines/handlebars.js +0 -28
- package/tests/tests/engines/mustache.js +0 -28
- package/tests/tests/engines/pug.js +0 -25
- package/tests/tests/engines/swig.js +0 -28
- package/tests/tests/errors/error-handling-middleware.js +0 -22
- package/tests/tests/errors/next-error-optimized.js +0 -26
- package/tests/tests/errors/next-error.js +0 -26
- package/tests/tests/errors/unexpected-error-handling.js +0 -18
- package/tests/tests/listen/listen-random.js +0 -11
- package/tests/tests/listen/listen-specific.js +0 -17
- package/tests/tests/middlewares/body-json.js +0 -31
- package/tests/tests/middlewares/body-raw-deflate.js +0 -43
- package/tests/tests/middlewares/body-raw-gzip.js +0 -43
- package/tests/tests/middlewares/body-raw.js +0 -41
- package/tests/tests/middlewares/body-text.js +0 -27
- package/tests/tests/middlewares/body-urlencoded.js +0 -30
- package/tests/tests/middlewares/cookie-parser-signed.js +0 -31
- package/tests/tests/middlewares/cookie-parser.js +0 -28
- package/tests/tests/middlewares/cookie-session.js +0 -40
- package/tests/tests/middlewares/cors.js +0 -29
- package/tests/tests/middlewares/errorhandler.js +0 -26
- package/tests/tests/middlewares/express-fileupload-temp.js +0 -46
- package/tests/tests/middlewares/express-fileupload.js +0 -28
- package/tests/tests/middlewares/express-rate-limit.js +0 -33
- package/tests/tests/middlewares/express-session.js +0 -37
- package/tests/tests/middlewares/express-static-options.js +0 -72
- package/tests/tests/middlewares/express-static.js +0 -40
- package/tests/tests/middlewares/method-override.js +0 -33
- package/tests/tests/middlewares/multer.js +0 -43
- package/tests/tests/middlewares/multiple-middlewares.js +0 -37
- package/tests/tests/middlewares/response-time.js +0 -29
- package/tests/tests/middlewares/serve-index.js +0 -38
- package/tests/tests/middlewares/serve-static.js +0 -38
- package/tests/tests/middlewares/vhost.js +0 -50
- package/tests/tests/params/array-param.js +0 -30
- package/tests/tests/params/nested-params.js +0 -24
- package/tests/tests/params/param-errors.js +0 -56
- package/tests/tests/params/param-function.js +0 -49
- package/tests/tests/params/param-next-route.js +0 -48
- package/tests/tests/params/param-optimized.js +0 -38
- package/tests/tests/params/param-use.js +0 -39
- package/tests/tests/params/param.js +0 -68
- package/tests/tests/params/params-regex.js +0 -26
- package/tests/tests/params/params-use.js +0 -20
- package/tests/tests/params/params.js +0 -35
- package/tests/tests/req/req-accepts-charsets.js +0 -40
- package/tests/tests/req/req-accepts-encodings.js +0 -36
- package/tests/tests/req/req-accepts-languages.js +0 -41
- package/tests/tests/req/req-accepts.js +0 -41
- package/tests/tests/req/req-app.js +0 -17
- package/tests/tests/req/req-baseurl.js +0 -38
- package/tests/tests/req/req-connection.js +0 -19
- package/tests/tests/req/req-fresh.js +0 -59
- package/tests/tests/req/req-get.js +0 -78
- package/tests/tests/req/req-headers-distinct.js +0 -72
- package/tests/tests/req/req-headers.js +0 -72
- package/tests/tests/req/req-host.js +0 -45
- package/tests/tests/req/req-hostname.js +0 -45
- package/tests/tests/req/req-ip.js +0 -19
- package/tests/tests/req/req-is.js +0 -44
- package/tests/tests/req/req-original-url.js +0 -29
- package/tests/tests/req/req-param.js +0 -29
- package/tests/tests/req/req-protocol.js +0 -20
- package/tests/tests/req/req-query.js +0 -23
- package/tests/tests/req/req-range.js +0 -48
- package/tests/tests/req/req-raw-headers.js +0 -72
- package/tests/tests/req/req-subdomains.js +0 -48
- package/tests/tests/req/req-url-nested.js +0 -27
- package/tests/tests/req/req-url-optimized-router.js +0 -26
- package/tests/tests/req/req-url-optimized.js +0 -23
- package/tests/tests/req/req-url.js +0 -36
- package/tests/tests/req/req-xhr.js +0 -23
- package/tests/tests/res/head-content-length.js +0 -18
- package/tests/tests/res/head.js +0 -47
- package/tests/tests/res/injecting.js +0 -25
- package/tests/tests/res/piping.js +0 -23
- package/tests/tests/res/res-app.js +0 -17
- package/tests/tests/res/res-append.js +0 -24
- package/tests/tests/res/res-attachment.js +0 -19
- package/tests/tests/res/res-clear-cookie.js +0 -18
- package/tests/tests/res/res-cookie.js +0 -22
- package/tests/tests/res/res-download.js +0 -36
- package/tests/tests/res/res-format.js +0 -57
- package/tests/tests/res/res-get.js +0 -18
- package/tests/tests/res/res-headers-sent.js +0 -18
- package/tests/tests/res/res-json.js +0 -17
- package/tests/tests/res/res-jsonp.js +0 -25
- package/tests/tests/res/res-links.js +0 -21
- package/tests/tests/res/res-location.js +0 -34
- package/tests/tests/res/res-redirect.js +0 -46
- package/tests/tests/res/res-remove-header.js +0 -19
- package/tests/tests/res/res-send-file.js +0 -17
- package/tests/tests/res/res-send-status.js +0 -17
- package/tests/tests/res/res-send.js +0 -69
- package/tests/tests/res/res-set.js +0 -28
- package/tests/tests/res/res-status.js +0 -18
- package/tests/tests/res/res-type.js +0 -19
- package/tests/tests/res/res-vary.js +0 -19
- package/tests/tests/res/res-write.js +0 -29
- package/tests/tests/routers/complex-routers.js +0 -34
- package/tests/tests/routers/empty-router.js +0 -25
- package/tests/tests/routers/lot-of-routes.js +0 -38
- package/tests/tests/routers/mergeparams.js +0 -42
- package/tests/tests/routers/nested-routers.js +0 -52
- package/tests/tests/routers/router-options.js +0 -68
- package/tests/tests/routers/routers.js +0 -45
- package/tests/tests/routers/simple-routers.js +0 -35
- package/tests/tests/routing/all.js +0 -47
- package/tests/tests/routing/array-arguments.js +0 -35
- package/tests/tests/routing/array-use.js +0 -33
- package/tests/tests/routing/async-use.js +0 -25
- package/tests/tests/routing/complex-routes.js +0 -50
- package/tests/tests/routing/lot-of-param-routes.js +0 -26
- package/tests/tests/routing/lot-of-routes.js +0 -59
- package/tests/tests/routing/next-existent-optimized-route.js +0 -29
- package/tests/tests/routing/next-existent-route.js +0 -29
- package/tests/tests/routing/next-nonexistent-optimized-route.js +0 -19
- package/tests/tests/routing/next-nonexistent-route.js +0 -19
- package/tests/tests/routing/next-special-cases.js +0 -54
- package/tests/tests/routing/next-unoptimized.js +0 -39
- package/tests/tests/routing/no-path-use.js +0 -29
- package/tests/tests/routing/non-string-routes.js +0 -27
- package/tests/tests/routing/req-multiple-mountpaths.js +0 -34
- package/tests/tests/routing/simple-routes.js +0 -29
- package/tests/tests/routing/simple-use.js +0 -52
- package/tests/tests/routing/some-middlewares.js +0 -27
- package/tests/tests/routing/special-characters.js +0 -28
- package/tests/tests/routing/star.js +0 -31
- package/tests/tests/routing/sub-apps.js +0 -32
- package/tests/tests/routing/trailing-slash.js +0 -37
- package/tests/tests/routing/weird-route-start.js +0 -18
- package/tests/tests/send-file/accept-ranges.js +0 -26
- package/tests/tests/send-file/callback.js +0 -23
- package/tests/tests/send-file/default-error-routing.js +0 -21
- package/tests/tests/send-file/dotfiles.js +0 -24
- package/tests/tests/send-file/etag.js +0 -19
- package/tests/tests/send-file/fs-threads.js +0 -39
- package/tests/tests/send-file/head.js +0 -49
- package/tests/tests/send-file/headers.js +0 -23
- package/tests/tests/send-file/if-match.js +0 -31
- package/tests/tests/send-file/if-range.js +0 -37
- package/tests/tests/send-file/if-unmodified-since.js +0 -32
- package/tests/tests/send-file/immutable.js +0 -22
- package/tests/tests/send-file/large-file.js +0 -19
- package/tests/tests/send-file/last-modified.js +0 -21
- package/tests/tests/send-file/max-age.js +0 -21
- package/tests/tests/send-file/path-traversal.js +0 -35
- package/tests/tests/send-file/range.js +0 -57
- package/tests/tests/send-file/simple.js +0 -18
- package/tests/tests/settings/case-sensitive-routing.js +0 -48
- package/tests/tests/settings/env-errors.js +0 -38
- package/tests/tests/settings/etag.js +0 -36
- package/tests/tests/settings/json-escape.js +0 -45
- package/tests/tests/settings/json-replacer.js +0 -50
- package/tests/tests/settings/json-spaces.js +0 -44
- package/tests/tests/settings/query-parser.js +0 -45
- package/tests/tests/settings/strict-routing.js +0 -64
- package/tests/tests/settings/subdomain-offset.js +0 -38
- package/tests/tests/settings/trust-proxy-host.js +0 -58
- package/tests/tests/settings/trust-proxy-ip.js +0 -58
- package/tests/tests/settings/trust-proxy-ips.js +0 -58
- package/tests/tests/settings/trust-proxy-protocol.js +0 -46
- package/tests/tests/settings/x-powered-by.js +0 -32
- package/tests/uws.js +0 -14
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultimate-express",
|
|
3
|
-
"version": "1.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"
|
|
@@ -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
|
-
}
|
package/tests/parts/big.jpg
DELETED
|
Binary file
|
package/tests/parts/index.art
DELETED
|
@@ -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>
|
package/tests/parts/index.dot
DELETED
|
@@ -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>
|
package/tests/parts/index.ejs
DELETED
|
@@ -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>
|
package/tests/parts/index.html
DELETED
|
@@ -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>
|
package/tests/parts/index.pug
DELETED
package/tests/parts/index.swig
DELETED
|
@@ -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>
|
package/tests/preload.cjs
DELETED
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,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
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// error handling middleware
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
app.set('env', 'production');
|
|
7
|
-
|
|
8
|
-
app.get('/test', (req, res) => {
|
|
9
|
-
throw new Error('test');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.use((err, req, res, next) => {
|
|
13
|
-
res.status(500).send(`whoops!`);
|
|
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').then(res => res.text());
|
|
20
|
-
console.log(response);
|
|
21
|
-
process.exit(0);
|
|
22
|
-
});
|