feat(tools): add helper for testing webhooks locally
This commit is contained in:
committed by
mrugesh
parent
f25d035e9d
commit
d8e5f3ebc8
@ -1,5 +1,31 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
|
||||
|
||||
const nodemon = require('nodemon');
|
||||
const SmeeClient = require('smee-client');
|
||||
const createDebugger = require('debug');
|
||||
|
||||
const log = createDebugger('fcc:start:development');
|
||||
|
||||
if (process.env.WEBHOOK_PROXY_URL) {
|
||||
const paypalPayloadHandler = new SmeeClient({
|
||||
source: process.env.WEBHOOK_PROXY_URL,
|
||||
target: process.env.API_LOCATION + '/hooks/update-paypal',
|
||||
logger: { info: log, error: log }
|
||||
});
|
||||
|
||||
const paypalevents = paypalPayloadHandler.start();
|
||||
|
||||
process.on('exit', () => {
|
||||
log('Stopping webhook proxy client.');
|
||||
paypalevents.close(() => {
|
||||
log('Webhook proxy client is stopped.');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
log('Webhook client is not configured.');
|
||||
log('This can be ignored when not working with webhooks locally.');
|
||||
}
|
||||
|
||||
nodemon({
|
||||
ext: 'js json',
|
||||
@ -13,5 +39,5 @@ nodemon({
|
||||
});
|
||||
|
||||
nodemon.on('restart', function nodemonRestart(files) {
|
||||
console.log('App restarted due to: ', files);
|
||||
log('App restarted due to: ', files);
|
||||
});
|
||||
|
Reference in New Issue
Block a user