generated from shgysk8zer0/npm-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.config.js
More file actions
39 lines (35 loc) · 1.22 KB
/
http.config.js
File metadata and controls
39 lines (35 loc) · 1.22 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
import { useRateLimit } from './rate-limit.js';
import { checkCacheItem, setCacheItem } from './cache.js';
import { imports } from '@shgysk8zer0/importmap';
import { addTrustedTypePolicy, addScriptSrc, useDefaultCSP } from './csp.js';
addScriptSrc(imports['@shgysk8zer0/polyfills']);
addTrustedTypePolicy('aegis-sanitizer#html');
const visits = new Map();
export default {
routes: {
'/': '@aegisjsproject/dev-server',
'/favicon.svg': '@aegisjsproject/dev-server/favicon',
},
open: true,
requestPreprocessors: [
(req) => {
visits.set(req.url, (visits.get(req.url) ?? 0) + 1);
console.log(`${req.url} visit count: ${visits.get(req.url)}`);
},
useRateLimit({ timeout: 60_000, maxRequests: 100 }),
'@aegisjsproject/http-utils/geo.js',
'@aegisjsproject/http-utils/request-id.js',
checkCacheItem,
],
responsePostprocessors: [
'@aegisjsproject/http-utils/compression.js',
'@aegisjsproject/http-utils/cors.js',
useDefaultCSP(),
(response, { request }) => {
if (request.destination === 'document') {
response.headers.append('Link', `<${imports['@shgysk8zer0/polyfills']}>; rel="preload"; as="script"; fetchpriority="high"; crossorigin="anonymous"; referrerpolicy="no-referrer"`);
}
},
setCacheItem,
],
};