make port changeable through env

This commit is contained in:
Darius
2025-11-18 22:23:20 +01:00
parent c7f0c38cb3
commit 99b9f7d40c
3 changed files with 12 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
API_KEY=apiKey API_KEY=apiKey
PORT=
TIDAL_HOST=http://localhost TIDAL_HOST=http://localhost
TIDAL_PORT=47836 TIDAL_PORT=47836

View File

@@ -4,6 +4,7 @@ dotenv.config();
export const Config = { export const Config = {
api_key: process.env.API_KEY, api_key: process.env.API_KEY,
port: process.env.PORT || "8080",
tidal: { tidal: {
host: process.env.TIDAL_HOST || "", host: process.env.TIDAL_HOST || "",

View File

@@ -141,10 +141,13 @@ server.register(
{ prefix: "/api" }, { prefix: "/api" },
); );
server.listen({ port: 8080, host: "0.0.0.0" }, (err, address) => { server.listen(
{ port: parseInt(Config.port, 10), host: "0.0.0.0" },
(err, address) => {
if (err) { if (err) {
console.error(err); console.error(err);
process.exit(1); process.exit(1);
} }
console.log(`Server listening at ${address}`); console.log(`Server listening at ${address}`);
}); },
);