UNPKG

lemoncloud-engine-js

Version:

lemoncloud.io - Lemon Engine Modle of Node for Robust Micro-service based on DynamoDB + ElastiCache + Elasticsearch.

1 lines 3.06 kB
"use strict";function initialize(r,e){var i=this;if(!r)throw new Error("$export is required.");if(!i)throw new Error("_$ is required.");if("function"!=typeof i)throw new Error("_$ should be function.");i.log;var o=i.inf,t=(i.err,i.environ("STAGE",""));t&&o("#STAGE =",t),i("U",require("./lib/utilities")(i));var n=require("./lib/http-proxy");i("httpProxy",n),require("./lib/mysql-proxy")(i,"MS"),require("./lib/dynamo-proxy")(i,"DS"),require("./lib/redis-proxy")(i,"RS"),require("./lib/elastic-proxy")(i,"ES"),require("./lib/elastic6-proxy")(i,"ES6"),require("./lib/s3-proxy")(i,"S3"),require("./lib/sqs-proxy")(i,"SS"),require("./lib/sns-proxy")(i,"SN"),require("./lib/ses-proxy")(i,"SE"),require("./lib/web-proxy")(i,"WS"),require("./lib/cognito-proxy")(i,"CS"),require("./lib/lambda-proxy")(i,"LS"),require("./lib/protocol-proxy")(i,"PR"),require("./lib/cron-proxy")(i,"CR"),require("./lib/agw-proxy")(i,"AG");var u=require("./core/lemon-engine-model");return i("LEM",u),Object.assign(r,{createModel:function(r,e,i){return u(r,e,i)},createHttpProxy:function(r,e,i){return n(r,e,i)}})}module.exports=function(r,t){r=r||new function(){};function n(){var r=!Array.isArray(arguments)&&Array.prototype.slice.call(arguments)||arguments;return c.auto_color?(r.unshift(""),c.auto_ts&&r.unshift(p(),"L")||r.unshift("L"),r.unshift("")):c.auto_ts&&r.unshift(p(),"L"),c.log.apply(c.thiz,r)}function e(){var r=!Array.isArray(arguments)&&Array.prototype.slice.call(arguments)||arguments;return c.auto_color?(r.unshift(""),r.push(""),c.auto_ts&&r.unshift(p(),"I")||r.unshift("I"),r.unshift("")):c.auto_ts&&r.unshift(p(),"I"),c.log.apply(c.thiz,r)}function u(){var r=!Array.isArray(arguments)&&Array.prototype.slice.call(arguments)||arguments;return c.auto_color?(r.unshift(""),r.push(""),c.auto_ts&&r.unshift(p(),"E")||r.unshift("E"),r.unshift("")):c.auto_ts&&r.unshift(p(),"E"),c.error.apply(c.thiz,r)}function s(r,e){for(var i in e){var o=e[i];void 0===o?delete r[i]:r[i]=o}return r}var i=(t=t||{}).name||"lemon",o=f("STAGE",""),l="1"===f("TS","1"),a="local"===o||"express"===o||"1"===f("LC",""),c={thiz:console,log:console.log,error:console.error,auto_ts:l,auto_color:a};function p(r){var e=r||new Date,i=[e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()],o=i[0],t=i[1],n=i[2],u=i[3],s=i[4],l=i[5];return(o<10?"0":"")+o+"-"+(t<10?"0":"")+t+"-"+(n<10?"0":"")+n+" "+(u<10?"0":"")+u+":"+(s<10?"0":"")+s+":"+(l<10?"0":"")+l}function f(r,e){var i=t.env||process&&process.env||{},o=i&&i[r]||void 0;if(e&&e instanceof Error&&void 0===o)throw e;return void 0===o?e:o}function y(r,e){if(r){var i=y,o=void 0!==i[r]?i[r]:void 0;return void 0===e?o:void 0===o?(n("INFO! service["+r+"] registered"),i[r]=e):(u("WARN! service["+r+"] exists! so extends "),o=s(o=o||{},e=e||{}),i[r]=o)}}return y.STAGE=o,y.id=i,y.log=n,y.inf=e,y.err=u,y.extend=s,y.ts=p,y.environ=f,y.$console=c,y.toString=function(){return i||"$ROOT"},r._log=n,r._inf=e,r._err=u,r._$=y,(r[y.id]=y)("_",require("lodash/core")),initialize.apply(y,[r,t]),r};