UNPKG

@master4n/decorators

Version:
3 lines (2 loc) 2.28 kB
"use strict";var t=require("config"),e=require("winston"),r=require("os"),n=require("uuid");const o=e.format.printf((({level:t,message:e,label:r,timestamp:n,stack:o})=>o?`${n} [${r}] ${t}: ${e}\n${o}`:`${n} [${r}] ${t}: ${e}`)),s=e.createLogger({defaultMeta:{host:r.hostname,env:process.env.NODE_ENV?process.env.NODE_ENV:"local"},format:e.format.combine((u="Master4Novice",e.format.label({label:`${u}`})),e.format.colorize(),e.format.timestamp(),e.format.errors({stack:!0}),o),transports:[new e.transports.Console]});var u;exports.Counter=function(t,e){t.constructor.hasOwnProperty("_counters")||Object.defineProperty(t.constructor,"_counters",{value:{},enumerable:!1,configurable:!0,writable:!0}),t.constructor._counters[e]||(t.constructor._counters[e]=0),Object.defineProperty(t,e,{get:function(){return t.constructor._counters[e]++,t.constructor._counters[e]},enumerable:!0,configurable:!0})},exports.GenerateID=function(t,e){const r=Symbol("uuid");Object.defineProperty(t,e,{get:function(){return this[r]||(this[r]=n.v4()),this[r]},set:function(t){this[r]=t},enumerable:!0,configurable:!0})},exports.Log=function(){return function(t,e,r){const n=r.value;return r.value=function(...t){s.info(`Entering ${e}`);const r=n.apply(this,t);return s.info(`Exiting ${e}`),r},r}},exports.NotNull=function(t,e,r){const n=r.value;return r.value=function(...t){return t.forEach((t=>{null==t&&s.error("Error: Arguments must not be null or undefined")})),n.apply(this,t)},r},exports.ValidDate=function(t,e){const r=t[e];t[e]=function(...t){const e=t[0];return function(t){if("object"==typeof t&&null!==t&&"string"==typeof t.DD&&"string"==typeof t.MM&&"string"==typeof t.YYYY){const e=parseInt(t.DD,10),r=parseInt(t.MM,10),n=parseInt(t.YYYY,10);return!isNaN(n)&&!isNaN(r)&&!isNaN(e)&&r>=1&&r<=12&&e>=1&&e<=new Date(n,r,0).getDate()}return!1}(e)||void 0===e||s.error("Error: Invalid parameter at index 0. Property 'DD', 'MM', and 'YYYY' must represent a valid date."),r.apply(this,t)}},exports.Value=function(e,r){return function(n,o){const s=Symbol("yml");Object.defineProperty(n,o,{get:function(){return this[s]||(this[s]=function(e,r){try{return t.get(e)}catch(t){return r}}(e,r)),this[s]},set:function(t){this[s]=t},enumerable:!0,configurable:!0})}}; //# sourceMappingURL=index.cjs.map