UNPKG

irest-app-test

Version:

iRest is a zero-configuration application that allows you to easily create/manage APIs, generate random data on demand and perform operations on that data using REST interface.

4 lines 2.15 kB
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_typeof=require("@babel/runtime/helpers/typeof");Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleErrorLogs=exports.handleDevLogs=void 0;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_winston=_interopRequireWildcard(require("winston")),_expressWinston=_interopRequireDefault(require("express-winston")),_excluded=["label","timestamp","level","message"];function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!==_typeof(a)&&"function"!=typeof a)return{default:a};var c=_getRequireWildcardCache(b);if(c&&c.has(a))return c.get(a);var d={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}return d["default"]=a,c&&c.set(a,d),d}var printf=_winston.format.printf,combine=_winston.format.combine,timestamp=_winston.format.timestamp,label=_winston.format.label,colorize=_winston.format.colorize,handleDevLogs=_expressWinston["default"].logger({transports:[new _winston.transports.Console],format:combine(colorize(),combine(colorize({all:!0}),label({label:"\n[Access Log]"}),timestamp({format:"YY-MM-DD HH:MM:SS"}),printf(// eslint-disable-next-line no-shadow function(a){var b=a.label,c=a.timestamp,d=a.level,e=a.message,f=(0,_objectWithoutProperties2["default"])(a,_excluded);return"".concat(b," ").concat(c," ").concat(d,": ").concat(e," ").concat(JSON.stringify(f))})))});// express winston acesss logs.before handling the routes. exports.handleDevLogs=handleDevLogs;// express winston error log var handleErrorLogs=_expressWinston["default"].errorLogger({transports:[new _winston["default"].transports.Console({json:!0,colorize:!0})]});exports.handleErrorLogs=handleErrorLogs;