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,23 +0,0 @@
|
|
|
1
|
-
// must support piping into res
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
|
|
6
|
-
const app = express();
|
|
7
|
-
|
|
8
|
-
app.get('/test', (req, res) => {
|
|
9
|
-
if(!fs.existsSync('./src/router.js')) {
|
|
10
|
-
throw new Error('File not found');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const file = fs.createReadStream('./src/router.js');
|
|
14
|
-
file.pipe(res);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app.listen(13333, async () => {
|
|
18
|
-
console.log('Server is running on port 13333');
|
|
19
|
-
|
|
20
|
-
const response = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
21
|
-
console.log(response.slice(0, 100), response.length);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// must support res.app
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
console.log(!!res.app);
|
|
9
|
-
res.send('test');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// must support res.append()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.append('X-Test', '1');
|
|
9
|
-
res.append('X-Test', '2');
|
|
10
|
-
res.append('Set-Cookie', 'test=1');
|
|
11
|
-
res.append('Set-Cookie', 'test2=2');
|
|
12
|
-
res.append('Link', ['<http://example.com>', '<http://example.com/other>']);
|
|
13
|
-
res.send('test');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
app.listen(13333, async () => {
|
|
17
|
-
console.log('Server is running on port 13333');
|
|
18
|
-
|
|
19
|
-
const response = await fetch('http://localhost:13333/test');
|
|
20
|
-
console.log(response.headers.get('X-Test'));
|
|
21
|
-
console.log(response.headers.get('Set-Cookie'));
|
|
22
|
-
console.log(response.headers.get('Link'));
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// must support res.attachment()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.attachment('test.png');
|
|
9
|
-
res.send('test');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test');
|
|
16
|
-
console.log(response.headers.get('Content-Disposition'));
|
|
17
|
-
console.log(response.headers.get('Content-Type').split(';')[0]);
|
|
18
|
-
process.exit(0);
|
|
19
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// must support res.clearCookie()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.clearCookie('test');
|
|
9
|
-
res.send('test');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test');
|
|
16
|
-
console.log(response.headers.get('Set-Cookie'));
|
|
17
|
-
process.exit(0);
|
|
18
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// must support res.cookie()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.cookie('test', '1');
|
|
9
|
-
res.cookie('test2', '2', { maxAge: 1000 });
|
|
10
|
-
res.cookie('test3', '3', { maxAge: 1000, path: '/test' });
|
|
11
|
-
res.cookie('test4', '4', { maxAge: 1000, path: '/test', httpOnly: true });
|
|
12
|
-
res.cookie('test5', '5', { maxAge: 1000, path: '/test', secure: true });
|
|
13
|
-
res.send('test');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
app.listen(13333, async () => {
|
|
17
|
-
console.log('Server is running on port 13333');
|
|
18
|
-
|
|
19
|
-
const response = await fetch('http://localhost:13333/test');
|
|
20
|
-
console.log(response.headers.get('Set-Cookie').replace(/\d\d\:\d\d\:\d\d/g, 'xx:xx:xx'));
|
|
21
|
-
process.exit(0);
|
|
22
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// must support res.download()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.download('src/index.js', { root: "." });
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.get('/test2', (req, res) => {
|
|
12
|
-
res.download('src/index.js', "hi.js", (err) => {
|
|
13
|
-
console.log(err);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app.get('/test3', (req, res) => {
|
|
18
|
-
res.download('src/index.js', { root: "." }, (err) => {
|
|
19
|
-
console.log(err);
|
|
20
|
-
});
|
|
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');
|
|
27
|
-
console.log([await response.text(), response.headers.get('content-disposition')]);
|
|
28
|
-
|
|
29
|
-
const response2 = await fetch('http://localhost:13333/test2');
|
|
30
|
-
console.log([await response2.text(), response2.headers.get('content-disposition')]);
|
|
31
|
-
|
|
32
|
-
const response3 = await fetch('http://localhost:13333/test3');
|
|
33
|
-
console.log([await response3.text(), response3.headers.get('content-disposition')]);
|
|
34
|
-
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// must support res.format()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.format({
|
|
9
|
-
'text/plain': function () {
|
|
10
|
-
res.send('hey')
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
'text/html': function () {
|
|
14
|
-
res.send('<p>hey</p>')
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
'application/json': function () {
|
|
18
|
-
res.send(JSON.stringify({ message: 'hey' }))
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
default: function () {
|
|
22
|
-
res.status(406).send('Not Acceptable')
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
app.listen(13333, async () => {
|
|
28
|
-
console.log('Server is running on port 13333');
|
|
29
|
-
|
|
30
|
-
let response = await fetch('http://localhost:13333/test');
|
|
31
|
-
console.log(await response.text());
|
|
32
|
-
response = await fetch('http://localhost:13333/test', {
|
|
33
|
-
headers: {
|
|
34
|
-
'Accept': 'text/html'
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
console.log(await response.text());
|
|
38
|
-
response = await fetch('http://localhost:13333/test', {
|
|
39
|
-
headers: {
|
|
40
|
-
'Accept': 'application/json'
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
console.log(await response.text());
|
|
44
|
-
response = await fetch('http://localhost:13333/test', {
|
|
45
|
-
headers: {
|
|
46
|
-
'Accept': 'text/plain'
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
console.log(await response.text());
|
|
50
|
-
response = await fetch('http://localhost:13333/test', {
|
|
51
|
-
headers: {
|
|
52
|
-
'Accept': 'text/html, application/json, text/plain, */*'
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
console.log(await response.text());
|
|
56
|
-
process.exit(0);
|
|
57
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// must support res.get()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.set('Content-Type', 'text/plain');
|
|
9
|
-
res.send(res.get('Content-Type').split(';')[0]);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test');
|
|
16
|
-
console.log(await response.text());
|
|
17
|
-
process.exit(0);
|
|
18
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// must support res.headersSent
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
console.log(res.headersSent);
|
|
9
|
-
res.send('test');
|
|
10
|
-
console.log(res.headersSent);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
app.listen(13333, async () => {
|
|
14
|
-
console.log('Server is running on port 13333');
|
|
15
|
-
|
|
16
|
-
const response = await fetch('http://localhost:13333/test').then(res => res.text());
|
|
17
|
-
process.exit(0);
|
|
18
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// must support res.json()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.json({ test: 'test' });
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.listen(13333, async () => {
|
|
12
|
-
console.log('Server is running on port 13333');
|
|
13
|
-
|
|
14
|
-
const response = await fetch('http://localhost:13333/test');
|
|
15
|
-
console.log(await response.json());
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// must support res.jsonp()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
app.set('jsonp callback name', 'callback2');
|
|
7
|
-
|
|
8
|
-
app.get('/test', (req, res) => {
|
|
9
|
-
res.jsonp({ test: 'test' });
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test?callback2=test');
|
|
16
|
-
console.log(await response.text());
|
|
17
|
-
|
|
18
|
-
const response2 = await fetch('http://localhost:13333/test');
|
|
19
|
-
console.log(await response2.text());
|
|
20
|
-
|
|
21
|
-
const response3 = await fetch('http://localhost:13333/test?asdf=test');
|
|
22
|
-
console.log(await response3.text());
|
|
23
|
-
|
|
24
|
-
process.exit(0);
|
|
25
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// must support res.links()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.links({
|
|
9
|
-
'next': 'http://api.example.com/users?page=2',
|
|
10
|
-
'last': 'http://api.example.com/users?page=5',
|
|
11
|
-
});
|
|
12
|
-
res.send('ok');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
app.listen(13333, async () => {
|
|
16
|
-
console.log('Server is running on port 13333');
|
|
17
|
-
|
|
18
|
-
const response = await fetch('http://localhost:13333/test');
|
|
19
|
-
console.log(response.headers.get('Link'));
|
|
20
|
-
process.exit(0);
|
|
21
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// must support res.location()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.location('http://example.com');
|
|
9
|
-
res.send('ok');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.get('/test2', (req, res) => {
|
|
13
|
-
res.location('back');
|
|
14
|
-
res.send('ok');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app.listen(13333, async () => {
|
|
18
|
-
console.log('Server is running on port 13333');
|
|
19
|
-
|
|
20
|
-
const response = await fetch('http://localhost:13333/test');
|
|
21
|
-
console.log(response.headers.get('Location'));
|
|
22
|
-
|
|
23
|
-
const response2 = await fetch('http://localhost:13333/test2');
|
|
24
|
-
console.log(response2.headers.get('Location'));
|
|
25
|
-
|
|
26
|
-
const response3 = await fetch('http://localhost:13333/test2', {
|
|
27
|
-
headers: {
|
|
28
|
-
'Referrer': 'http://example.com',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
console.log(response3.headers.get('Location'));
|
|
32
|
-
|
|
33
|
-
process.exit(0);
|
|
34
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// must support res.redirect()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.redirect(301, 'http://example.com');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.get('/test2', (req, res) => {
|
|
12
|
-
res.redirect('http://example.com');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
app.get('/test3', (req, res) => {
|
|
16
|
-
res.redirect('/test');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
app.get('/test4', (req, res) => {
|
|
20
|
-
res.redirect('..');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
app.get('/test5', (req, res) => {
|
|
24
|
-
res.redirect(304, 'back');
|
|
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', { redirect: 'manual' });
|
|
31
|
-
console.log(response.status, response.headers.get('Location'), await response.text());
|
|
32
|
-
|
|
33
|
-
const response2 = await fetch('http://localhost:13333/test2', { redirect: 'manual' });
|
|
34
|
-
console.log(response2.status, response2.headers.get('Location'));
|
|
35
|
-
|
|
36
|
-
const response3 = await fetch('http://localhost:13333/test3', { redirect: 'manual' });
|
|
37
|
-
console.log(response3.status, response3.headers.get('Location'));
|
|
38
|
-
|
|
39
|
-
const response4 = await fetch('http://localhost:13333/test4', { redirect: 'manual' });
|
|
40
|
-
console.log(response4.status, response4.headers.get('Location'));
|
|
41
|
-
|
|
42
|
-
const response5 = await fetch('http://localhost:13333/test5', { redirect: 'manual' });
|
|
43
|
-
console.log(response5.status, response5.headers.get('Location'));
|
|
44
|
-
|
|
45
|
-
process.exit(0);
|
|
46
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// must support res.removeHeader()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.set('X-Test', 'test');
|
|
9
|
-
res.removeHeader('X-Test');
|
|
10
|
-
res.send('ok');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
app.listen(13333, async () => {
|
|
14
|
-
console.log('Server is running on port 13333');
|
|
15
|
-
|
|
16
|
-
const response = await fetch('http://localhost:13333/test');
|
|
17
|
-
console.log(response.headers.get('X-Test'));
|
|
18
|
-
process.exit(0);
|
|
19
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// must support res.sendFile()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.sendFile('src/index.js', { root: "." });
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.listen(13333, async () => {
|
|
12
|
-
console.log('Server is running on port 13333');
|
|
13
|
-
|
|
14
|
-
const response = await fetch('http://localhost:13333/test');
|
|
15
|
-
console.log(await response.text(), response.headers.get('Content-Type').split(';')[0]);
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// must support res.sendStatus()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.sendStatus(201);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.listen(13333, async () => {
|
|
12
|
-
console.log('Server is running on port 13333');
|
|
13
|
-
|
|
14
|
-
const response = await fetch('http://localhost:13333/test');
|
|
15
|
-
console.log(response.status, await response.text());
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// must support res.send()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.send('Hello World');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
app.get('/json', (req, res) => {
|
|
12
|
-
res.send({
|
|
13
|
-
message: 'Hello World'
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
app.get('/buffer', (req, res) => {
|
|
18
|
-
res.send(Buffer.from("asf"));
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
app.get('/null', (req, res) => {
|
|
22
|
-
res.send(null);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
app.get('/undefined', (req, res) => {
|
|
26
|
-
res.send(undefined);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
app.get('/number', (req, res) => {
|
|
30
|
-
res.send(202);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
app.get('/number2', (req, res) => {
|
|
34
|
-
res.send(203, "test");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
app.get('/boolean', (req, res) => {
|
|
38
|
-
res.send(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
app.listen(13333, async () => {
|
|
42
|
-
console.log('Server is running on port 13333');
|
|
43
|
-
|
|
44
|
-
const responses = await Promise.all([
|
|
45
|
-
fetch('http://localhost:13333/test').then(res => res.text()),
|
|
46
|
-
fetch('http://localhost:13333/json').then(res => res.text()),
|
|
47
|
-
fetch('http://localhost:13333/buffer').then(res => res.text()),
|
|
48
|
-
fetch('http://localhost:13333/null').then(res => res.text()),
|
|
49
|
-
fetch('http://localhost:13333/undefined').then(res => res.text()),
|
|
50
|
-
fetch('http://localhost:13333/number').then(res => res.text()),
|
|
51
|
-
fetch('http://localhost:13333/number2').then(res => res.text()),
|
|
52
|
-
fetch('http://localhost:13333/boolean').then(res => res.text()),
|
|
53
|
-
]);
|
|
54
|
-
|
|
55
|
-
const codes = await Promise.all([
|
|
56
|
-
fetch('http://localhost:13333/test').then(res => res.status),
|
|
57
|
-
fetch('http://localhost:13333/json').then(res => res.status),
|
|
58
|
-
fetch('http://localhost:13333/buffer').then(res => res.status),
|
|
59
|
-
fetch('http://localhost:13333/null').then(res => res.status),
|
|
60
|
-
fetch('http://localhost:13333/undefined').then(res => res.status),
|
|
61
|
-
fetch('http://localhost:13333/number').then(res => res.status),
|
|
62
|
-
fetch('http://localhost:13333/number2').then(res => res.status),
|
|
63
|
-
fetch('http://localhost:13333/boolean').then(res => res.status),
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
console.log(responses);
|
|
67
|
-
console.log(codes);
|
|
68
|
-
process.exit(0);
|
|
69
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// must support res.set(), res.header()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.set('X-Test', 'test');
|
|
9
|
-
res.set({
|
|
10
|
-
'X-Test2': 'test2',
|
|
11
|
-
'X-Test3': 'test3'
|
|
12
|
-
});
|
|
13
|
-
res.header('X-Test4', 'test4');
|
|
14
|
-
res.setHeader('X-Test5', 'test5');
|
|
15
|
-
res.send('ok');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.listen(13333, async () => {
|
|
19
|
-
console.log('Server is running on port 13333');
|
|
20
|
-
|
|
21
|
-
const response = await fetch('http://localhost:13333/test');
|
|
22
|
-
console.log(response.headers.get('X-Test'));
|
|
23
|
-
console.log(response.headers.get('X-Test2'));
|
|
24
|
-
console.log(response.headers.get('X-Test3'));
|
|
25
|
-
console.log(response.headers.get('X-Test4'));
|
|
26
|
-
console.log(response.headers.get('X-Test5'));
|
|
27
|
-
process.exit(0);
|
|
28
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// must support res.status()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.status(201);
|
|
9
|
-
res.send('ok');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.listen(13333, async () => {
|
|
13
|
-
console.log('Server is running on port 13333');
|
|
14
|
-
|
|
15
|
-
const response = await fetch('http://localhost:13333/test');
|
|
16
|
-
console.log(response.status);
|
|
17
|
-
process.exit(0);
|
|
18
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// must support res.type()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.type('text/plain');
|
|
9
|
-
res.contentType('application/json');
|
|
10
|
-
res.send('test');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
app.listen(13333, async () => {
|
|
14
|
-
console.log('Server is running on port 13333');
|
|
15
|
-
|
|
16
|
-
const response = await fetch('http://localhost:13333/test');
|
|
17
|
-
console.log(response.headers.get('Content-Type').split(';')[0]);
|
|
18
|
-
process.exit(0);
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// must support res.vary()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.vary('X-Test');
|
|
9
|
-
res.vary('Set-Cookie');
|
|
10
|
-
res.send('test');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
app.listen(13333, async () => {
|
|
14
|
-
console.log('Server is running on port 13333');
|
|
15
|
-
|
|
16
|
-
const response = await fetch('http://localhost:13333/test');
|
|
17
|
-
console.log(response.headers.get('Vary'));
|
|
18
|
-
process.exit(0);
|
|
19
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// must support res.sendFile()
|
|
2
|
-
|
|
3
|
-
const express = require("express");
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
app.get('/test', (req, res) => {
|
|
8
|
-
res.write('test');
|
|
9
|
-
res.end();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
app.get('/test2', (req, res) => {
|
|
13
|
-
for(let i = 0; i < 10; i++) {
|
|
14
|
-
const ab = new Uint8Array([i]);
|
|
15
|
-
res.write(ab);
|
|
16
|
-
}
|
|
17
|
-
res.end();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
app.listen(13333, async () => {
|
|
21
|
-
console.log('Server is running on port 13333');
|
|
22
|
-
|
|
23
|
-
const response = await fetch('http://localhost:13333/test');
|
|
24
|
-
console.log(await response.text());
|
|
25
|
-
|
|
26
|
-
const response2 = await fetch('http://localhost:13333/test2');
|
|
27
|
-
console.log(await response2.arrayBuffer());
|
|
28
|
-
process.exit(0);
|
|
29
|
-
});
|