Add configurable library path with settings API and UI
This commit is contained in:
@@ -7,13 +7,18 @@ import playlistsRouter from './routes/playlists.js';
|
||||
import albumsRouter from './routes/albums.js';
|
||||
import uploadRouter from './routes/upload.js';
|
||||
import subsonicRouter from './routes/subsonic.js';
|
||||
import settingsRouter from './routes/settings.js';
|
||||
import { initDatabase } from './database/db.js';
|
||||
import { loadConfig } from './routes/settings.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// Load config
|
||||
const config = await loadConfig();
|
||||
const PORT = process.env.PORT || config.port || 3000;
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
@@ -27,6 +32,7 @@ app.use('/api/tracks', tracksRouter);
|
||||
app.use('/api/playlists', playlistsRouter);
|
||||
app.use('/api/albums', albumsRouter);
|
||||
app.use('/api/upload', uploadRouter);
|
||||
app.use('/api/settings', settingsRouter);
|
||||
|
||||
// Subsonic API
|
||||
app.use('/rest', subsonicRouter);
|
||||
@@ -34,8 +40,11 @@ app.use('/rest', subsonicRouter);
|
||||
// Serve static files
|
||||
app.use(express.static('public'));
|
||||
|
||||
// Serve audio files
|
||||
app.use('/audio', express.static(path.join(process.cwd(), 'audio_library')));
|
||||
// Serve audio files (use configured path)
|
||||
const libraryPath = path.isAbsolute(config.libraryPath)
|
||||
? config.libraryPath
|
||||
: path.join(process.cwd(), config.libraryPath);
|
||||
app.use('/audio', express.static(libraryPath));
|
||||
app.use('/artwork', express.static(path.join(process.cwd(), 'artwork')));
|
||||
|
||||
// Health check
|
||||
@@ -45,5 +54,6 @@ app.get('/health', (req, res) => {
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🎵 CarPlay Audio Server running on port ${PORT}`);
|
||||
console.log(`📁 Audio library: ${path.join(process.cwd(), 'audio_library')}`);
|
||||
console.log(`📁 Audio library: ${libraryPath}`);
|
||||
console.log(`🌐 Admin panel: http://localhost:${PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user