forked from Scribouilli/toctoctoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.js
33 lines (28 loc) · 842 Bytes
/
tools.js
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
import { readFileSync } from 'node:fs'
/**
*
* @param {TemplateStringsArray | string} content
* @returns {string}
*/
export const htmlTemplate = (content) => {
if(typeof content !== 'string'){
content = content[0]
}
return `<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<link rel="icon" href="data:,">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Serveur toctoctoc</title>
<meta name="referrer" content="no-referrer">
<style>body{width: 60%; margin: 1rem auto;}</style>
</head>
<body>
${content}
</body>
</html>`
}
export const allowlist = new Set(
readFileSync('./allowlist.csv', {encoding: 'utf8'}).split('\n').map(s => s.trim()).filter(x => !!x)
)