UNPKG

tiny-server-essentials

Version:

A good utility toolkit to unify Express v5 and Socket.IO v4 into a seamless development experience with modular helpers, server wrappers, and WebSocket tools.

50 lines (49 loc) 1.58 kB
import * as Utils from './Utils.mjs'; import TinyWebInstance from './TinyWebInstance.mjs'; import TinyExpress from './TinyExpress.mjs'; import TinyIo from './TinyIo.mjs'; /** * Central access point for all essential modules provided by the TinyWeb toolkit. * * This class acts as a namespace-like container to group the Express, Socket.IO, * server instance tools, and utility features in a unified API. * * Example: * ```js * import TinyWebEssentials from 'tiny-server-essentials'; * * const server1 = TinyWebEssentials.Express(); * const server2 = TinyWebEssentials.Io(); * const instance = new TinyWebEssentials.Instance(); * ``` */ class TinyWebEssentials { /** * Utility functions such as IP extractors and filters. */ static Utils = Utils; static Instance = TinyWebInstance; static Express = TinyExpress; static Io = TinyIo; /** * This constructor is intentionally blocked. * * ⚠️ You must NOT instantiate TinyWebEssentials directly. * To create a working instance, use {@link TinyWebEssentials.Express}, and {@link TinyWebEssentials.Io}: * * ```js * const server = new TinyWebEssentials.Express(); * ``` * * ```js * const server = TinyWebEssentials.Io(); * ``` * * @constructor * @throws {Error} Always throws an error to prevent direct instantiation. */ constructor() { throw new Error('You must use new TinyWebEssentials.Express() or TinyWebEssentials.Io() to create your new instance.'); } } export default TinyWebEssentials;