refacto: Remake the interface so it is more 'vintage' looking + Adding a full calendar page
This commit is contained in:
@@ -17,9 +17,15 @@ const MIME_TYPES = {
|
||||
'.json': 'application/json; charset=utf-8',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpeg',
|
||||
'.woff2': 'font/woff2',
|
||||
'.txt': 'text/plain; charset=utf-8',
|
||||
'.ico': 'image/x-icon',
|
||||
};
|
||||
|
||||
// Binary assets never change without a rename, so they can be cached for a day.
|
||||
const CACHEABLE_EXTENSIONS = new Set(['.jpg', '.woff2', '.svg']);
|
||||
|
||||
function sendJson(res, statusCode, payload) {
|
||||
const body = JSON.stringify(payload);
|
||||
res.writeHead(statusCode, {
|
||||
@@ -78,7 +84,11 @@ function serveStatic(res, rootDir, requestPath) {
|
||||
return;
|
||||
}
|
||||
const ext = path.extname(filePath).toLowerCase();
|
||||
res.writeHead(200, { 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' });
|
||||
const headers = { 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' };
|
||||
if (CACHEABLE_EXTENSIONS.has(ext)) {
|
||||
headers['Cache-Control'] = 'public, max-age=86400';
|
||||
}
|
||||
res.writeHead(200, headers);
|
||||
res.end(content);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user