medisot-base-server
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -12,2 +12,9 @@ 1.0.1 / 2020-03-23 | ||
- Run the desired express application in all the available cores of the CPU to utilize maximum CPU Resources | ||
- Adds a logging library with some default configurations that logs every request | ||
- Adds a logging library with some default configurations that logs every request | ||
1.1.0 / 2020-05-05 | ||
=================== | ||
* Base Server is now configuration driver: | ||
- Configuration support for `Clustering` and `Logging` | ||
- Types for the configuration added |
import { Cluster } from "cluster"; | ||
import { Container } from "inversify"; | ||
export interface IBaseServerTypes { | ||
BaseServerConfig: symbol; | ||
} | ||
export interface IBaseServerConfig { | ||
clusterMode: Boolean; | ||
enableLogger: Boolean; | ||
} | ||
declare class BaseServer { | ||
@@ -9,2 +18,4 @@ constructor(appFactory: (app: Express.Application, cluster: Cluster) => Express.Application, container: Container, serverConfig: (app: Express.Application) => void); | ||
export const TYPES: IBaseServerTypes; | ||
export default BaseServer |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.BaseServer=r():e.BaseServer=r()}(global,(function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(t(1))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(2),o=t(3),i=t(4),u=t(5),f=function(){function e(e,r,t){this.appFactory=e,this.container=r,this.serverConfig=t}return e.prototype.onFork=function(){u.on("fork",(function(e){console.log("forked -> Worker %d",e.id)}))},e.prototype.assignId=function(e,r,t){e.id=i.v4(),t()},e.prototype.run=function(){if(u.isMaster)for(var e=t(6).cpus().length,r=0;r<e;r+=1)u.fork();else{var i=new n.InversifyExpressServer(this.container);i.setConfig(this.serverConfig);var f=i.build();o.token("id",(function(e){return e.id})),f.use(this.assignId),f.use(o("Worker-"+u.worker.id+" :id :method :url :response-time")),this.appFactory(f,u)}this.onFork()},e}();r.default=f},function(e,r){e.exports=require("inversify-express-utils")},function(e,r){e.exports=require("morgan")},function(e,r){e.exports=require("node-uuid")},function(e,r){e.exports=require("cluster")},function(e,r){e.exports=require("os")}])})); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.BaseServer=r():e.BaseServer=r()}(global,(function(){return function(e){var r={};function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(o,n,function(r){return e[r]}.bind(null,n));return o},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.TYPES={BaseServerConfig:Symbol.for("BaseServerConfig")}},function(e,r,t){"use strict";function o(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),o(t(2)),o(t(0))},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t(3),n=t(4),i=t(5),s=t(0),u=t(6),f=function(){function e(e,r,t){this.appFactory=e,this.container=r,this.serverConfig=t,this.baseServerConfig=r.get(s.TYPES.BaseServerConfig)}return e.prototype.onFork=function(){u.on("fork",(function(e){console.log("forked -> Worker %d",e.id)}))},e.prototype.assignId=function(e,r,t){e.id=i.v4(),t()},e.prototype.spawnProcess=function(){var e=new o.InversifyExpressServer(this.container);e.setConfig(this.serverConfig);var r=e.build();this.baseServerConfig.enableLogger&&(n.token("id",(function(e){return e.id})),r.use(this.assignId),r.use(n((this.baseServerConfig.clusterMode?"Worker-"+u.worker.id:"")+" :id :method :url :response-time"))),this.appFactory(r,u)},e.prototype.run=function(){if(this.baseServerConfig.clusterMode){if(u.isMaster)for(var e=t(7).cpus().length,r=0;r<e;r+=1)u.fork();else this.spawnProcess();this.onFork()}else this.spawnProcess()},e}();r.default=f},function(e,r){e.exports=require("inversify-express-utils")},function(e,r){e.exports=require("morgan")},function(e,r){e.exports=require("node-uuid")},function(e,r){e.exports=require("cluster")},function(e,r){e.exports=require("os")}])})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "medisot-base-server", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Helps create an inversify express application that utilises all the cores of the CPU", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18926
73