nginxwebnodeplugin 1.0.251 → 1.0.254

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 ADDED
@@ -0,0 +1,43 @@
1
+ import { CheckReachabilityOptions, RecursivePartial } from 'clientnode/type';
2
+ import { PluginHandler } from 'web-node/type';
3
+ import { Configuration, Service, ServicePromises, Services } from './type';
4
+ /**
5
+ * Launches an application server und triggers all some pluginable hooks on
6
+ * an event.
7
+ */
8
+ export declare class Nginx implements PluginHandler {
9
+ /**
10
+ * Start nginx's child process and return a Promise which observes this
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.
16
+ *
17
+ * @returns A promise which correspond to the plugin specific continues
18
+ * service.
19
+ */
20
+ static loadService(servicePromises: Omit<ServicePromises, 'nginx'>, services: Services, configuration: Configuration): Promise<null | Service>;
21
+ /**
22
+ * Application will be closed soon.
23
+ * @param services - An object with stored service instances.
24
+ * @param configuration - Mutable by plugins extended configuration object.
25
+ *
26
+ * @returns Given object of services.
27
+ */
28
+ static shouldExit(services: Services, configuration: Configuration): Promise<Services>;
29
+ /**
30
+ * Check if a nginx server is currently (not) running.
31
+ * @param serverConfiguration - Mutable by plugins extended configuration
32
+ * object.
33
+ * @param inverse - Boolean indicating if we should check for reachability
34
+ * or un-reachability.
35
+ * @param givenOptions - Tools reachability options to configure how to
36
+ * check for reachability.
37
+ *
38
+ * @returns A promise which will be resolved if a request to given url has
39
+ * (not) finished. Otherwise returned promise will be rejected.
40
+ */
41
+ static checkReachability(serverConfiguration: Configuration['applicationServer'], inverse?: boolean, givenOptions?: RecursivePartial<CheckReachabilityOptions>): Promise<Response | Error | null | Promise<Error | null>>;
42
+ }
43
+ export default Nginx;
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,(function(e,r,n,t,o){return(()=>{"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 u(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return a[e](n,n.exports,u),n.exports}u.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return u.d(r,{a:r}),r},u.d=(e,r)=>{for(var n in r)u.o(r,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},u.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{u.r(c),u.d(c,{Nginx:()=>d,default:()=>f});var e=u(1),r=u.n(e),n=u(2),t=u.n(n),o=u(3),a=u.n(o),i=u(4),l=u(5),s=u.n(l);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 u;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)}))}))},u=new Promise((function(e,r){for(var n,a,i=p(l.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,u=null,r.next=19;break;case 18:throw r.t0;case 19:return r.abrupt("return",{name:"nginx",promise:u});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})(),c})()}));
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})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nginxwebnodeplugin",
3
- "version": "1.0.251",
3
+ "version": "1.0.254",
4
4
  "description": "A nginx proxy server configuration template for webNode.",
5
5
  "keywords": [
6
6
  "web",
@@ -31,7 +31,7 @@
31
31
  "url": "https://github.com/thaibault/nginx-web-node-plugin.git"
32
32
  },
33
33
  "scripts": {
34
- "build": "weboptimizer build",
34
+ "build": "weboptimizer build:types && weboptimizer build",
35
35
  "check": "yarn check:types; yarn lint",
36
36
  "check:types": "weboptimizer check:types",
37
37
  "clear": "weboptimizer clear",
@@ -44,7 +44,7 @@
44
44
  "test:coverage": "yarn clear && weboptimizer test:coverage",
45
45
  "test:coverage:report": "yarn clear && weboptimizer test:coverage:report",
46
46
  "update": "yarn version --patch && yarn publish",
47
- "update:documentation": "documentationWebsite --log-level info",
47
+ "update:documentation": "documentation-website",
48
48
  "watch": "weboptimizer build --watch"
49
49
  },
50
50
  "dependencies": {
package/type.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import { ChildProcess } from 'child_process';
3
+ import { Mapping, ProcessCloseReason } from 'clientnode/type';
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';
6
+ export declare type Configuration<PluginConfigurationType = Mapping<unknown>> = BaseConfiguration<{
7
+ applicationServer: {
8
+ proxy: {
9
+ optional: boolean;
10
+ logFilePath: {
11
+ access: string;
12
+ error: string;
13
+ };
14
+ ports: {
15
+ backend: Mapping<number>;
16
+ };
17
+ };
18
+ };
19
+ }> & PluginConfigurationType;
20
+ export interface Service extends BaseService {
21
+ name: 'nginx';
22
+ promise: null | Promise<ProcessCloseReason>;
23
+ }
24
+ export interface ServiceProcess extends ChildProcess {
25
+ reload(): Promise<string>;
26
+ }
27
+ export declare type ServicePromises<ServicePromiseType = Mapping<unknown>> = BaseServicePromises<{
28
+ nginx: Promise<ProcessCloseReason>;
29
+ }> & ServicePromiseType;
30
+ export declare type Services<ServiceType = Mapping<unknown>> = BaseServices<{
31
+ nginx: null | ServiceProcess;
32
+ }> & ServiceType;