-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (39 loc) · 1.35 KB
/
Copy pathindex.js
File metadata and controls
47 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Legacy minimal server.
*
* NOTE: The current TaskForge implementation lives under `src/` and the real
* entry point is `src/server.js` (see `package.json`). This file is kept only
* for historical reference.
*/
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.disable('x-powered-by');
app.set('trust proxy', 1);
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('Referrer-Policy', 'no-referrer');
res.setHeader('Cross-Origin-Resource-Policy', 'same-site');
next();
});
const ROOT_BODY = 'Welcome to TaskForge!';
const ROOT_ETAG = 'W/"15-E9IrSfED/8Fp4SZP9LZB6ui+Ndg"';
const ROOT_CONTENT_LENGTH = Buffer.byteLength(ROOT_BODY, 'utf8');
app.get('/', (req, res) => {
if (req.headers['if-none-match'] === ROOT_ETAG) {
res.status(304);
res.setHeader('ETag', ROOT_ETAG);
return res.end();
}
res.status(200);
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.setHeader('Content-Length', ROOT_CONTENT_LENGTH);
res.setHeader('ETag', ROOT_ETAG);
return res.end(ROOT_BODY);
});
const server = app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
server.keepAliveTimeout = 65_000;
server.headersTimeout = 66_000;