mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 12:36:15 -08:00
Add a new HttpServer class that serves the built remote-control-web static assets and provides a simple REST/API routing layer for remote control endpoints. Key changes: - Implement server lifecycle: start, stop, updateSettings with port and enabled handling. - Resolve distribution path depending on electron packaging (dev vs production). - Serve static files with basic security (normalize path to prevent traversal) and SPA fallback to index.html for client-side routing. - Provide registration API for remote control handlers mapped to /api/remote-control/* endpoints. - Log server status and listening URL on start, and on stop. These changes enable the Electron backend to host the remote control web app and route API calls without external web servers, simplifying development and packaging.
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { app, BrowserWindow } from 'electron';
|
|
import fixPath from 'fix-path';
|
|
import App from './app/app';
|
|
import { initDatabase } from './app/database/connection';
|
|
import DatabaseEvents from './app/events/database.events';
|
|
import ElectronEvents from './app/events/electron.events';
|
|
import EpgEvents from './app/events/epg.events';
|
|
import PlayerEvents from './app/events/player.events';
|
|
import PlaylistEvents from './app/events/playlist.events';
|
|
import RemoteControlEvents from './app/events/remote-control.events';
|
|
import SettingsEvents from './app/events/settings.events';
|
|
import SharedEvents from './app/events/shared.events';
|
|
import SquirrelEvents from './app/events/squirrel.events';
|
|
import StalkerEvents from './app/events/stalker.events';
|
|
import XtreamEvents from './app/events/xtream.events';
|
|
|
|
app.setName('iptvnator');
|
|
|
|
export default class Main {
|
|
static initialize() {
|
|
if (SquirrelEvents.handleEvents()) {
|
|
// squirrel event handled (except first run event) and app will exit in 1000ms, so don't do anything else
|
|
app.quit();
|
|
}
|
|
}
|
|
|
|
static bootstrapApp() {
|
|
App.main(app, BrowserWindow);
|
|
}
|
|
|
|
static async bootstrapAppEvents() {
|
|
// Initialize database before other events
|
|
await initDatabase();
|
|
|
|
ElectronEvents.bootstrapElectronEvents();
|
|
PlaylistEvents.bootstrapPlaylistEvents();
|
|
SharedEvents.bootstrapSharedEvents();
|
|
PlayerEvents.bootstrapPlayerEvents();
|
|
SettingsEvents.bootstrapSettingsEvents();
|
|
StalkerEvents.bootstrapStalkerEvents();
|
|
XtreamEvents.bootstrapXtreamEvents();
|
|
DatabaseEvents.bootstrapDatabaseEvents();
|
|
EpgEvents.bootstrapEpgEvents();
|
|
RemoteControlEvents.bootstrapRemoteControlEvents();
|
|
|
|
// initialize auto updater service
|
|
if (!App.isDevelopmentMode()) {
|
|
// UpdateEvents.initAutoUpdateService();
|
|
}
|
|
}
|
|
}
|
|
|
|
fixPath();
|
|
|
|
// handle setup events as quickly as possible
|
|
Main.initialize();
|
|
|
|
// bootstrap app
|
|
Main.bootstrapApp();
|
|
|
|
// Bootstrap app events after Electron app is ready
|
|
app.whenReady().then(async () => {
|
|
await Main.bootstrapAppEvents();
|
|
});
|