nginxwebnodeplugin 1.0.255 → 1.0.258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CheckReachabilityOptions, RecursivePartial } from 'clientnode/type';
2
- import { PluginHandler } from 'web-node/type';
3
- import { Configuration, Service, ServicePromises, Services } from './type';
2
+ import { PluginHandler, PluginPromises } from 'web-node/type';
3
+ import { Configuration, ServicePromisesState } from './type';
4
4
  /**
5
5
  * Launches an application server und triggers all some pluginable hooks on
6
6
  * an event.
@@ -9,23 +9,24 @@ export declare class Nginx implements PluginHandler {
9
9
  /**
10
10
  * Start nginx's child process and return a Promise which observes this
11
11
  * service.
12
- * @param servicePromises - An object with stored service promise
13
- * instances.
14
- * @param services - An object with stored service instances.
15
- * @param configuration - Mutable by plugins extended configuration object.
12
+ * @param state - Application state.
13
+ * @param state.configuration - Applications configuration.
14
+ * @param state.configuration.applicationServer - Plugins configuration.
15
+ * @param state.services - An object with stored service instances.
16
16
  *
17
17
  * @returns A promise which correspond to the plugin specific continues
18
18
  * service.
19
19
  */
20
- static loadService(servicePromises: Omit<ServicePromises, 'nginx'>, services: Services, configuration: Configuration): Promise<null | Service>;
20
+ static loadService({ configuration: { applicationServer: configuration }, services }: ServicePromisesState): Promise<null | PluginPromises>;
21
21
  /**
22
22
  * Application will be closed soon.
23
- * @param services - An object with stored service instances.
24
- * @param configuration - Mutable by plugins extended configuration object.
23
+ * @param state - Application state.
24
+ * @param state.configuration - Applications configuration.
25
+ * @param state.services - Application services.
25
26
  *
26
27
  * @returns Given object of services.
27
28
  */
