Giter Site home page Giter Site logo

node-express-postgresql-heroku-tutorial's Introduction

Prerequisites

  1. Node.js

http://nodejs.org/

  1. Heroku toolbelt

https://toolbelt.heroku.com/

  1. Postgresql

    $ sudo apt-get install postgresql

Tutorial

Clone this repo:

$ git clone https://github.com/FTraian/node-express-postgresql-heroku-tutorial.git 	

Create a Heroku app. Be careful as is global on Heroku so another user might already have the 'test' name:

$ cd node-express-postgresql-heroku-tutorial
$ heroku create <app-name>

Add Postgresql to your app:

$ heroku addons:add heroku-postgresql:dev

Get DB details:

$ heroku config | grep HEROKU_POSTGRESQL

They will look as: HEROKU_POSTGRESQL_IVORY_URL: postgres://user:[email protected]:5432/database

Promote the DB as primary DB:

$ heroku pg:promote HEROKU_POSTGRESQL_IVORY_URL

You should now be able to reference it as DATABASE_URL but due to a bug in heroku it's not working at the moment. Instead we will use the full connection sring in web.js.

In order to use DB from local machine set PGSSLMODE variable:

$ export PGSSLMODE=require

Create table and add some data:

$ heroku pg:psql

> CREATE TABLE MyTable (id int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY(id))
> INSERT into MyTable VALUES (1, 'First USer'), (2, 'Second User');

Install required modules:

$ npm install

Start application locally:

$ foreman start

Access app at: http://localhost:5000

View the logs:

$ heroku logs

Deploy app to heroku:

$ git push heroku master

Access remote app:

$ heroku open

node-express-postgresql-heroku-tutorial's People

Contributors

ftraian avatar

Watchers

James Cloos avatar Vladimir Pineda avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.