| 
									
										
										
										
											2018-09-20 10:20:30 +01:00
										 |  |  | const path = require('path'); | 
					
						
							| 
									
										
										
										
											2020-03-17 16:14:58 +05:30
										 |  |  | require('dotenv').config({ path: path.resolve(__dirname, '../.env') }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 11:23:18 +01:00
										 |  |  | const nodemon = require('nodemon'); | 
					
						
							| 
									
										
										
										
											2020-03-17 16:14:58 +05:30
										 |  |  | 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.'); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-03 11:23:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | nodemon({ | 
					
						
							|  |  |  |   ext: 'js json', | 
					
						
							|  |  |  |   // --silent squashes an ELIFECYCLE error when the server exits
 | 
					
						
							| 
									
										
										
										
											2018-10-08 12:58:56 +03:00
										 |  |  |   exec: 'npm run --silent babel-dev-server', | 
					
						
							| 
									
										
										
										
											2018-09-20 10:20:30 +01:00
										 |  |  |   watch: path.resolve(__dirname, './server'), | 
					
						
							| 
									
										
										
										
											2018-10-08 12:58:56 +03:00
										 |  |  |   spawn: true, | 
					
						
							|  |  |  |   env: { | 
					
						
							|  |  |  |     DEBUG: 'fcc*' | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-09-03 11:23:18 +01:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | nodemon.on('restart', function nodemonRestart(files) { | 
					
						
							| 
									
										
										
										
											2020-03-17 16:14:58 +05:30
										 |  |  |   log('App restarted due to: ', files); | 
					
						
							| 
									
										
										
										
											2018-09-03 11:23:18 +01:00
										 |  |  | }); |