deployment configuration

This commit is contained in:
canove
2020-06-19 08:28:12 -03:00
parent 8a6324a98b
commit 4e69c0b008
10 changed files with 28 additions and 21 deletions

7
backend/.env.example Normal file
View File

@@ -0,0 +1,7 @@
NODE_ENV=development
PORT=8080
DB_HOST=
DB_USER=
DB_PASS=
DB_NAME=

3
backend/.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules
public/*
public/*
.env

View File

@@ -1,3 +1,4 @@
require("dotenv/config");
const express = require("express");
const path = require("path");
const cors = require("cors");
@@ -46,7 +47,7 @@ app.use((error, req, res, next) => {
sequelize
.sync()
.then(() => {
const server = app.listen(8080);
const server = app.listen(process.env.PORT);
const io = require("./socket").init(server);
io.on("connection", socket => {
console.log("Client Connected");
@@ -64,11 +65,11 @@ sequelize
});
});
wBot.init().then(res => {
wBot.init().then(() => {
wbotMessageListener();
wbotMonitor();
});
console.log("Server started");
console.log("Server started on", process.env.PORT);
})
.catch(err => {
console.log(err);

View File

@@ -82,7 +82,7 @@ exports.getContactMessages = async (req, res, next) => {
...message.dataValues,
mediaUrl: `${
message.mediaUrl
? `http://localhost:8080/public/${message.mediaUrl}`
? `http://localhost:${process.env.PORT}/public/${message.mediaUrl}`
: ""
}`,
};

View File

@@ -82,7 +82,7 @@ const wbotMessageListener = () => {
...newMessage.dataValues,
mediaUrl: `${
newMessage.mediaUrl
? `http://localhost:8080/public/${newMessage.mediaUrl}`
? `http://localhost:${process.env.PORT}/public/${newMessage.mediaUrl}`
: ""
}`,
},

View File

@@ -754,6 +754,11 @@
"is-obj": "^2.0.0"
}
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"dottie": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz",

View File

@@ -17,6 +17,7 @@
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-validator": "^6.5.0",
"jsonwebtoken": "^8.5.1",

View File

@@ -1,13 +1,17 @@
require("dotenv/config");
const Sequelize = require("sequelize");
const sequelize = new Sequelize("econo_whatsbot", "root", "nodecomplete", {
const sequelize = new Sequelize({
define: {
charset: "utf8mb4",
collate: "utf8mb4_bin",
},
dialect: "mysql",
timezone: "-03:00",
host: "localhost",
host: process.env.DB_HOST,
database: process.env.DB_NAME,
username: process.env.DB_USER,
password: process.env.DB_PASS,
logging: false,
});