UNPKG

rexuws

Version:

An express-like framework built on top of uWebsocket.js aims at simple codebase and high performance

23 lines (22 loc) 842 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = __importDefault(require("../base")); class PrefixRouter extends base_1.default { constructor(prefix) { super(); if (!prefix || typeof prefix !== 'string') throw new TypeError('Prefix must be a string'); this.prefix = prefix; } transform(args) { if (!args || !Array.isArray(args) || args.length < 1) throw new TypeError('Invalid router pattern'); if (args.some((e) => typeof e !== 'function')) throw new TypeError('Middleware must be a function'); return [this.prefix, args]; } } exports.default = PrefixRouter;