28
- static shouldExit(services: Services, configuration: Configuration): Promise<Services>;
29
+ static shouldExit({ configuration, services }: ServicePromisesState): Promise<void>;
29
30
  /**
30
31
  * Check if a nginx server is currently (not) running.
31
32
  * @param serverConfiguration - Mutable by plugins extended configuration
package/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';if(typeof module!=='undefined'&&module!==null&&eval('typeof require')!=='undefined'&&eval('require')!==null&&'main'in eval('require')&&eval('typeof require.main')!=='undefined'&&eval('require.main')!==null){var ORIGINAL_MAIN_MODULE=module;if(module!==eval('require.main')&&'paths'in module&&'paths'in eval('require.main')&&typeof __dirname!=='undefined'&&__dirname!==null)module.paths=eval('require.main.paths').concat(module.paths.filter(function(path){return eval('require.main.paths').includes(path)}))};if(typeof window==='undefined'||window===null)var window=(typeof global==='undefined'||global===null)?{}:global;!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@babel/runtime/helpers/extends"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("child_process"),require("clientnode"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/extends","@babel/runtime/helpers/asyncToGenerator","@babel/runtime/regenerator","child_process","clientnode"],r);else{var n="object"==typeof exports?r(require("@babel/runtime/helpers/extends"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("child_process"),require("clientnode")):r(e["@babel/runtime/helpers/extends"],e["@babel/runtime/helpers/asyncToGenerator"],e["@babel/runtime/regenerator"],e.child_process,e.clientnode);for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}(this,((e,r,n,t,o)=>(()=>{"use strict";var a=[,r=>{r.exports=e},e=>{e.exports=r},e=>{e.exports=n},e=>{e.exports=t},e=>{e.exports=o}],i={};function c(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return a[e](n,n.exports,c),n.exports}c.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return c.d(r,{a:r}),r},c.d=(e,r)=>{for(var n in r)c.o(r,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},c.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{c.r(l),c.d(l,{Nginx:()=>d,default:()=>f});var e=c(1),r=c.n(e),n=c(2),t=c.n(n),o=c(3),a=c.n(o),i=c(4),u=c(5),s=c.n(u);function p(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return b(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=Array(r);n<r;n++)t[n]=e[n];return t}var d=function(){function e(){}return e.loadService=function(){var r=t()(a().mark((function r(n,t,o){var c;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!Object.prototype.hasOwnProperty.call(t,"nginx")){r.next=2;break}return r.abrupt("return",null);case 2:return t.nginx=(0,i.spawn)("nginx",[],{cwd:process.cwd(),env:process.env,shell:!0,stdio:"inherit"}),t.nginx.reload=function(){return new Promise((function(e,r){return(0,i.exec)("nginx -s reload",(function(n,t,o){n?(n.standardErrorOutput=o,r(n)):e(t)}))}))},c=new Promise((function(e,r){for(var n,a,i=p(u.CloseEventNames);!(n=i()).done;)a=n.value,t.nginx.on(a,s().getProcessCloseHandler(e,o.applicationServer.proxy.optional?e:r,{reason:t.nginx,process:t.nginx}))})),r.prev=5,r.next=8,e.checkReachability(o.applicationServer);case 8:r.next=19;break;case 10:if(r.prev=10,r.t0=r.catch(5),!o.applicationServer.proxy.optional){r.next=18;break}t.nginx=null,c=null,r.next=19;break;case 18:throw r.t0;case 19:return r.abrupt("return",{name:"nginx",promise:c});case 20:case"end":return r.stop()}}),r,null,[[5,10]])})));return function(){return r.apply(this,arguments)}}(),e.shouldExit=function(){var r=t()(a().mark((function r(n,t){return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null===n.nginx){r.next=4;break}return n.nginx.kill("SIGINT"),r.next=4,e.checkReachability(t.applicationServer,!0);case 4:return delete n.nginx,r.abrupt("return",n);case 6:case"end":return r.stop()}}),r)})));return function(){return r.apply(this,arguments)}}(),e.checkReachability=function(e,n,t){if(void 0===n&&(n=!1),void 0===t&&(t={}),0<Object.values(e.proxy.ports.backend).length){var o="http"+(443===Object.values(e.proxy.ports.backend)[0]?"s":"")+"://"+e.hostName+":"+Object.values(e.proxy.ports.backend)[0],a=r()({options:{redirect:"manual"},pollIntervallInSeconds:.1,statusCodes:[100,101,102,200,201,202,203,204,205,206,207,208,226,300,301,302,303,304,305,306,307,308],timeoutInSeconds:3,wait:!0},t);return(n?s().checkUnreachability:s().checkReachability)(o,a)}return Promise.resolve(null)},e}();const f=d})(),l})()));
1
+ 'use strict';if(typeof module!=='undefined'&&module!==null&&eval('typeof require')!=='undefined'&&eval('require')!==null&&'main'in eval('require')&&eval('typeof require.main')!=='undefined'&&eval('require.main')!==null){var ORIGINAL_MAIN_MODULE=module;if(module!==eval('require.main')&&'paths'in module&&'paths'in eval('require.main')&&typeof __dirname!=='undefined'&&__dirname!==null)module.paths=eval('require.main.paths').concat(module.paths.filter(function(path){return eval('require.main.paths').includes(path)}))};if(typeof window==='undefined'||window===null)var window=(typeof global==='undefined'||global===null)?{}:global;!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@babel/runtime/helpers/extends"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("child_process"),require("clientnode"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/extends","@babel/runtime/helpers/asyncToGenerator","@babel/runtime/regenerator","child_process","clientnode"],r);else{var t="object"==typeof exports?r(require("@babel/runtime/helpers/extends"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("child_process"),require("clientnode")):r(e["@babel/runtime/helpers/extends"],e["@babel/runtime/helpers/asyncToGenerator"],e["@babel/runtime/regenerator"],e.child_process,e.clientnode);for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,((e,r,t,n,o)=>(()=>{"use strict";var a=[,r=>{r.exports=e},e=>{e.exports=r},e=>{e.exports=t},e=>{e.exports=n},e=>{e.exports=o}],i={};function c(e){var r=i[e];if(void 0!==r)return r.exports;var t=i[e]={exports:{}};return a[e](t,t.exports,c),t.exports}c.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return c.d(r,{a:r}),r},c.d=(e,r)=>{for(var t in r)c.o(r,t)&&!c.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},c.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{c.r(s),c.d(s,{Nginx:()=>d,default:()=>f});var e=c(1),r=c.n(e),t=c(2),n=c.n(t),o=c(3),a=c.n(o),i=c(4),u=c(5),l=c.n(u);function p(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return b(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?b(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}var d=function(){function e(){}return e.loadService=function(){var r=n()(a().mark((function r(t){var n,o,c,s;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.configuration.applicationServer,o=t.services,!Object.prototype.hasOwnProperty.call(o,"nginx")){r.next=3;break}return r.abrupt("return",null);case 3:return c=(0,i.spawn)("nginx",[],{cwd:process.cwd(),env:process.env,shell:!0,stdio:"inherit"}),o.nginx=c,c.reload=function(){return new Promise((function(e,r){return(0,i.exec)("nginx -s reload",(function(t,n,o){t?(t.standardErrorOutput=o,r(t)):e(n)}))}))},s=new Promise((function(e,r){for(var t,o,a=p(u.CloseEventNames);!(t=a()).done;)o=t.value,c.on(o,l().getProcessCloseHandler(e,n.proxy.optional?e:r,{reason:c,process:c}))})),r.prev=7,r.next=10,e.checkReachability(n);case 10:r.next=21;break;case 12:if(r.prev=12,r.t0=r.catch(7),!n.proxy.optional){r.next=20;break}o.nginx=null,s=null,r.next=21;break;case 20:throw r.t0;case 21:return r.abrupt("return",{nginx:s});case 22:case"end":return r.stop()}}),r,null,[[7,12]])})));return function(){return r.apply(this,arguments)}}(),e.shouldExit=function(){var r=n()(a().mark((function r(t){var n,o;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.configuration,null===(o=t.services).nginx){r.next=5;break}return o.nginx.kill("SIGINT"),r.next=5,e.checkReachability(n.applicationServer,!0);case 5:delete o.nginx;case 6:case"end":return r.stop()}}),r)})));return function(){return r.apply(this,arguments)}}(),e.checkReachability=function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n={}),0<Object.values(e.proxy.ports.backend).length){var o="http"+(443===Object.values(e.proxy.ports.backend)[0]?"s":"")+"://"+e.hostName+":"+Object.values(e.proxy.ports.backend)[0],a=r()({options:{redirect:"manual"},pollIntervallInSeconds:.1,statusCodes:[100,101,102,200,201,202,203,204,205,206,207,208,226,300,301,302,303,304,305,306,307,308],timeoutInSeconds:3,wait:!0},n);return(t?l().checkUnreachability:l().checkReachability)(o,a)}return Promise.resolve(null)},e}();const f=d})(),s})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nginxwebnodeplugin",
3
- "version": "1.0.255",
3
+ "version": "1.0.258",
4
4
  "description": "A nginx proxy server configuration template for webNode.",
5
5
  "keywords": [
6
6
  "web",
package/type.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { ChildProcess } from 'child_process';
3
3
  import { Mapping, ProcessCloseReason } from 'clientnode/type';
4
4
  import { Configuration as BaseConfiguration, Services as BaseServices, ServicePromises as BaseServicePromises } from 'application-server-web-node-plugin/type';
5
- import { Service as BaseService } from 'web-node/type';
5
+ import { ServicePromisesState as BaseServicePromisesState, ServicesState as BaseServicesState } from 'web-node/type';
6
6
  export declare type Configuration<PluginConfigurationType = Mapping<unknown>> = BaseConfiguration<{
7
7
  applicationServer: {
8
8
  proxy: {
@@ -17,16 +17,14 @@ export declare type Configuration<PluginConfigurationType = Mapping<unknown>> =
17
17
  };
18
18
  };
19
19
  }> & PluginConfigurationType;
20
- export interface Service extends BaseService {
21
- name: 'nginx';
22
- promise: null | Promise<ProcessCloseReason>;
23
- }
24
20
  export interface ServiceProcess extends ChildProcess {
25
21
  reload(): Promise<string>;
26
22
  }
27
- export declare type ServicePromises<ServicePromiseType = Mapping<unknown>> = BaseServicePromises<{
23
+ export declare type ServicePromises<Type = Mapping<unknown>> = BaseServicePromises<{
28
24
  nginx: Promise<ProcessCloseReason>;
29
- }> & ServicePromiseType;
30
- export declare type Services<ServiceType = Mapping<unknown>> = BaseServices<{
25
+ }> & Type;
26
+ export declare type Services<Type = Mapping<unknown>> = BaseServices<{
31
27
  nginx: null | ServiceProcess;
32
- }> & ServiceType;
28
+ }> & Type;
29
+ export declare type ServicesState = BaseServicesState<undefined, Configuration, Services>;
30
+ export declare type ServicePromisesState = BaseServicePromisesState<undefined, Configuration, Services, ServicePromises>;