UNPKG

@szegedsw/lib-node

Version:

A little framework published by Szeged Software Zrt. in order to enhance api endpoint security and create reuseable code. Email module, Logging system, and much more. Further improvements are expected.

25 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.upgradeAvailable = void 0; const config_1 = require("../config/config"); const try_1 = require("../functions/try"); function upgradeAvailable() { return async (req, res, next) => { await try_1._try(res, async () => { var _a, _b; // tslint:disable: no-string-literal const version = req.headers.version || config_1.env.clientVersion; // tslint:disable: max-line-length if (version < config_1.env.clientVersion && (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.lastNote) || ((_b = req.session) === null || _b === void 0 ? void 0 : _b.lastNote) < Date.now() - config_1.env.upgradeNoteInterval)) { if (req.session) { req.session.lastNote = Date.now(); res.status(config_1.HttpCodes.upgradeRequired).end(); return; } } next(); }); }; } exports.upgradeAvailable = upgradeAvailable; //# sourceMappingURL=upgrade.available.js.map