UNPKG

jaid-core

Version:

Simple, opinionated framework that combines koa, got, sequelize, essential-config and jaid-logger.

6 lines 20.7 kB
/*! *** jaid-core 7.4.0 *** Copyright © 2020, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT !*/ var t,e;t=global,e=function(){return function(t){var e={};function s(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(n,i,function(e){return t[e]}.bind(null,i));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=73)}([function(t,e){t.exports=require("has-content")},function(t,e){t.exports=require("zahl")},function(t,e){t.exports=require("chalk")},function(t,e){t.exports=require("ensure-array")},function(t,e,s){var n=s(9)(Object,"create");t.exports=n},function(t,e,s){var n=s(35),i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")();t.exports=o},function(t,e,s){var n=s(49);t.exports=function(t,e){for(var s=t.length;s--;)if(n(t[s][0],e))return s;return-1}},function(t,e,s){var n=s(55);t.exports=function(t,e){var s=t.__data__;return n(e)?s["string"==typeof e?"string":"hash"]:s.map}},function(t,e,s){var n=s(14),i=s(16);t.exports=function(t){if(!i(t))return!1;var e=n(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},function(t,e,s){var n=s(34),i=s(41);t.exports=function(t,e){var s=i(t,e);return n(s)?s:void 0}},function(t,e,s){var n=s(14),i=s(71),o=s(72);t.exports=function(t){return"string"==typeof t||!i(t)&&o(t)&&"[object String]"==n(t)}},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("pify")},function(t,e){t.exports=require("sort-keys")},function(t,e,s){var n=s(15),i=s(36),o=s(37),r=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?i(t):o(t)}},function(t,e,s){var n=s(5).Symbol;t.exports=n},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e){t.exports=function(t){var e=-1,s=Array(t.size);return t.forEach((function(t){s[++e]=t})),s}},function(t,e,s){var n=s(28);t.exports=function(t){return t&&t.length?n(t):[]}},function(t,e){t.exports=require("camelcase")},function(t,e){t.exports=require("ensure-end")},function(t,e){t.exports=require("essential-config")},function(t,e){t.exports=require("http")},function(t,e){t.exports=require("https")},function(t,e){t.exports=require("is-class")},function(t,e){t.exports=require("jaid-logger")},function(t,e){t.exports=require("prevent-start")},function(t,e){t.exports=require("readable-ms")},function(t,e,s){var n=s(29),i=s(61),o=s(66),r=s(67),a=s(68),u=s(17);t.exports=function(t,e,s){var l=-1,c=i,h=t.length,f=!0,p=[],g=p;if(s)f=!1,c=o;else if(200>h)g=e?[]:p;else{var d=e?null:a(t);if(d)return u(d);f=!1,c=r,g=new n}t:for(;++l<h;){var b=t[l],v=e?e(b):b;if(b=s||0!==b?b:0,f&&v==v){for(var y=g.length;y--;)if(g[y]===v)continue t;e&&g.push(v),p.push(b)}else c(g,v,s)||(g!==p&&g.push(v),p.push(b))}return p}},function(t,e,s){var n=s(30),i=s(59),o=s(60);function r(t){var e=-1,s=null==t?0:t.length;for(this.__data__=new n;++e<s;)this.add(t[e])}r.prototype.add=r.prototype.push=i,r.prototype.has=o,t.exports=r},function(t,e,s){var n=s(31),i=s(54),o=s(56),r=s(57),a=s(58);function u(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=o,u.prototype.has=r,u.prototype.set=a,t.exports=u},function(t,e,s){var n=s(32),i=s(46),o=s(53);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(o||i),string:new n}}},function(t,e,s){var n=s(33),i=s(42),o=s(43),r=s(44),a=s(45);function u(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=o,u.prototype.has=r,u.prototype.set=a,t.exports=u},function(t,e,s){var n=s(4);t.exports=function(){this.__data__=n?n(null):{},this.size=0}},function(t,e,s){var n=s(8),i=s(38),o=s(16),r=s(40),a=Function.prototype,u=Object.prototype,l=a.toString,c=u.hasOwnProperty,h=RegExp("^"+l.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!o(t)||i(t))&&(n(t)?h:/^\[object .+?Constructor\]$/).test(r(t))}},function(t,e){var s="object"==typeof global&&global&&global.Object===Object&&global;t.exports=s},function(t,e,s){var n=s(15),i=Object.prototype,o=i.hasOwnProperty,r=i.toString,a=n?n.toStringTag:void 0;t.exports=function(t){var e=o.call(t,a),s=t[a];try{t[a]=void 0;var n=!0}catch(t){}var i=r.call(t);return n&&(e?t[a]=s:delete t[a]),i}},function(t,e){var s=Object.prototype.toString;t.exports=function(t){return s.call(t)}},function(t,e,s){var n,i=s(39),o=(n=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";t.exports=function(t){return!!o&&o in t}},function(t,e,s){var n=s(5)["__core-js_shared__"];t.exports=n},function(t,e){var s=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return s.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},function(t,e,s){var n=s(4),i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(n){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return i.call(e,t)?e[t]:void 0}},function(t,e,s){var n=s(4),i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return n?void 0!==e[t]:i.call(e,t)}},function(t,e,s){var n=s(4);t.exports=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=n&&void 0===e?"__lodash_hash_undefined__":e,this}},function(t,e,s){var n=s(47),i=s(48),o=s(50),r=s(51),a=s(52);function u(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=o,u.prototype.has=r,u.prototype.set=a,t.exports=u},function(t,e){t.exports=function(){this.__data__=[],this.size=0}},function(t,e,s){var n=s(6),i=Array.prototype.splice;t.exports=function(t){var e=this.__data__,s=n(e,t);return s>=0&&(s==e.length-1?e.pop():i.call(e,s,1),--this.size,!0)}},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e,s){var n=s(6);t.exports=function(t){var e=this.__data__,s=n(e,t);return 0>s?void 0:e[s][1]}},function(t,e,s){var n=s(6);t.exports=function(t){return n(this.__data__,t)>-1}},function(t,e,s){var n=s(6);t.exports=function(t,e){var s=this.__data__,i=n(s,t);return 0>i?(++this.size,s.push([t,e])):s[i][1]=e,this}},function(t,e,s){var n=s(9)(s(5),"Map");t.exports=n},function(t,e,s){var n=s(7);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},function(t,e){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},function(t,e,s){var n=s(7);t.exports=function(t){return n(this,t).get(t)}},function(t,e,s){var n=s(7);t.exports=function(t){return n(this,t).has(t)}},function(t,e,s){var n=s(7);t.exports=function(t,e){var s=n(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this}},function(t,e){t.exports=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}},function(t,e){t.exports=function(t){return this.__data__.has(t)}},function(t,e,s){var n=s(62);t.exports=function(t,e){return!(null==t||!t.length)&&n(t,e,0)>-1}},function(t,e,s){var n=s(63),i=s(64),o=s(65);t.exports=function(t,e,s){return e==e?o(t,e,s):n(t,i,s)}},function(t,e){t.exports=function(t,e,s,n){for(var i=t.length,o=s+(n?1:-1);n?o--:++o<i;)if(e(t[o],o,t))return o;return-1}},function(t,e){t.exports=function(t){return t!=t}},function(t,e){t.exports=function(t,e,s){for(var n=s-1,i=t.length;++n<i;)if(t[n]===e)return n;return-1}},function(t,e){t.exports=function(t,e,s){for(var n=-1,i=null==t?0:t.length;++n<i;)if(s(e,t[n]))return!0;return!1}},function(t,e){t.exports=function(t,e){return t.has(e)}},function(t,e,s){var n=s(69),i=s(70),o=s(17),r=n&&1/o(new n([,-0]))[1]==1/0?function(t){return new n(t)}:i;t.exports=r},function(t,e,s){var n=s(9)(s(5),"Set");t.exports=n},function(t,e){t.exports=function(){}},function(t,e){var s=Array.isArray;t.exports=s},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,s){s.r(e);var n=s(18),i=s.n(n),o=s(10),r=s.n(o),a=s(8),u=s.n(a),l=s(19),c=s.n(l),h=s(2),f=s.n(h),p=s(3),g=s.n(p),d=s(20),b=s.n(d),v=s(21),y=s.n(v),x=s(0),m=s.n(x),_=s(22),S=s.n(_),w=s(23),P=s.n(w),j=s(24),O=s.n(j),q=s(25),k=s.n(q),E=s(11),C=s.n(E),$=s(12),L=s.n($),z=s(26),D=s.n(z),M=s(13),N=s.n(M),A=s(1),K=s.n(A),F=s(27),R=s.n(F),T=t=>f.a.blueBright(R()(t));class I{constructor(){this.isManagedByJaidCore=!0,this.core=null,this.logger=null}log(...t){this.logger.info(...t)}logWarning(...t){this.logger.warn(...t)}logError(...t){this.logger.error(...t)}logDebug(...t){this.logger.debug(...t)}}s.d(e,"default",(function(){return J})),s.d(e,"JaidCorePlugin",(function(){return I}));class J{constructor(t){this.startTime=new Date,this.unusedPluginEvents=new Set,this.defaultLogLevel=process.env.JAID_CORE_LOG_LEVEL||"debug",this.options={http2:!1,serverLogLevel:this.defaultLogLevel,databaseLogLevel:this.defaultLogLevel,gotLogLevel:this.defaultLogLevel,configSetup:{},useGot:!1,sqlite:!1,databaseExtenions:!1,koaSession:!1,koaKeys:!1,...t},this.hasDatabase=!(!this.options.database&&!this.options.sqlite),this.hasInsecureServer=!!this.options.insecurePort,this.hasSecureServer=!!this.options.securePort,this.hasServer=this.hasInsecureServer||this.hasSecureServer,this.camelName=c()(this.options.name),this.appPath=[...g()(this.options.folder),this.options.name],this.logger=k()(this.appPath);const e=this.logger.log;this.logger.log=async(...t)=>{if(e.apply(this.logger,t),this.hasPlugins){const[e,...s]=t;await this.callPlugins("handleLog",e,s)}},this.appFolder=this.logger.appFolder,this.logFolder=this.logger.logFolder,this.databaseExtensions=i()(g()(this.options.databaseExtensions)),this.config={},this.hasPlugins=null,this.plugins={},this.database=null,this.koa=null,this.got=null,this.insecureServer=null,this.secureServer=null,this.configSetup=null}getConfigSetup(){const t={fields:{},defaults:{disabledPlugins:[]},secretKeys:[]};if(this.hasDatabase)if(Object.assign(t.defaults,{databaseSchemaSync:"sync"}),this.options.sqlite){const e=b()(r()(this.options.database)?this.options.database:"database",".sqlite");let s;s=C.a.isAbsolute(e)?e:C.a.join(this.appFolder,e),Object.assign(t.defaults,{databasePath:s})}else Object.assign(t.defaults,{databaseName:r()(this.options.database)?this.options.database:this.camelName,databaseUser:"postgres",databaseDialect:"postgres",databaseHost:"localhost",databasePort:5432,timezone:"Europe/Berlin"}),t.secretKeys.push("databasePassword");return this.hasInsecureServer&&Object.assign(t.defaults,{insecurePort:this.options.insecurePort}),this.hasSecureServer&&Object.assign(t.defaults,{securePort:this.options.securePort}),this.hasServer&&this.options.koaSession&&t.secretKeys.push("koaKeys"),t}applyConfigSetup(t){m()(null==t?void 0:t.fields)&&Object.assign(this.configSetup.fields,t.fields),m()(null==t?void 0:t.defaults)&&Object.assign(this.configSetup.defaults,t.defaults),m()(null==t?void 0:t.secretKeys)&&Array.prototype.push.apply(this.configSetup.secretKeys,t.secretKeys)}registerModel(t,e){const s=N()(e.schema);e.default.init(s,{modelName:t,sequelize:this.database,indexes:e.indexes})}registerModelDynamic(t,e,s,n){const i=e(s.Model,{core:this,sequelize:this.database,models:this.database.models,parentPlugin:n}),o=N()(i.schema);i.default.init(o,{modelName:t,sequelize:this.database,indexes:i.indexes})}async close(){await this.callPlugins("close");const t=[];if(this.hasInsecureServer){const e=L()(this.insecureServer.close.bind(this.insecureServer));t.push(e())}if(this.hasSecureServer){const e=L()(this.secureServer.close.bind(this.secureServer));t.push(e())}this.hasDatabase&&t.push(this.database.close()),await Promise.all(t)}async callPlugins(t,...e){if(this.unusedPluginEvents.has(t))return{};const s=Object.entries(this.plugins),n=e=>void 0!==e[1][t],i=[];for(let t=0;t<=s.length-1;t++)n(s[t])&&i.push(s[t]);if(0===i.length)return this.unusedPluginEvents.add(t),{};const o=Date.now(),r={},a=async([s,n])=>{const i=n[t],o="function"==typeof i?i.apply(n,e):i;r[s]=await o},u=Array(i.length);for(let t=0;t<=i.length-1;t++)u[t]=a(i[t]);await Promise.all(u);const l=i.map(([t,e])=>this.formatPluginName(t,e)).join(", ");return this.logger.info("Called %s in %s on: %s",t,T(Date.now()-o),l),r}async callAndRemovePlugins(t,...e){const s=await this.callPlugins(t,...e),n=Object.entries(s),i=t=>!(!1!==t[1]),o=[];for(let t=0;t<=n.length-1;t++)i(n[t])&&o.push(n[t]);if(0!==o.length){for(const[t]of o)delete this.plugins[t];const t=o.map(([t,e])=>this.formatPluginName(t,e)).join(", ");this.logger.info("%s wanted to be removed: %s",K()(o,"plugin"),t)}}doForManagedPluginsSync(t){for(const[e,s]of Object.entries(this.plugins))!0===s.isManagedByJaidCore&&t(s,e)}async doForManagedPlugins(t){for(const[e,s]of Object.entries(this.plugins))!0===s.isManagedByJaidCore&&await t(s,e)}async gatherConfigSetups(){const t=await this.callPlugins("getConfigSetup");if(t)for(const e of Object.values(t))this.applyConfigSetup(e)}formatPluginName(t){return f.a.magenta(t)}formatPluginNameDetailed(t,e){let s=this.formatPluginName(t);return s+=" ",s+=!0===e.isManagedByJaidCore?f.a.gray("(auto-managed)"):f.a.gray("(self-managed)"),s}async init(t={}){try{var e,s;this.configSetup=this.getConfigSetup(),this.applyConfigSetup(this.options.configSetup);const i=Object.entries(t);this.hasPlugins=i.length>0;for(const[t,e]of i){let s;s=O()(e)?new e(this):e,this.plugins[t]=s}m()(this.plugins)&&this.logger.info(`${K()(this.plugins,"plugin")}: ${Object.entries(this.plugins).map(([t,e])=>this.formatPluginNameDetailed(t,e)).join(", ")}`),await this.callPlugins("setCoreReference",this),this.doForManagedPluginsSync(t=>{t.core=this,t.logger=this.logger}),await this.gatherConfigSetups(),await this.callAndRemovePlugins("preInit");const o=y()(this.appPath,this.configSetup);if(e=o.newKeys,m()(e)&&this.logger.info("Added %s to config: %s",K()(o.newKeys,"new entry"),o.newKeys.join(", ")),s=o.deprecatedKeys,m()(s)&&this.logger.warn("Config contains %s: %s",K()(o.deprecatedKeys,"no longer needed entry"),o.deprecatedKeys.join(", ")),Object.assign(this.config,o.config),m()(this.config.disabledPlugins)){const t=[];for(const e of g()(this.config.disabledPlugins))this.plugins[e]?(delete this.plugins[e],t.push(e)):this.logger.warn(`${e} is listed in config.disabledPlugins, but was not intended to be loaded at all`);m()(t)&&this.logger.info(`${K()(t,"plugin")} will be skipped because of config.disabledPlugins: ${t.join(", ")}`)}let r;if(await this.callAndRemovePlugins("handleConfig",this.config),this.hasDatabase){r=require("sequelize");const t={};this.options.sqlite?Object.assign(t,{dialect:"sqlite",storage:this.config.databasePath}):Object.assign(t,{dialect:this.config.databaseDialect,host:this.config.databaseHost,port:this.config.databasePort,database:this.config.databaseName,username:this.config.databaseUser,password:this.config.databasePassword,timezone:this.config.timezone}),this.database=new r({benchmark:!0,logging:t=>{this.logger.log(this.options.databaseLogLevel,t)},...t,...this.options.sequelizeOptions})}if(this.hasServer){const t=require("koa");if(this.koa=new t,this.koa.use(async(t,e)=>{await e();const s=t.response.get("X-Response-Time");this.logger.log(this.options.serverLogLevel,"[%s %s in %s] ◀︎ %s %s",t.status,t.message,T(s),t.method,t.url)}),this.koa.use(async(t,e)=>{const s=Date.now();await e(),t.set("X-Response-Time",Date.now()-s)}),this.koaSession){if(Object(x.isEmpty)(this.config.koaKeys))throw new Error("config.koaKeys is not set");this.koa.keys=g()(this.config.koaKeys);const t={...this.options.koaSession||{},signed:!0},e=require("koa-session");this.koa.use(e(t,this.koa))}await this.callPlugins("handleKoa",this.koa)}if(this.options.useGot){const t=require("got"),e=require("got/dist/source/utils/url-to-options").default;this.got=t.extend({request:(t,s,n)=>"https:"===t.protocol?P.a.request({...s,...e(t)},n):S.a.request({...s,...e(t)},n),headers:{"User-Agent":`${this.camelName}/${this.options.version}`},hooks:{afterResponse:[t=>{let e=D()(t.requestUrl,"https://");return e.length>160&&(e=`${e.slice(0,159)}…`),this.logger.log(this.options.gotLogLevel,`[${t.statusCode} ${t.statusMessage} in ${T(t.timings.phases.total)}] ▶︎ ${t.request.options.method} ${f.a.yellow(t.requestUrl)}`),t}]}}),await this.callPlugins("handleGot",this.got)}if(this.hasInsecureServer){const{createServer:t}=require(this.options.http2?"http2":"http");this.insecureServer=t(this.koa.callback())}if(this.hasSecureServer){const{createSecureServer:t}=require(this.options.http2?"http2":"https");this.secureServer=t(this.koa.callback())}if(this.hasDatabase){if("postgres"===this.database.options.dialect){var n;try{const{create:t}=require("pg-create-drop-db");await t({user:this.database.options.username,pass:this.database.options.password,host:this.database.options.host,port:this.database.options.port,name:this.database.options.database}),this.logger.info("Ensured existence of database %s at %s:%s",this.database.options.database,this.database.options.host,this.database.options.port)}catch(t){this.logger.error("Could not create database %s: %s",this.database.options.database,t)}if(n=this.databaseExtensions,m()(n)){const t=this.databaseExtensions.map(t=>`CREATE EXTENSION IF NOT EXISTS ${t};`).join(" ");await this.database.query(t),this.logger.info("Ensured existence of %s",K()(this.databaseExtensions,"database extension"))}}await this.database.authenticate();const e=await this.callPlugins("collectModels"),s=[],i=[];if(e)for(const[n,o]of Object.entries(e)){const e=t[n];for(const[t,n]of Object.entries(o))if(n.schema)this.registerModel(t,n),s.push(t);else if(u()(n))this.registerModelDynamic(t,n,r,e),i.push(t);else{if(!u()(n.default))throw new Error(`Not sure what to do with given Sequelize model definition ${t}`);this.registerModelDynamic(t,n.default,r,e),i.push(t)}}const o=Object.values(this.database.models);if(0===o.length)this.logger.warn("No models have been registered, that's weird");else{s.length&&this.logger.info(`${K()(s,"static model definition")} loaded: ${s.join(", ")}`),i.length&&this.logger.info(`${K()(i,"dynamic model definition")} generated: ${i.join(", ")}`);const t=t=>t.associate,e=[];for(let s=0;s<=o.length-1;s++)t(o[s],s,o)&&e.push(o[s]);if(e.length>0){for(const t of e)t.associate(this.database.models);this.logger.debug("Called associate on %s",K()(e,"model"))}"sync"===this.config.databaseSchemaSync&&await this.database.sync(),"force"===this.config.databaseSchemaSync&&await this.database.sync({force:!0}),"alter"===this.config.databaseSchemaSync&&await this.database.sync({alter:!0})}}if(await this.callAndRemovePlugins("init"),this.hasInsecureServer&&(this.insecureServer.listen(this.config.insecurePort),this.logger.info("Started insecure server on port %s",this.config.insecurePort)),this.hasSecureServer&&(this.secureServer.listen(this.config.securePort),this.logger.info("Started secure server on port %s",this.config.securePort)),this.database){const t=Object.values(this.database.models),e=t=>t.start,s=[];for(let n=0;n<=t.length-1;n++)e(t[n],n,t)&&s.push(t[n]);if(s.length>0){const t=Date.now(),e=async t=>{await t.start()},n=Array(s.length);for(let t=0;t<=s.length-1;t++)n[t]=e(s[t],t,s);await Promise.all(n),this.logger.debug("Called start on %s in %s",K()(s,"model"),T(Date.now()-t))}}await this.callAndRemovePlugins("postInit"),await this.callPlugins("ready"),this.logger.info("Ready after %s",T(Date.now()-this.startTime.getTime()))}catch(t){throw this.logger.error("Could not initialize: %s",t),t}}}}])},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["jaid-core"]=e():t.JaidCore=e();