Changed config path for server to use local env files.
This commit is contained in:
@@ -11,16 +11,15 @@ xclip -sel clip < ~/.ssh/id_rsa.pub
|
||||
|
||||
Add the SSH key to the drop creation screen.
|
||||
|
||||
|
||||
1. Create a new user to replace root user
|
||||
1. # adduser bob
|
||||
2. # usermod -aG sudo bob
|
||||
3. # su - bob
|
||||
1. # adduser imex
|
||||
2. # usermod -aG sudo imex
|
||||
3. # su - imex
|
||||
4. $ mkdir ~/.ssh
|
||||
5. $ chmod 700 ~/.ssh
|
||||
6. $ nano ~/.ssh/authorized_keys
|
||||
7. Add the copied SSH key and save.
|
||||
8. $ chmod 600 ~/.ssh/authorized_keys #Restrict access to authroized keys.
|
||||
8. $ chmod 600 ~/.ssh/authorized_keys #Restrict access to authorized keys.
|
||||
2. Setup the Firewall
|
||||
1. $ sudo ufw allow OpenSSH.
|
||||
2. $ sudo ufw enable
|
||||
@@ -43,20 +42,20 @@ Add the SSH key to the drop creation screen.
|
||||
8. Setup PM2
|
||||
1. $ npm install pm2 -g
|
||||
2. copy the environment variables to the local .env file.
|
||||
3. $ pm2 start server.js
|
||||
3. $ pm2 start ecosystem.config.js
|
||||
4. $ pm2 startup ubuntu //Ensure it starts when server does.
|
||||
9. Alter Nginx config
|
||||
1. sudo nano /etc/nginx/sites-available/default
|
||||
2. Add Appropriate server names to the file. www. and non-www.
|
||||
3. Add the following inside the location block:
|
||||
proxy_pass http://localhost:{{YOUR-APP-PORT-IN-YOUR-CODE}};
|
||||
2. //Add Appropriate server names to the file. www. and non-www.
|
||||
3. Add the following inside the location of the server block:
|
||||
proxy_pass http://localhost:5000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
9. Install Certbot
|
||||
1. $ sudo add-apt-repository ppa:certbot/certbot
|
||||
1. $ sudo add-apt-repository ppa:certbot/certbot //Potential issue on ubuntu 20.04
|
||||
2. $ sudo apt-get update
|
||||
3. $ sudo apt install python-certbot-nginx
|
||||
4. $ sudo nano /etc/nginx/sites-available/default
|
||||
@@ -70,3 +69,8 @@ Add the SSH key to the drop creation screen.
|
||||
1. $ sudo certbot --nginx -d example.com -d www.example.com //Follow prompts.
|
||||
2. $ sudo certbot renew --dry-run //Dry run to test auto renewal.
|
||||
|
||||
|
||||
ADding Yarn
|
||||
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
sudo apt-get update && sudo apt-get install yarn
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "bodyshop-dev-b1cb6",
|
||||
"private_key_id": "68cbb23486745271eb9ebd19b544f4f0ffff208f",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCkw6wLHLibOjc2\npCoHqZ2pc1AbrecocNWVnVF8W7j8Zkc/oacwNVD/EMZ7dDjlT9vcmf71Yw2mDWOO\njQaXSlOASkDYE0jDYyMyYflonaGyGmAemyirRqXV78g9hliAMcS+HL6wL7HpZ8Y3\nGVp9pYn792aJnCrXJOZvRFqx+eOBztLADBmBpMH4u9FFM6ZdLuWjmgKJwx5u/jYx\nFIxJuEA1Zo1ZPT9D5amgYzmI4Tjvj8b5WzlsFA7HEkAV96f3AY4cnIWqlz6Vm2qR\nXvroDueqzM6QbzqXI5iHKkcJfH1DQpjUyLX82+5nnTEoaYSqzy7ja2ILpBrY+Noh\nAWLsxq7bAgMBAAECggEAKlaPmIFmXJj+hB92H2bx+Q+FF7+9pRItiBcXT83gAJel\nmk/HPueMayab4jBQyHgXZp35uoOcB73sBb7uYST7xP0PoZZ+/Zo1eqZbaQsMeFA3\nv9WeAzkRtyI5AbpKdpKTXEjVpT90R6ZfdFwi+SN3DB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9E9h\n4mMvZOe/P8k5MPlPoXrt1Q==\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-8mboc@bodyshop-dev-b1cb6.iam.gserviceaccount.com",
|
||||
"client_id": "106919386910689150709",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-8mboc%40bodyshop-dev-b1cb6.iam.gserviceaccount.com"
|
||||
}
|
||||
@@ -3,6 +3,7 @@ module.exports = {
|
||||
{
|
||||
name: "ImEX Online API",
|
||||
script: "./server.js",
|
||||
watch: true,
|
||||
env: {
|
||||
NODE_ENV: "production",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
var nodemailer = require("nodemailer");
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({ path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || 'development'}`) });
|
||||
|
||||
|
||||
var transporter = nodemailer.createTransport({
|
||||
host: process.env.email_server,
|
||||
|
||||
@@ -5,7 +5,8 @@ const path = require("path");
|
||||
const compression = require("compression");
|
||||
const twilio = require("twilio");
|
||||
//var enforce = require("express-sslify");
|
||||
if (process.env.NODE_ENV !== "production") require("dotenv").config();
|
||||
|
||||
require("dotenv").config({ path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || 'development'}`) });
|
||||
|
||||
const https = require("https");
|
||||
const fs = require("fs");
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
var admin = require("firebase-admin");
|
||||
const path = require("path");
|
||||
require("dotenv").config({ path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || 'development'}`) });
|
||||
|
||||
console.log(
|
||||
"Found Firebase AdminSDK JSON",
|
||||
process.env.NODE_ENV,
|
||||
!!process.env.FIREBASE_ADMINSDK_JSON
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({ path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || 'development'}`) });
|
||||
|
||||
//TODO May need to use a different client that includes caching of resources.
|
||||
exports.client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
var cloudinary = require("cloudinary").v2;
|
||||
cloudinary.config(process.env.CLOUDINARY_URL);
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const Handlebars = require("handlebars");
|
||||
|
||||
exports.render = (req, res) => {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const queries = require("../graphql-client/queries");
|
||||
const phone = require("phone");
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const twilio = require("twilio");
|
||||
const phone = require("phone");
|
||||
const queries = require("../graphql-client/queries");
|
||||
@@ -17,27 +24,27 @@ exports.send = (req, res) => {
|
||||
.create({
|
||||
body: body,
|
||||
messagingServiceSid: messagingServiceSid,
|
||||
to: phone(to)[0]
|
||||
to: phone(to)[0],
|
||||
})
|
||||
.then(message => {
|
||||
.then((message) => {
|
||||
let newMessage = {
|
||||
msid: message.sid,
|
||||
text: body,
|
||||
conversationid,
|
||||
isoutbound: true
|
||||
isoutbound: true,
|
||||
};
|
||||
gqlClient
|
||||
.request(queries.INSERT_MESSAGE, { msg: newMessage })
|
||||
.then(r2 => {
|
||||
.then((r2) => {
|
||||
console.log("Responding GQL Message ID", JSON.stringify(r2));
|
||||
res.sendStatus(200);
|
||||
})
|
||||
.catch(e2 => {
|
||||
.catch((e2) => {
|
||||
console.log("e2", e2);
|
||||
//res.json({ success: false, message: e2 });
|
||||
});
|
||||
})
|
||||
.catch(e1 => {
|
||||
.catch((e1) => {
|
||||
//res.json({ success: false, message: error });
|
||||
console.log("e1", e1);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
require("dotenv").config();
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const queries = require("../graphql-client/queries");
|
||||
const phone = require("phone");
|
||||
@@ -8,12 +15,12 @@ exports.status = (req, res) => {
|
||||
client
|
||||
.request(queries.UPDATE_MESSAGE_STATUS, {
|
||||
msid: SmsSid,
|
||||
fields: { status: SmsStatus }
|
||||
fields: { status: SmsStatus },
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
console.log("Message Updated");
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.log("Error updating message status", error);
|
||||
});
|
||||
res.sendStatus(200);
|
||||
|
||||
Reference in New Issue
Block a user