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.
58 lines (52 loc) • 1.57 kB
JavaScript
var Utils = require('./Utils.cjs');
var TinyWebInstance = require('./TinyWebInstance.cjs');
var TinyExpress = require('./TinyExpress.cjs');
var TinyIo = require('./TinyIo.cjs');
/**
* 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.',
);
}
}
module.exports = TinyWebEssentials;
;