Skip to content

@waylis/core


@waylis/core / AppServer

Class: AppServer

Defined in: server/server.ts:60

Main application server.

This class encapsulates the initialization and lifecycle management of the server, including database, file storage, configuration, and logging.

Constructors

Constructor

ts
new AppServer(params?: AppServerParams): AppServer;

Defined in: server/server.ts:80

Create a new application server instance.

Parameters

params?

AppServerParams

Optional initialization parameters used to configure the server. If omitted, defaults will be applied.

Returns

AppServer

Properties

PropertyModifierTypeDefined in
chatManagerprotectedChatManagerserver/server.ts:65
configprotectedServerConfigserver/server.ts:61
connectionsprotectedMap<string, ServerResponse<IncomingMessage>>server/server.ts:72
databaseprotectedDatabaseserver/server.ts:62
engineprotectedSceneEngineserver/server.ts:70
eventBusprotectedEventBusClassserver/server.ts:71
fileManagerprotectedFileManagerserver/server.ts:64
fileStorageprotectedFileStorageserver/server.ts:63
loggerprotectedLoggerserver/server.ts:68
messageManagerprotectedMessageManagerserver/server.ts:66
stepManagerprotectedStepManagerserver/server.ts:67

Methods

addScene()

ts
addScene<Steps>(command: Command, scene: {
  handler: (responses: SceneResponsesMap<Steps>) => Promise<
     | SystemMessageBody
    | SystemMessageBody[]>;
  steps: [...Steps[]];
}): void;

Defined in: server/server.ts:222

Add a new scene to the application.

A scene represents a sequence of steps that the engine will execute when the specified command is triggered.

Type Parameters

Steps

Steps extends readonly SceneStep<any, any>[]

A tuple of SceneStep definitions representing the ordered steps of the scene.

Parameters

command

Command

The command that will trigger this scene.

scene

The actual scene.

handler

(responses: SceneResponsesMap<Steps>) => Promise< | SystemMessageBody | SystemMessageBody[]>

steps

[...Steps[]]

Returns

void


getFileManager()

ts
getFileManager(): Promise<FileManager>;

Defined in: server/server.ts:237

Get the FileManager instance for managing files.

Returns

Promise<FileManager>

A promise that resolves to the FileManager instance.


start()

ts
start(): Promise<Server<typeof IncomingMessage, typeof ServerResponse>>;

Defined in: server/server.ts:182

Start the HTTP server.

Returns

Promise<Server<typeof IncomingMessage, typeof ServerResponse>>

A new instance of the HTTP server.

Released under the MIT License.