UNPKG

@nova-ts/core

Version:

A serverside framework used to build scalable application

75 lines (72 loc) 2.55 kB
import * as express_serve_static_core from 'express-serve-static-core'; import express from 'express'; /** * Options for configuring the Nova application. * This interface allows you to specify the port, * middlewares, and an existing Express application instance. * You can use this to customize the behavior of the Nova application * during initialization. */ type NovaOptions = { port?: number; middlewares?: any[]; application?: express.Express; }; /** * Bootstraps and configures the entire application. * * This function is used to initialize the framework, * set up routes, middleware, dependency injection, and start the Express server. * * Example usage: * ```ts * const Application = new ApplicationFactory(); * Application.InitializeApplication().startApplication(); * ``` * * port - The port number on which the application should listen. * @returns {void | Promise<void>} Starts the server after all configurations are complete. * @author Inbanithi107 * @requires ```@nova-ts/context``` installed in the application */ declare class ApplicationFactory { private Application; private port; constructor(options?: NovaOptions); /** * * @param port It is the port number on which the application should listen. * @returns Instance of ApplicationFactory for method chaining. */ setPort(port: number): this; /** * * @returns The express application instance. */ getApplication(): express_serve_static_core.Express; /** * Sets the Express application instance. * This allows for custom configurations or middleware to be applied before starting the server. * * @param {express.Express} application - The Express application instance. * @returns {ApplicationFactory} The current instance of ApplicationFactory for method chaining. */ setApplication(application: any): this; /** * Initializes the application by loading configurations, * setting up routes, and exception handling. * @returns Instance of ApplicationFactory for method chaining. */ InitializeApplication(): this; /** * * @param middlewares An array of middleware functions to be applied to the application. * @returns The current instance of ApplicationFactory for method chaining. */ applyMiddlewares(middlewares: any[]): this; /** * Starts the application by listening on the specified port. */ startApplication(): void; } export { ApplicationFactory, type NovaOptions };