Skip to content

Commit bdb31de

Browse files
committed
feature(): Open the webhook store
1 parent 84d4ac5 commit bdb31de

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

bin/lcp.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ var optionDefinitions = [
1010
type: String,
1111
defaultValue: '/proxy'
1212
},
13-
{ name: 'proxyUrl', type: String },
13+
{ name: 'proxyUrl', type: String, defaultValue: 'http://localhost:9000' },
1414
{ name: 'credentials', type: Boolean, defaultValue: false },
15-
{ name: 'origin', type: String, defaultValue: '*' }
15+
{ name: 'origin', type: String, defaultValue: '*' },
16+
{ name: 'webhookStore', type: String }
1617
];
1718

1819
try {
1920
var options = commandLineArgs(optionDefinitions);
20-
if (!options.proxyUrl) {
21-
throw new Error('--proxyUrl is required');
21+
if (!options.webhookStore) {
22+
throw new Error('--webhookStore is required. example --webhookStore https://claimyourdomain.webhook.store');
2223
}
23-
lcp.startProxy(options.port, options.proxyUrl, options.proxyPartial, options.credentials, options.origin);
24+
lcp.startProxy(options.port, options.proxyUrl, options.proxyPartial, options.credentials, options.origin, options.webhookStore);
2425
} catch (error) {
2526
console.error(error);
2627
}

lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ var express = require('express');
22
var request = require('request');
33
var cors = require('cors');
44
var chalk = require('chalk');
5+
var open = require('open');
56
var proxy = express();
67

7-
var startProxy = function(port, proxyUrl, proxyPartial, credentials, origin) {
8+
var startProxy = function(port, proxyUrl, proxyPartial, credentials, origin, webhookStoreUrl) {
89
proxy.use(cors({credentials: credentials, origin: origin}));
910
proxy.options('*', cors({credentials: credentials, origin: origin}));
1011

@@ -46,6 +47,8 @@ var startProxy = function(port, proxyUrl, proxyPartial, credentials, origin) {
4647
chalk.bold('http://localhost:' + port + '/' + cleanProxyPartial + '\n')
4748
)
4849
);
50+
console.log(chalk.cyan('Now opening the webhook store ' + chalk.bold(webhookStoreUrl)));
51+
open(webhookStoreUrl)
4952
};
5053

5154
exports.startProxy = startProxy;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"command-line-args": "^5.0.2",
3232
"cors": "^2.8.4",
3333
"express": "^4.16.3",
34+
"open": "^8.4.0",
3435
"request": "^2.85.0"
3536
}
3637
}

yarn.lock

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ debug@2.6.9:
185185
dependencies:
186186
ms "2.0.0"
187187

188+
define-lazy-prop@^2.0.0:
189+
version "2.0.0"
190+
resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f"
191+
integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==
192+
188193
delayed-stream@~1.0.0:
189194
version "1.0.0"
190195
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
@@ -384,10 +389,22 @@ ipaddr.js@1.6.0:
384389
version "1.6.0"
385390
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.6.0.tgz#e3fa357b773da619f26e95f049d055c72796f86b"
386391

392+
is-docker@^2.0.0, is-docker@^2.1.1:
393+
version "2.2.1"
394+
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
395+
integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
396+
387397
is-typedarray@~1.0.0:
388398
version "1.0.0"
389399
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
390400

401+
is-wsl@^2.2.0:
402+
version "2.2.0"
403+
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
404+
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
405+
dependencies:
406+
is-docker "^2.0.0"
407+
391408
isstream@~0.1.2:
392409
version "0.1.2"
393410
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
@@ -469,6 +486,15 @@ on-finished@~2.3.0:
469486
dependencies:
470487
ee-first "1.1.1"
471488

489+
open@^8.4.0:
490+
version "8.4.0"
491+
resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8"
492+
integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==
493+
dependencies:
494+
define-lazy-prop "^2.0.0"
495+
is-docker "^2.1.1"
496+
is-wsl "^2.2.0"
497+
472498
parseurl@~1.3.2:
473499
version "1.3.2"
474500
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"

0 commit comments

Comments
 (0)