@apipass/common 0.0.16-alpha.0

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.
@@ -0,0 +1,21 @@
1
+ export declare class TunnelOptions {
2
+ agent?: string;
3
+ username: string;
4
+ privateKey: any;
5
+ host: string;
6
+ port: number;
7
+ dstHost: string;
8
+ dstPort: number;
9
+ localHost: string;
10
+ localPort: number;
11
+ }
12
+ export declare class Environment {
13
+ private static readonly CURRENT_ENVIRONMENT;
14
+ private static readonly PRODUCTION;
15
+ private static readonly DEVELOP;
16
+ static getEnvironment(): string;
17
+ static isLocal(): boolean;
18
+ static isDevelop(): boolean;
19
+ static isProduction(environment: string): boolean;
20
+ static configureTunnel(sshTunnelConfig: TunnelOptions): Promise<void>;
21
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Environment = exports.TunnelOptions = void 0;
13
+ const tunnel = require('tunnel-ssh');
14
+ class TunnelOptions {
15
+ }
16
+ exports.TunnelOptions = TunnelOptions;
17
+ class Environment {
18
+ static getEnvironment() {
19
+ return this.CURRENT_ENVIRONMENT;
20
+ }
21
+ static isLocal() {
22
+ return this.CURRENT_ENVIRONMENT !== this.PRODUCTION && this.CURRENT_ENVIRONMENT !== this.DEVELOP;
23
+ }
24
+ static isDevelop() {
25
+ return this.CURRENT_ENVIRONMENT === this.DEVELOP;
26
+ }
27
+ static isProduction(environment) {
28
+ return this.CURRENT_ENVIRONMENT === this.PRODUCTION;
29
+ }
30
+ static configureTunnel(sshTunnelConfig) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ yield new Promise(function (resolve, reject) {
33
+ tunnel(sshTunnelConfig, (error, server) => {
34
+ if (error) {
35
+ console.log('Error on tunnel configuration: ', error);
36
+ reject(error);
37
+ }
38
+ resolve(server);
39
+ });
40
+ });
41
+ });
42
+ }
43
+ }
44
+ exports.Environment = Environment;
45
+ Environment.CURRENT_ENVIRONMENT = process.env.APIPASS_ENVIRONMENT;
46
+ Environment.PRODUCTION = 'prd' || 'prod';
47
+ Environment.DEVELOP = 'develop';
48
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/environment/environment.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAErC,MAAa,aAAa;CAUzB;AAVD,sCAUC;AAED,MAAa,WAAW;IAKb,MAAM,CAAC,cAAc;QACxB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,OAAO;QACjB,OAAO,IAAI,CAAC,mBAAmB,KAAK,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,mBAAmB,KAAK,IAAI,CAAC,OAAO,CAAC;IACrG,CAAC;IAEM,MAAM,CAAC,SAAS;QACnB,OAAO,IAAI,CAAC,mBAAmB,KAAK,IAAI,CAAC,OAAO,CAAA;IACpD,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,WAAmB;QAC1C,OAAO,IAAI,CAAC,mBAAmB,KAAK,IAAI,CAAC,UAAU,CAAA;IACvD,CAAC;IAEM,MAAM,CAAO,eAAe,CAAC,eAA8B;;YAC9D,MAAM,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBACvC,MAAM,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;oBACtC,IAAI,KAAK,EAAE;wBACP,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;wBACtD,MAAM,CAAC,KAAK,CAAC,CAAC;qBACjB;oBACD,OAAO,CAAC,MAAM,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;;AA/BL,kCAiCC;AAhC2B,+BAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AACtD,sBAAU,GAAG,KAAK,IAAI,MAAM,CAAC;AAC7B,mBAAO,GAAG,SAAS,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './environment/environment';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./environment/environment"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@apipass/common",
3
+ "version": "0.0.16-alpha.0",
4
+ "description": "> TODO: description",
5
+ "author": "Nathan Lemos <nathan@apipass.com.br>",
6
+ "license": "ISC",
7
+ "main": "lib/index.js",
8
+ "typings": "lib/index.d.ts",
9
+ "directories": {
10
+ "lib": "lib"
11
+ },
12
+ "devDependencies": {
13
+ "tunnel-ssh": "4.1.6"
14
+ },
15
+ "files": [
16
+ "lib"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "tsc": "tsc"
23
+ },
24
+ "gitHead": "081479c84280b4f851b310590118ffd07f78e3aa"
25
+ }