UNPKG

mp-holistic

Version:

si prefigge l'umile compito di aiutare nella creazione di : - un server API REST mediante express - un semplice ORM per Postgres Questo tramite decoratori o classi particolari.

68 lines 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MetodoLimitazioni = void 0; /** * */ class MetodoLimitazioni { constructor() { this.slow_down = { windowMs: 1000, delayAfter: 1000, delayMs: 5000, maxDelayMs: 6000, onLimitReached: (req, res, options) => { res.status(555).send("rate_limit : onLimitReached"); throw new Error("Errore: rate_limit : onLimitReached"); } }; this.rate_limit = { windowMs: 500, max: 1000, onLimitReached: (req, res, options) => { res.status(555).send("rate_limit : onLimitReached"); throw new Error("Errroe: rate_limit : onLimitReached"); } }; this.middleware = []; //cacheOptionRedis: OptionsCache; this.cacheOptionMemory = undefined; //= { durationSecondi: 1 }; /* constructor(){ this.slow_down = } */ } Init(item) { if (item.slow_down) this.slow_down = item.slow_down; if (item.rate_limit) this.rate_limit = item.rate_limit; if (item.middleware) this.middleware = item.middleware; if (item.cacheOptionMemory) this.cacheOptionMemory = item.cacheOptionMemory; if (item.helmet != undefined) this.helmet = item.helmet; if (item.cors != undefined) this.cors = item.cors; if (item.corsOption != undefined) this.corsOption = item.corsOption; } PrintStruttura() { let ritorno = ''; if (this.slow_down) ritorno = ritorno + '\nslow_down :' + JSON.stringify(this.slow_down); if (this.rate_limit) ritorno = ritorno + '\nrate_limit :' + JSON.stringify(this.rate_limit); if (this.cors) ritorno = ritorno + '\ncors :' + JSON.stringify(this.cors); if (this.helmet) ritorno = ritorno + '\nhelmet :' + JSON.stringify(this.helmet); if (this.middleware) ritorno = ritorno + '\nmiddleware :' + JSON.stringify(this.middleware); if (this.cacheOptionMemory) ritorno = ritorno + '\ncacheOptionMemory :' + JSON.stringify(this.cacheOptionMemory); return ritorno; } } exports.MetodoLimitazioni = MetodoLimitazioni; //# sourceMappingURL=MetodoLimitazioni.js.map