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.
- package/LICENSE +13 -0
- package/README.md +2 -1
- package/package.json +8 -4
- 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
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// must support complex routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router();
|
|
7
|
-
|
|
8
|
-
router.get('/test', (req, res) => {
|
|
9
|
-
console.log('found router', req.params.test);
|
|
10
|
-
res.send('test2');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
router.get('/b/:hi', (req, res) => {
|
|
14
|
-
console.log('found router2', req.params.hi);
|
|
15
|
-
res.send('test2');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.use('/:test', router);
|
|
19
|
-
|
|
20
|
-
app.use((req, res, next) => {
|
|
21
|
-
res.send('404');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
app.listen(13333, async () => {
|
|
25
|
-
console.log('Server is running on port 13333');
|
|
26
|
-
|
|
27
|
-
let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
28
|
-
let output2 = await fetch('http://localhost:13333/asdf/asdf').then(res => res.text());
|
|
29
|
-
let output3 = await fetch('http://localhost:13333/asdf/test').then(res => res.text());
|
|
30
|
-
let output4 = await fetch('http://localhost:13333/test/b/asdf').then(res => res.text());
|
|
31
|
-
|
|
32
|
-
console.log(output1, output2, output3, output4);
|
|
33
|
-
process.exit(0);
|
|
34
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// must support empty routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router();
|
|
7
|
-
|
|
8
|
-
router.get('/', (req, res) => {
|
|
9
|
-
res.send('test2');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.use('/test', router);
|
|
13
|
-
|
|
14
|
-
app.use((req, res, next) => {
|
|
15
|
-
res.send('404');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
console.log('Server is running on port 13333');
|
|
20
|
-
|
|
21
|
-
let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
22
|
-
|
|
23
|
-
console.log(output1);
|
|
24
|
-
process.exit(0);
|
|
25
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// must support a lot of routes inside simple routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = express.Router();
|
|
7
|
-
|
|
8
|
-
for(let i = 0; i < 1000; i++) {
|
|
9
|
-
router.get(`/${i}`, (req, res) => {
|
|
10
|
-
res.send(i.toString());
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
for(let i = 1000; i < 2000; i++) {
|
|
15
|
-
router.use((req, res, next) => {
|
|
16
|
-
next();
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for(let i = 2000; i < 3000; i++) {
|
|
21
|
-
router.get(`/${i}`, (req, res) => {
|
|
22
|
-
res.send(i.toString());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
app.use("/router", router);
|
|
27
|
-
|
|
28
|
-
app.listen(13333, async () => {
|
|
29
|
-
console.log('Server is running on port 13333');
|
|
30
|
-
|
|
31
|
-
let res = await fetch('http://localhost:13333/router/999');
|
|
32
|
-
console.log(await res.text());
|
|
33
|
-
|
|
34
|
-
res = await fetch('http://localhost:13333/router/2999');
|
|
35
|
-
console.log(await res.text());
|
|
36
|
-
|
|
37
|
-
process.exit(0);
|
|
38
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// must support mergeParams
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router({ mergeParams: true });
|
|
7
|
-
const router2 = new express.Router({ mergeParams: true });
|
|
8
|
-
|
|
9
|
-
app.use('/:param1', router);
|
|
10
|
-
router.use('/:param2', router2);
|
|
11
|
-
|
|
12
|
-
router2.get('/:param3', (req, res, next) => {
|
|
13
|
-
if(req.params.param1 === '1') {
|
|
14
|
-
return next();
|
|
15
|
-
}
|
|
16
|
-
res.send([req.params.param1, req.params.param2, req.params.param3]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
app.get('/:param4/:param5/:param6', (req, res) => {
|
|
20
|
-
res.send([req.params.param4, req.params.param5, req.params.param6]);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
app.use((req, res, next) => {
|
|
25
|
-
|
|
26
|
-
res.send('404');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
app.listen(13333, async () => {
|
|
30
|
-
console.log('Server is running on port 13333');
|
|
31
|
-
|
|
32
|
-
let responses = await Promise.all([
|
|
33
|
-
fetch('http://localhost:13333/1/2/3').then(res => res.text()),
|
|
34
|
-
fetch('http://localhost:13333/4/5/6').then(res => res.text()),
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.log(responses);
|
|
39
|
-
|
|
40
|
-
process.exit(0);
|
|
41
|
-
|
|
42
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// must support nested routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router();
|
|
7
|
-
const router2 = new express.Router();
|
|
8
|
-
const router3 = new express.Router();
|
|
9
|
-
|
|
10
|
-
router.get('/test', (req, res) => {
|
|
11
|
-
res.send('test2');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
router2.get('/ccc', (req, res) => {
|
|
15
|
-
res.send('ccc');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
router2.use('/nested', router3);
|
|
19
|
-
|
|
20
|
-
router2.get("/nested", (req, res) => {
|
|
21
|
-
res.send('nested');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
router3.get('/ddd', (req, res) => {
|
|
25
|
-
res.send('ddd');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.use('/:test', router);
|
|
29
|
-
app.use('/abccc', router2);
|
|
30
|
-
|
|
31
|
-
app.use((req, res, next) => {
|
|
32
|
-
res.send('404');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
app.listen(13333, async () => {
|
|
36
|
-
console.log('Server is running on port 13333');
|
|
37
|
-
|
|
38
|
-
const outputs = await Promise.all([
|
|
39
|
-
fetch('http://localhost:13333/test').then(res => res.text()),
|
|
40
|
-
fetch('http://localhost:13333/gdgdf').then(res => res.text()),
|
|
41
|
-
fetch('http://localhost:13333/ccc').then(res => res.text()),
|
|
42
|
-
fetch('http://localhost:13333/abccc').then(res => res.text()),
|
|
43
|
-
fetch('http://localhost:13333/abccc/ddd').then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/abccc/ccc').then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13333/abccc/ddd/ddd').then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13333/abccc/nested/ddd').then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13333/abccc/nested').then(res => res.text()),
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
console.log(outputs.join(' '));
|
|
51
|
-
process.exit(0);
|
|
52
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// must support router options
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
app.set("case sensitive routing", false);
|
|
7
|
-
app.set("strict routing", false);
|
|
8
|
-
const router = express.Router({
|
|
9
|
-
caseSensitive: true,
|
|
10
|
-
strict: true
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
router.get('/TEST', (req, res) => {
|
|
14
|
-
res.send('hi');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.get('/asdf/', (req, res) => {
|
|
18
|
-
res.send('hi');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
app.use('/TEST', router);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
app.get("/ASDF", (req, res) => {
|
|
25
|
-
res.send('asdf');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.get("/def/", (req, res) => {
|
|
29
|
-
res.send('def');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
app.use((req, res, next) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
res.send('404');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
app.listen(13333, async () => {
|
|
39
|
-
|
|
40
|
-
console.log('Server is running on port 13333');
|
|
41
|
-
|
|
42
|
-
let responses = await Promise.all([
|
|
43
|
-
fetch('http://localhost:13333/TEST').then(res => res.text()),
|
|
44
|
-
fetch('http://localhost:13333/TEST/TEST').then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13333/test/test').then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13333/test/TEST/').then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13333/Test/Test').then(res => res.text()),
|
|
48
|
-
fetch('http://localhost:13333/test/TeST').then(res => res.text()),
|
|
49
|
-
fetch('http://localhost:13333/Test/test/').then(res => res.text()),
|
|
50
|
-
|
|
51
|
-
fetch('http://localhost:13333/asdf').then(res => res.text()),
|
|
52
|
-
fetch('http://localhost:13333/asdf/').then(res => res.text()),
|
|
53
|
-
fetch('http://localhost:13333/def').then(res => res.text()),
|
|
54
|
-
fetch('http://localhost:13333/def/').then(res => res.text()),
|
|
55
|
-
|
|
56
|
-
fetch('http://localhost:13333/ASDF').then(res => res.text()),
|
|
57
|
-
fetch('http://localhost:13333/ASDF/').then(res => res.text()),
|
|
58
|
-
fetch('http://localhost:13333/def/').then(res => res.text()),
|
|
59
|
-
|
|
60
|
-
fetch('http://localhost:13333/TEST/asdf').then(res => res.text()),
|
|
61
|
-
fetch('http://localhost:13333/TEST/asdf/').then(res => res.text()),
|
|
62
|
-
fetch('http://localhost:13333/TEST/asdf/asdf').then(res => res.text()),
|
|
63
|
-
fetch('http://localhost:13333/TEST/asdf/asdf/').then(res => res.text()),
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
console.log(responses.join(' '));
|
|
67
|
-
process.exit(0);
|
|
68
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// must support routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router();
|
|
7
|
-
const router2 = new express.Router();
|
|
8
|
-
const router3 = express.Router();
|
|
9
|
-
|
|
10
|
-
router.get('/test', (req, res) => {
|
|
11
|
-
res.send('test');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
router2.get('/test', (req, res) => {
|
|
15
|
-
res.send('test2');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
router3.get('/meow', (req, res) => {
|
|
19
|
-
res.send('meow');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
app.use('/', router);
|
|
23
|
-
app.use('/asdf', router2);
|
|
24
|
-
app.use(router3);
|
|
25
|
-
|
|
26
|
-
app.get('/gaa', (req, res) => {
|
|
27
|
-
res.send('gaa');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
app.use((req, res, next) => {
|
|
31
|
-
res.send('404');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
app.listen(13333, async () => {
|
|
35
|
-
console.log('Server is running on port 13333');
|
|
36
|
-
|
|
37
|
-
let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
38
|
-
let output2 = await fetch('http://localhost:13333/asdf/asdf').then(res => res.text());
|
|
39
|
-
let output3 = await fetch('http://localhost:13333/asdf/test').then(res => res.text());
|
|
40
|
-
let output4 = await fetch('http://localhost:13333/meow').then(res => res.text());
|
|
41
|
-
let output5 = await fetch('http://localhost:13333/gaa').then(res => res.text());
|
|
42
|
-
|
|
43
|
-
console.log(output1, output2, output3, output4, output5);
|
|
44
|
-
process.exit(0);
|
|
45
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// must support simple routers
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
const router = new express.Router();
|
|
7
|
-
|
|
8
|
-
router.get('/:test', (req, res, next) => {
|
|
9
|
-
console.log(req.url, req.params.test);
|
|
10
|
-
next();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
router.get('/test', (req, res) => {
|
|
14
|
-
console.log(req.url);
|
|
15
|
-
res.send('test');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.use('/asdf', router);
|
|
19
|
-
|
|
20
|
-
app.use((req, res, next) => {
|
|
21
|
-
res.send('404');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
app.listen(13333, async () => {
|
|
25
|
-
console.log('Server is running on port 13333');
|
|
26
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
27
|
-
|
|
28
|
-
let outputs = await Promise.all([
|
|
29
|
-
fetch('http://localhost:13333/test').then(res => res.text()),
|
|
30
|
-
fetch('http://localhost:13333/asdf/asdf').then(res => res.text()),
|
|
31
|
-
fetch('http://localhost:13333/asdf/test').then(res => res.text()),
|
|
32
|
-
]);
|
|
33
|
-
console.log(outputs);
|
|
34
|
-
process.exit(0);
|
|
35
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// must support app.all
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.all('/test', (req, res) => {
|
|
8
|
-
res.send('test');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.use((req, res) => {
|
|
12
|
-
res.send('404');
|
|
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
|
-
method: 'POST',
|
|
23
|
-
});
|
|
24
|
-
console.log(await res.text());
|
|
25
|
-
|
|
26
|
-
res = await fetch('http://localhost:13333/test', {
|
|
27
|
-
method: 'PUT',
|
|
28
|
-
});
|
|
29
|
-
console.log(await res.text());
|
|
30
|
-
|
|
31
|
-
res = await fetch('http://localhost:13333/test', {
|
|
32
|
-
method: 'DELETE',
|
|
33
|
-
});
|
|
34
|
-
console.log(await res.text());
|
|
35
|
-
|
|
36
|
-
res = await fetch('http://localhost:13333/test', {
|
|
37
|
-
method: 'PATCH',
|
|
38
|
-
});
|
|
39
|
-
console.log(await res.text());
|
|
40
|
-
|
|
41
|
-
res = await fetch('http://localhost:13333/testas', {
|
|
42
|
-
method: 'OPTIONS',
|
|
43
|
-
});
|
|
44
|
-
console.log(await res.text());
|
|
45
|
-
|
|
46
|
-
process.exit(0);
|
|
47
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// must support array arguments
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.use([(req, res, next) => {
|
|
8
|
-
console.log('first');
|
|
9
|
-
next();
|
|
10
|
-
}, (req, res, next) => {
|
|
11
|
-
console.log('second');
|
|
12
|
-
next();
|
|
13
|
-
}]);
|
|
14
|
-
|
|
15
|
-
app.use('/asdf', (req, res, next) => {
|
|
16
|
-
console.log('third');
|
|
17
|
-
next();
|
|
18
|
-
}, (req, res, next) => {
|
|
19
|
-
console.log('fourth');
|
|
20
|
-
next();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
app.get('/asdf', (req, res) => {
|
|
24
|
-
res.send('asdf');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
app.listen(13333, async () => {
|
|
29
|
-
console.log('Server is running on port 13333');
|
|
30
|
-
|
|
31
|
-
let output = await fetch('http://localhost:13333/asdf').then(res => res.text());
|
|
32
|
-
|
|
33
|
-
console.log(output);
|
|
34
|
-
process.exit(0);
|
|
35
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// must support array use
|
|
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', '/def'], router);
|
|
13
|
-
|
|
14
|
-
app.use((req, res, next) => {
|
|
15
|
-
res.send('404');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
console.log(router.mountpath); // should be last one
|
|
19
|
-
|
|
20
|
-
app.listen(13333, async () => {
|
|
21
|
-
console.log('Server is running on port 13333');
|
|
22
|
-
|
|
23
|
-
let res = await fetch('http://localhost:13333/abc/asdf');
|
|
24
|
-
console.log(await res.text());
|
|
25
|
-
|
|
26
|
-
res = await fetch('http://localhost:13333/def/asdf');
|
|
27
|
-
console.log(await res.text());
|
|
28
|
-
|
|
29
|
-
res = await fetch('http://localhost:13333/ghi/asdf');
|
|
30
|
-
console.log(await res.text());
|
|
31
|
-
|
|
32
|
-
process.exit(0);
|
|
33
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// must support async "use"
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.use(async (req, res, next) => {
|
|
8
|
-
let start = Date.now();
|
|
9
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
10
|
-
res.took = Math.round((Date.now() - start) / 100) * 100;
|
|
11
|
-
next();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app.get('/test', (req, res, next) => {
|
|
15
|
-
res.send(`took ${res.took}ms`);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
console.log('Server is running on port 13333');
|
|
20
|
-
|
|
21
|
-
let output1 = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
22
|
-
|
|
23
|
-
console.log(output1);
|
|
24
|
-
process.exit(0);
|
|
25
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// must support complex routes
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/abc?d', (req, res) => {
|
|
8
|
-
res.send('1');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.get('/za*v', (req, res) => {
|
|
12
|
-
res.send('2');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
app.get('/g+t', (req, res) => {
|
|
16
|
-
res.send('3');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
app.get('/test(abc)?test', (req, res) => {
|
|
20
|
-
res.send('4');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
app.get('/*', (req, res) => {
|
|
24
|
-
res.send('5');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
console.log('Server is running on port 13333');
|
|
29
|
-
|
|
30
|
-
let outputs = await Promise.all([
|
|
31
|
-
fetch('http://localhost:13333/abcd').then(res => res.text()),
|
|
32
|
-
fetch('http://localhost:13333/abd').then(res => res.text()),
|
|
33
|
-
fetch('http://localhost:13333/ad').then(res => res.text()),
|
|
34
|
-
|
|
35
|
-
fetch('http://localhost:13333/zav').then(res => res.text()),
|
|
36
|
-
fetch('http://localhost:13333/zaaaav').then(res => res.text()),
|
|
37
|
-
fetch('http://localhost:13333/zv').then(res => res.text()),
|
|
38
|
-
fetch('http://localhost:13333/zavv').then(res => res.text()),
|
|
39
|
-
|
|
40
|
-
fetch('http://localhost:13333/t').then(res => res.text()),
|
|
41
|
-
fetch('http://localhost:13333/gt').then(res => res.text()),
|
|
42
|
-
fetch('http://localhost:13333/ggggt').then(res => res.text()),
|
|
43
|
-
|
|
44
|
-
fetch('http://localhost:13333/testtest').then(res => res.text()),
|
|
45
|
-
fetch('http://localhost:13333/testabctest').then(res => res.text()),
|
|
46
|
-
]);
|
|
47
|
-
|
|
48
|
-
console.log(outputs.join(' '));
|
|
49
|
-
process.exit(0);
|
|
50
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// must support a lot of param routes
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
for(let i = 0; i < 1000; i++) {
|
|
8
|
-
app.get(`/:test`, (req, res, next) => {
|
|
9
|
-
next();
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
app.get('/:test', (req, res) => {
|
|
14
|
-
res.send(req.params.test);
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
console.log('Server is running on port 13333');
|
|
20
|
-
|
|
21
|
-
let res = await fetch('http://localhost:13333/asdf');
|
|
22
|
-
console.log(await res.text());
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
process.exit(0);
|
|
26
|
-
})
|
|
@@ -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
|
-
});
|