@xmobitea/gn-server
Version:
GearN Server by XmobiTea (Pro)
227 lines (226 loc) • 8.35 kB
TypeScript
import { IBuilder } from "./../GN-library/xbuilder/lib/IBuilder";
import { ApplicationSettings } from "./settings/ApplicationSettings";
import { HttpAppSettings } from "./settings/HttpAppSettings";
import { SocketAppSettings } from "./settings/SocketAppSettings";
import { GNServer } from "./../GNServer";
import { DatabaseSettings } from "./settings/DatabaseSettings";
import { OtherSettings } from "./settings/OtherSettings";
import { OnRunSuccess } from "./../GN-library/xbuilder/lib/OnRunSuccess";
import { LogSettings } from "./settings/LogSettings";
import { UploadFileSettings } from "./settings/UploadFileSettings";
import { DdosSettings } from "./settings/DDosSettings";
import { ClusterSettings } from "./settings/ClusterSettings";
declare abstract class BuilderBase {
protected applicationSettings: ApplicationSettings;
protected httpAppSettings: HttpAppSettings;
protected socketAppSettings: SocketAppSettings;
protected databaseSettings: DatabaseSettings;
protected otherSettings: OtherSettings;
protected logSettings: LogSettings;
protected uploadFileSettings: UploadFileSettings;
protected ddosSettings: DdosSettings;
protected clusterSettings: ClusterSettings;
/**
* Returns the application settings.
* @returns Returns the application settings.
*/
getApplicationSettings(): ApplicationSettings;
/**
* Returns the HTTP app settings.
* @returns Returns the HTTP app settings.
*/
getHttpAppSettings(): HttpAppSettings;
/**
* Returns the socket app settings.
* @returns Returns the socket app settings.
*/
getSocketAppSettings(): SocketAppSettings;
/**
* Returns the database settings.
* @returns Returns the database settings.
*/
getDatabaseSettings(): DatabaseSettings;
/**
* Returns the other settings.
* @returns Returns the other settings.
*/
getOtherSettings(): OtherSettings;
/**
* Returns the log settings.
* @returns Returns the log settings.
*/
getLogSettings(): LogSettings;
/**
* Returns the upload file settings.
* @returns Returns the upload file settings.
*/
getUploadFileSettings(): UploadFileSettings;
/**
* Returns the DDoS settings.
* @returns Returns the DDoS settings.
*/
getDdosSettings(): DdosSettings;
/**
* Returns the cluster settings.
* @returns Returns the cluster settings.
*/
getClusterSettings(): ClusterSettings;
/**
* Initializes a new builder base instance.
*/
constructor();
}
declare class Builder extends BuilderBase implements IBuilder<ServerApplication> {
/**
* Sets the application settings.
* @param applicationSettings Provides the application settings value used by this operation.
* @returns Returns the current builder instance.
*/
setApplicationSettings(applicationSettings: ApplicationSettings): Builder;
/**
* Sets the HTTP app settings.
* @param httpAppSettings Provides the HTTP app settings value used by this operation.
* @returns Returns the current builder instance.
*/
setHttpAppSettings(httpAppSettings: HttpAppSettings): Builder;
/**
* Sets the socket app settings.
* @param socketAppSettings Provides the socket app settings value used by this operation.
* @returns Returns the current builder instance.
*/
setSocketAppSettings(socketAppSettings: SocketAppSettings): Builder;
/**
* Sets the database settings.
* @param databaseSettings Provides the database settings value used by this operation.
* @returns Returns the current builder instance.
*/
setDatabaseSettings(databaseSettings: DatabaseSettings): Builder;
/**
* Sets the other settings.
* @param otherSettings Provides the other settings value used by this operation.
* @returns Returns the current builder instance.
*/
setOtherSettings(otherSettings: OtherSettings): Builder;
/**
* Sets the log settings.
* @param logSettings Provides the log settings value used by this operation.
* @returns Returns the current builder instance.
*/
setLogSettings(logSettings: LogSettings): Builder;
/**
* Sets the upload file settings.
* @param uploadFileSettings Provides the upload file settings value used by this operation.
* @returns Returns the current builder instance.
*/
setUploadFileSettings(uploadFileSettings: UploadFileSettings): Builder;
/**
* Sets the DDoS settings.
* @param ddosSettings Provides the DDoS settings value used by this operation.
* @returns Returns the current builder instance.
*/
setDdosSettings(ddosSettings: DdosSettings): Builder;
/**
* Sets the cluster settings.
* @param clusterSettings Provides the cluster settings value used by this operation.
* @returns Returns the current builder instance.
*/
setClusterSettings(clusterSettings: ClusterSettings): Builder;
/**
* Builds the configured instance.
*/
build(): ServerApplication;
/**
* Initializes a new builder instance.
*/
constructor();
}
/**
* Owns the full startup pipeline after settings have been materialized by `ServerApplicationStartup`.
*/
export declare class ServerApplication extends BuilderBase {
private httpApp;
private socketApp;
private gnServer;
private apiMiddleware;
private antiDdosMiddleware;
private uploadFileMiddleware;
private sessionId;
private secretkey;
private secretId;
/**
* Wires middleware, transports, database bootstrap, and runtime services, then starts listening.
* @param onRunSuccess Provides the callback executed after a successful startup.
*/
run(onRunSuccess?: OnRunSuccess): Promise<void>;
/**
* Ensures required system collections exist and seeds a fresh installation when no version document is found.
*/
private setupDatabase;
/**
* Creates indexes, default secrets, root admin, and baseline game documents for a brand-new installation.
*/
private setupNewGNDatabase;
/**
* Placeholder for future schema migrations when the persisted database version lags the server version.
* @param oldVersion Provides the old version value used by this operation.
*/
private reSetupGNDatabase;
/**
* Loads master settings plus every game definition from MongoDB into the in-memory runtime graph.
* @returns Resolves with the operation result.
*/
private applySettingsGame;
/**
* Creates the runtime coordinator and primes its database connections before transports start listening.
* @returns Returns the operation result.
*/
private newGNServer;
/**
* Factory method kept overridable for custom startup implementations.
* @returns Returns the operation result.
*/
private newApiMiddleware;
/**
* Factory method kept overridable for custom startup implementations.
* @returns Returns the operation result.
*/
private newAntiDdosMiddleware;
/**
* Factory method kept overridable for custom startup implementations.
* @returns Returns the operation result.
*/
private newUploadMiddleware;
/**
* Returns the GearN server.
* @returns Returns the GearN server.
*/
getGNServer(): GNServer;
/**
* Executes the new HTTP app workflow.
* @returns Returns the operation result.
*/
private newHttpApp;
/**
* Executes the new socket app workflow.
* @returns Returns the operation result.
*/
private newSocketApp;
/**
* Creates the underlying HTTP/HTTPS server used by Express and, when ports match, by Socket.IO as well.
* @param app Provides the app value used by this operation.
* @param settings Provides the settings value used by this operation.
* @returns Returns the server.
*/
private getServer;
/**
* Initializes a new server application instance.
* @param builder Provides the builder state copied into this instance.
*/
constructor(builder: BuilderBase);
/**
* Creates a new builder instance.
* @returns Returns a new builder instance.
*/
static Builder(): Builder;
}
export {};