Skip to content

Commit 1af7e5c

Browse files
michromesushantdhiman
authored andcommitted
Heroku (#46)
* Add Heroku generated app.json * Easy deployment to Heroku * npm install pg
1 parent 9f61b79 commit 1af7e5c

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This repository demonstrates the usage of Sequelize within an [Express](https://expressjs.com) application.
44
The implemented logic is a simple task tracking tool.
55

6+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
7+
68
## Starting App
79

810
```

‎app.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"addons": [
3+
{
4+
"plan": "heroku-postgresql"
5+
}
6+
],
7+
"buildpacks": [],
8+
"env": {
9+
"NODE_ENV": {
10+
"description": "Run as a production environment on Heroku",
11+
"value": "production"
12+
}
13+
},
14+
"formation": {},
15+
"name": "express-example",
16+
"scripts": {}
17+
}

‎models/index.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ var path = require("path");
55
var Sequelize = require("sequelize");
66
var env = process.env.NODE_ENV || "development";
77
var config = require(path.join(__dirname, '..', 'config', 'config.json'))[env];
8-
var sequelize = new Sequelize(config.database, config.username, config.password, config);
8+
if (process.env.DATABASE_URL) {
9+
var sequelize = new Sequelize(process.env.DATABASE_URL);
10+
} else {
11+
var sequelize = new Sequelize(config.database, config.username, config.password, config);
12+
}
913
var db = {};
1014

1115
fs

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"express": "^4.14.0",
1616
"jade": "~1.11.0",
1717
"morgan": "^1.7.0",
18+
"pg": "^6.1.0",
1819
"sequelize": "^3.23.6",
1920
"sequelize-cli": "^2.4.0",
2021
"serve-favicon": "~2.3.0",

0 commit comments

Comments
 (0)