added index

This commit is contained in:
uh wot 2021-08-16 19:52:51 +02:00
parent 756221a4b1
commit a735d06185
Signed by: uhwot
GPG Key ID: CB2454984587B781
6 changed files with 2365 additions and 616 deletions

6
dist/worker.js vendored

File diff suppressed because one or more lines are too long

37
index.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dzserver</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap');
body {
background-color: #474747;
}
p, h1, h2, a {
color: #ffffff;
font-family: 'Roboto', sans-serif;
text-align: center;
}
</style>
</head>
<body>
<h1>dzserver</h1>
<h2><a href="https://git.freezer.life/uhwot/dzserver">source code</a></h2>
<br>
<p>how 2 use:</p>
<p><b>/track/&lt;id&gt;</b></p>
<p><b>/album/&lt;id&gt;</b></p>
<p><b>/playlist/&lt;id&gt;</b></p>
<br>
<p>params are:</p>
<p><b>t: tagging</b>, boolean</p>
<p><b>f: format</b>, can be one of these:</p>
<p>aac_96, 64, 128, 320, ra1, ra2, ra3, sbc_256, misc</p>
<p>available formats depend on the track</p>
</body>
</html>

View File

@ -39,11 +39,11 @@ async function handler(type, request) {
} else { } else {
format = format.toLowerCase() format = format.toLowerCase()
if (format_string_to_num[format] === undefined) { if (format_string_to_num[format] === undefined) {
index = Object.values(format_string_to_num).indexOf(format) html = Object.values(format_string_to_num).indexOf(format)
if (index === -1) { if (html === -1) {
return new Response('Invalid format', { status: 400, headers: { 'content-type': 'text/plain' } }) return new Response('Invalid format', { status: 400, headers: { 'content-type': 'text/plain' } })
} }
format = Object.keys(format_string_to_num)[index] format = Object.keys(format_string_to_num)[html]
} }
} }
@ -231,8 +231,13 @@ async function m3u8(type, id, format, access_token, tagging, host) {
return new Response(list, { status: 200, headers: { 'content-type': 'audio/mpegurl' } }) return new Response(list, { status: 200, headers: { 'content-type': 'audio/mpegurl' } })
} }
async function indexHandler() {
return new Response(require('./index.html'), { status: 200, headers: { 'content-type': 'text/html' } })
}
async function handleRequest(request) { async function handleRequest(request) {
const r = new Router() const r = new Router()
r.get('/', () => indexHandler())
r.get('/track/-?\\d+', () => handler('track', request)) r.get('/track/-?\\d+', () => handler('track', request))
r.get('/album/\\d+', () => handler('album', request)) r.get('/album/\\d+', () => handler('album', request))
r.get('/playlist/\\d+', () => handler('playlist', request)) r.get('/playlist/\\d+', () => handler('playlist', request))

3006
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^1.5.0", "@wasm-tool/wasm-pack-plugin": "^1.5.0",
"html-loader": "^1.3.2",
"prettier": "^1.17.0" "prettier": "^1.17.0"
}, },
"dependencies": { "dependencies": {

View File

@ -9,5 +9,13 @@ module.exports = {
new WasmPackPlugin({ new WasmPackPlugin({
crateDirectory: __dirname, crateDirectory: __dirname,
}), }),
],
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader'
}
] ]
}
}; };