more server headers and MOTDs

This commit is contained in:
mellodoot 2023-10-02 14:06:50 +01:00
parent 221e5b9147
commit f3dfda066e

View file

@ -43,9 +43,12 @@ const MOTDS = [
"now fully open-source!", "now fully open-source!",
"somehow not the worst communication app!", "somehow not the worst communication app!",
"\"oh this is like nano but multiplayer\"", "\"oh this is like nano but multiplayer\"",
"there's no place like 127.0.0.1",
"it's no emacs, but it'll do",
]; ];
const STATIC_PATH = path.join(process.cwd(), "public"); const STATIC_PATH = path.join(process.cwd(), "public");
const CACHE_MAX_AGE = 86400 // 1 day
const BANNER = const BANNER =
`Welcome to OpenTerminal! `Welcome to OpenTerminal!
@ -99,7 +102,11 @@ const server = https.createServer(config, async (req, res) => {
return; return;
} }
const mime_type = MIME_TYPES[file.ext] || MIME_TYPES.default; const mime_type = MIME_TYPES[file.ext] || MIME_TYPES.default;
res.writeHead(200, { "Content-Type": mime_type }); res.writeHead(200, {
"Content-Type": mime_type,
"Cache-Control": `max-age=${CACHE_MAX_AGE}`,
"Server": "OpenTerminal",
});
file.stream.pipe(res); file.stream.pipe(res);
// console.log(`${req.method} - ${req.url}`); // console.log(`${req.method} - ${req.url}`);
}); });