فهرست منبع

Small improvements to dev environment and hid .env file.

KrisVos130 7 سال پیش
والد
کامیت
9b0514f339
4فایلهای تغییر یافته به همراه16 افزوده شده و 4 حذف شده
  1. 2 0
      .env
  2. 2 1
      .gitignore
  3. 2 1
      backend/config/template.json
  4. 10 2
      backend/logic/mail/index.js

+ 2 - 0
.env

@@ -1 +1,3 @@
 REDIS_PASSWORD=PASSWORD
+BACKEND_PORT=8080
+FRONTEND_PORT=80

+ 2 - 1
.gitignore

@@ -23,4 +23,5 @@ frontend/build/config/default.json
 npm
 
 # Logs
-log/
+log/
+.env

+ 2 - 1
backend/config/template.json

@@ -22,7 +22,8 @@
 		},
 		"mailgun": {
 			"key": "",
-			"domain": ""
+			"domain": "",
+		  	"enabled": true
 		}
 	},
 	"cors": {

+ 10 - 2
backend/logic/mail/index.js

@@ -1,7 +1,14 @@
 'use strict';
 
 const config = require('config');
-const mailgun = require('mailgun-js')({apiKey: config.get("apis.mailgun.key"), domain: config.get("apis.mailgun.domain")});
+const enabled = config.get('apis.mailgun.enabled');
+let mailgun = null;
+if (enabled) {
+	mailgun = require('mailgun-js')({
+		apiKey: config.get("apis.mailgun.key"),
+		domain: config.get("apis.mailgun.domain")
+	});
+}
 
 let lib = {
 
@@ -19,7 +26,8 @@ let lib = {
 
 	sendMail: (data, cb) => {
 		if (!cb) cb = ()=>{};
-		mailgun.messages().send(data, cb);
+		if (enabled) mailgun.messages().send(data, cb);
+		else cb();
 	}
 };