chore: remove server functions from core package
This commit is contained in:
parent
8ae1e4a24a
commit
1bb9d6ce1f
@ -44,11 +44,8 @@ export class App implements Processor {
|
||||
/**
|
||||
* Checks if the given path is a subdirectory of the given directory.
|
||||
*
|
||||
* @param _event - The IPC event object.
|
||||
* @param from - The path to check.
|
||||
* @param to - The directory to check against.
|
||||
*
|
||||
* @returns {Promise<boolean>} - A promise that resolves with the result.
|
||||
*/
|
||||
isSubdirectory(from: any, to: any) {
|
||||
const rel = relative(from, to)
|
||||
@ -79,26 +76,4 @@ export class App implements Processor {
|
||||
async updateAppConfiguration(args: any) {
|
||||
await updateAppConfiguration(args)
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Jan API Server.
|
||||
*/
|
||||
async startServer(args?: any) {
|
||||
const { startServer } = require('@janhq/server')
|
||||
return startServer({
|
||||
host: args?.host,
|
||||
port: args?.port,
|
||||
isCorsEnabled: args?.isCorsEnabled,
|
||||
isVerboseEnabled: args?.isVerboseEnabled,
|
||||
prefix: args?.prefix,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop Jan API Server.
|
||||
*/
|
||||
stopServer() {
|
||||
const { stopServer } = require('@janhq/server')
|
||||
return stopServer()
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,10 @@ export enum NativeRoute {
|
||||
|
||||
quickAskSizeUpdated = 'quickAskSizeUpdated',
|
||||
ackDeepLink = 'ackDeepLink',
|
||||
factoryReset = 'factoryReset'
|
||||
factoryReset = 'factoryReset',
|
||||
|
||||
startServer = 'startServer',
|
||||
stopServer = 'stopServer',
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,8 +44,6 @@ export enum AppRoute {
|
||||
dirName = 'dirName',
|
||||
isSubdirectory = 'isSubdirectory',
|
||||
baseName = 'baseName',
|
||||
startServer = 'startServer',
|
||||
stopServer = 'stopServer',
|
||||
log = 'log',
|
||||
systemInformation = 'systemInformation',
|
||||
showToast = 'showToast',
|
||||
|
||||
@ -277,4 +277,39 @@ export function handleAppIPCs() {
|
||||
ModuleManager.instance.clearImportedModules()
|
||||
return createUserSpace().then(migrate).then(setupExtensions)
|
||||
})
|
||||
|
||||
/**
|
||||
* Handles the "startServer" IPC message to start the Jan API server.
|
||||
* Initializes and starts server with provided configuration options.
|
||||
* @param _event - The IPC event object.
|
||||
* @param args - Configuration object containing host, port, CORS settings etc.
|
||||
* @returns Promise that resolves when server starts successfully
|
||||
*/
|
||||
ipcMain.handle(
|
||||
NativeRoute.startServer,
|
||||
async (_event, args): Promise<void> => {
|
||||
const { startServer } = require('@janhq/server')
|
||||
return startServer({
|
||||
host: args?.host,
|
||||
port: args?.port,
|
||||
isCorsEnabled: args?.isCorsEnabled,
|
||||
isVerboseEnabled: args?.isVerboseEnabled,
|
||||
prefix: args?.prefix,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Handles the "stopServer" IPC message to stop the Jan API server.
|
||||
* Gracefully shuts down the server instance.
|
||||
* @param _event - The IPC event object
|
||||
* @returns Promise that resolves when server stops successfully
|
||||
*/
|
||||
ipcMain.handle(NativeRoute.stopServer, async (_event): Promise<void> => {
|
||||
/**
|
||||
* Stop Jan API Server.
|
||||
*/
|
||||
const { stopServer } = require('@janhq/server')
|
||||
return stopServer()
|
||||
})
|
||||
}
|
||||
|
||||
@ -36,5 +36,8 @@
|
||||
"run-script-os": "^1.1.6",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"bundleDependencies": [
|
||||
"@fastify/swagger-ui"
|
||||
],
|
||||
"packageManager": "yarn@4.5.3"
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ export default defineConfig([
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts'],
|
||||
},
|
||||
external: ['@fastify/swagger-ui'],
|
||||
platform: 'node',
|
||||
},
|
||||
])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user