mirror of
https://github.com/leon-ai/leon.git
synced 2025-01-04 15:55:58 +03:00
refactor(server): prepare upcoming core singletons registration
This commit is contained in:
parent
efe865a4c5
commit
b3b10e326f
@ -18,6 +18,7 @@ import {
|
||||
STT_PROVIDER,
|
||||
TTS_PROVIDER
|
||||
} from '@/constants'
|
||||
import { TCP_CLIENT } from '@/core'
|
||||
import Nlu from '@/core/nlu'
|
||||
import Brain from '@/core/brain'
|
||||
import Asr from '@/core/asr'
|
||||
@ -30,7 +31,6 @@ import infoPlugin from '@/core/http-server/api/info'
|
||||
import downloadsPlugin from '@/core/http-server/api/downloads'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { DateHelper } from '@/helpers/date-helper'
|
||||
import { TCP_CLIENT } from '@/core/tcp-client'
|
||||
|
||||
const server = {}
|
||||
|
||||
|
11
server/src/core/index.ts
Normal file
11
server/src/core/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { TCP_SERVER_HOST, TCP_SERVER_PORT } from '@/constants'
|
||||
import TCPClient from '@/core/tcp-client'
|
||||
|
||||
/**
|
||||
* Register core singletons
|
||||
*/
|
||||
|
||||
export const TCP_CLIENT = new TCPClient(
|
||||
String(TCP_SERVER_HOST),
|
||||
TCP_SERVER_PORT
|
||||
)
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { TCP_CLIENT } from '@/core'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
import { TCP_CLIENT } from '@/core/tcp-client'
|
||||
|
||||
class Ner {
|
||||
constructor(ner) {
|
||||
@ -45,7 +45,7 @@ class Ner {
|
||||
|
||||
/**
|
||||
* Browse action entities
|
||||
* Dynamic injection of the action entities depending of the entity type
|
||||
* Dynamic injection of the action entities depending on the entity type
|
||||
*/
|
||||
for (let i = 0; i < actionEntities.length; i += 1) {
|
||||
const entity = actionEntities[i]
|
||||
|
@ -12,11 +12,11 @@ import kill from 'tree-kill'
|
||||
import { langs } from '@@/core/langs.json'
|
||||
import { version } from '@@/package.json'
|
||||
import { HAS_LOGGER, IS_TESTING_ENV, TCP_SERVER_BIN_PATH } from '@/constants'
|
||||
import { TCP_CLIENT } from '@/core'
|
||||
import Ner from '@/core/ner'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
import { LangHelper } from '@/helpers/lang-helper'
|
||||
import { TCP_CLIENT } from '@/core/tcp-client'
|
||||
import Conversation from '@/core/conversation'
|
||||
|
||||
const defaultNluResultObj = {
|
||||
|
@ -1,11 +1,7 @@
|
||||
import Net from 'node:net'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
import {
|
||||
IS_PRODUCTION_ENV,
|
||||
TCP_SERVER_HOST,
|
||||
TCP_SERVER_PORT
|
||||
} from '@/constants'
|
||||
import { IS_PRODUCTION_ENV } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { OSHelper, OSTypes } from '@/helpers/os-helper'
|
||||
|
||||
@ -14,7 +10,7 @@ const INTERVAL = IS_PRODUCTION_ENV ? 3000 : 500
|
||||
// Number of retries to connect to the TCP server
|
||||
const RETRIES_NB = IS_PRODUCTION_ENV ? 8 : 30
|
||||
|
||||
class TCPClient {
|
||||
export default class TCPClient {
|
||||
private static instance: TCPClient
|
||||
|
||||
private reconnectCounter = 0
|
||||
@ -126,8 +122,3 @@ class TCPClient {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const TCP_CLIENT = new TCPClient(
|
||||
String(TCP_SERVER_HOST),
|
||||
TCP_SERVER_PORT
|
||||
)
|
||||
|
@ -5,8 +5,8 @@ import {
|
||||
LANG as LEON_LANG,
|
||||
TCP_SERVER_BIN_PATH
|
||||
} from '@/constants'
|
||||
import { TCP_CLIENT } from '@/core'
|
||||
import { LangHelper } from '@/helpers/lang-helper'
|
||||
import { TCP_CLIENT } from '@/core/tcp-client'
|
||||
import server from '@/core/http-server/server'
|
||||
;(async (): Promise<void> => {
|
||||
process.title = 'leon'
|
||||
|
Loading…
Reference in New Issue
Block a user