fix: update server settings ref

This commit is contained in:
Louis 2024-01-16 11:42:55 +07:00 committed by Faisal Amir
parent 5975237a39
commit 013c0ce36e

View File

@ -4,7 +4,14 @@ import { WindowManager } from './../managers/window'
import { getResourcePath, userSpacePath } from './../utils/path'
import { AppRoute } from '@janhq/core'
import { ModuleManager, init, log } from '@janhq/core/node'
import { startServer, stopServer } from '@janhq/server'
import {
startServer,
stopServer,
isCorsEnabled,
isVerboseEnabled,
getHost,
getPort,
} from '@janhq/server'
export function handleAppIPCs() {
/**
@ -51,8 +58,14 @@ export function handleAppIPCs() {
/**
* Start Jan API Server.
*/
ipcMain.handle(AppRoute.startServer, async (_event) =>
ipcMain.handle(
AppRoute.startServer,
async (_event, host, port, isCorsEnabled, isVerbose) =>
startServer(
host,
port,
isCorsEnabled,
isVerbose,
app.isPackaged
? join(getResourcePath(), 'docs', 'openapi', 'jan.yaml')
: undefined,
@ -63,7 +76,27 @@ export function handleAppIPCs() {
/**
* Stop Jan API Server.
*/
ipcMain.handle(AppRoute.stopServer, async (_event) => stopServer())
ipcMain.handle(AppRoute.stopServer, stopServer)
/**
* Check if CORS is enabled.
*/
ipcMain.handle(AppRoute.isCorsEnabled, isCorsEnabled)
/**
* Check if verbose logging is enabled.
*/
ipcMain.handle(AppRoute.isVerboseEnabled, isVerboseEnabled)
/**
* Get the host setting.
*/
ipcMain.handle(AppRoute.getHost, getHost)
/**
* Get the port setting.
*/
ipcMain.handle(AppRoute.getPort, getPort)
/**
* Relaunches the app in production - reload window in development.