@longjs/core
Introduction
@longjs/core is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
Installation
> yarn add @longjs/core
or
> npm install @longjs/core
Use
import Server from '@longjs/core'
new Server({})
Server(options: Options)
1. options
- port?: number;
- host?: string;
- configs?: Configs;
- keys?: Keygrip | string[];
- env?: Env;
- proxy?: boolean; defalut false
- subdomainOffset?: number; defalut 2
- silent?: boolean;
- plugins?: Plugins;
- controllers?: Array<{ new (...args: any[]): any }>;
- routeStrict?: boolean;
Api
- listen
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this; listen(port: number, hostname?: string, listeningListener?: () => void): this; listen(port: number, backlog?: number, listeningListener?: () => void): this; listen(port: number, listeningListener?: () => void): this; listen(path: string, backlog?: number, listeningListener?: () => void): this; listen(path: string, listeningListener?: () => void): this; listen(options: ListenOptions, listeningListener?: () => void): this; listen(handle: any, backlog?: number, listeningListener?: () => void): this; listen(handle: any, listeningListener?: () => void): this;
- getPluginID
getPluginID(pluginConstructor: { new (...args: any[]): any}): string;
return plugin uid
- callback
return (request: IncomingMessage, response: ServerResponse): this;