add mpd config
This commit is contained in:
parent
93d7af271d
commit
c746d81063
|
@ -11,6 +11,8 @@
|
|||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
bun
|
||||
mpd
|
||||
mpc-cli
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
13
mpd.conf
Normal file
13
mpd.conf
Normal file
|
@ -0,0 +1,13 @@
|
|||
audio_output {
|
||||
type "pipewire"
|
||||
name "PipeWire Sound Server"
|
||||
}
|
||||
|
||||
db_file "/tmp/sanic/mpd_db"
|
||||
auto_update "yes"
|
||||
music_directory "/tmp/sanic/music"
|
||||
playlist_directory "/tmp/sanic/playlists"
|
||||
zeroconf_enabled "yes"
|
||||
zeroconf_name "sanic dev server"
|
||||
log_level "info"
|
||||
|
|
@ -3,7 +3,9 @@
|
|||
"module": "server.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "bun run server.ts"
|
||||
"start": "bun run server.ts",
|
||||
"init": "mkdir -p /tmp/sanic/{music,playlists}; touch /tmp/sanic/mpd_db",
|
||||
"mpd": "mpd --no-daemon ./mpd.conf"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bun-types": "latest"
|
||||
|
|
33
server.ts
33
server.ts
|
@ -1 +1,32 @@
|
|||
console.log("Hello via Bun!");
|
||||
// Run websocket server
|
||||
const wsServer = Bun.serve({
|
||||
port: 8080,
|
||||
fetch(req, server) {
|
||||
// upgrade the request to a WebSocket
|
||||
if (server.upgrade(req)) {
|
||||
return; // do not return a Response
|
||||
}
|
||||
return new Response("Upgrade failed :(", { status: 500 });
|
||||
},
|
||||
websocket: {
|
||||
message(ws, message) { // a message is received
|
||||
ws.send(message); // echo back the message
|
||||
},
|
||||
open(ws) {}, // a socket is opened
|
||||
close(ws, code, message) {}, // a socket is closed
|
||||
drain(ws) {}, // the socket is ready to receive more data
|
||||
},
|
||||
});
|
||||
|
||||
// Run web server
|
||||
const webServer = Bun.serve({
|
||||
port: 8000,
|
||||
//unix: "/run/sanic.sock",
|
||||
fetch(req) {
|
||||
return new Response("Put frontend here!");
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Listening on http://localhost:${webServer.port} ...`);
|
||||
console.log(`Listening on ws://localhost:${wsServer.port} ...`);
|
||||
|
||||
|
|
Loading…
Reference in a new issue