UNPKG

@arisan/data-api

Version:

The Universal Database API Gateway for CLIO's Modules

37 lines (33 loc) 995 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = checkPort; var _DataAPI = require('../DataAPI'); //endregion function checkPort(req, res, next) { const log = (lvl, msg) => _DataAPI.logger.log(lvl, msg, { tags: 'checkPort' }); if (typeof req.body.port === 'undefined') { const message = 'No Port'; log('error', message); res.status(400).send(message); return; } // if (typeof req.body.port !== 'number') { // const message = 'Malformed Port'; // log('error', message); // res.status(400).send(message); // return; // } const port = parseInt(req.body.port, 10); if (port < 1 || port > 65535) { const message = `Port in Invalid Range ${port}`; log('error', message); res.status(400).send(message); return; } if (next) { next(); } } //region 2. Project Libraries //# sourceMappingURL=checkPort.js.map