Skip to content

Instantly share code, notes, and snippets.

@NathBabs
NathBabs / node_nginx_ssl.md
Created October 8, 2019 09:26 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@NathBabs
NathBabs / heroku_env_copy.sh
Created September 21, 2021 20:55 — forked from nabucosound/heroku_env_copy.sh
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@NathBabs
NathBabs / index.js
Created September 26, 2021 14:29
Export routes folder contents through index.js using ESM exports
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
import express from "express";
const router = express.Router();
import * as fs from 'fs'
import path, { dirname, join } from 'path';
const __dirname = dirname(__filename);
const basename = path.basename(__filename);
@NathBabs
NathBabs / Procfile
Last active October 4, 2021 23:47
Logging with PM2 on Heroku
web: pm2 start app.js && pm2 logs all
@NathBabs
NathBabs / gist:753bfdc0c416fae7e55302db4b188cc0
Created October 5, 2021 22:00
postmanerator command to convert Postman collection to HTML
postmanerator --output=./doc.html -ignored-response-headers="Content-Length,X-Permitted-Cross-Domain-Policies,X-Content-Type-Options,X-Download-Options,ETag,Strict-Transport-Security,X-Frame-Options,Expect-CT,X-DNS-Prefetch-Control,Content-Security-Policy,Referrer-Policy,X-XSS-Protection,Date,Connection,Keep-Alive" --collection=metacare.postman_collection.json
@NathBabs
NathBabs / HerokuDeploy
Created October 5, 2021 22:06
Deploy container to Heroku
Deploy to Heroku in Container
login to heroku
heroku container:login
create an app for containers
heroku create
@NathBabs
NathBabs / index.js
Created March 10, 2022 11:01
index.js file in model folder to pass all model files to sequelize and export
'use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
@NathBabs
NathBabs / restify.js
Created April 27, 2022 20:00
call another endpoint in restify
function request(bearerToken) {
return function () {
const client = restify.createJSONClient({
url: process.env.GRUPP_API_URL,
version: "*",
});
client.headers.authorization = `Bearer ${bearerToken}`;
return client;
};
@NathBabs
NathBabs / aggs.json
Last active April 30, 2022 19:15
ElasticSearch Sum and Terms combination
"aggs": {
"bank_card_metrics": {
"terms": {
"field": "cardBank.keyword"
},
"aggs": {
"cards": {
"terms": {
"field": "cardType.keyword"
},
@NathBabs
NathBabs / envCopy.txt
Last active May 20, 2022 14:24
Copy .env variables fro Heroku App to .env file
heroku config -s -a [app-name-on-heroku] > .env