Skip to content

Commit

Permalink
Herokuize project
Browse files Browse the repository at this point in the history
* add build step to project
* add dev script
* instruct to use DATABASE_URL
* put morgan in dependencies
* inspired by
https://github.com/babel/example-node-server/blob/master/package.json
  • Loading branch information
morenoh149 committed Mar 8, 2019
1 parent ad11893 commit 1d81cfa
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logfile

.env

node_modules/
dist/
node_modules/
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,24 @@ Client Applications:
* `npm install`
* fill out *.env file* (see below)
* start PostgreSQL database
* `npm start`
* `npm run dev`
* visit `http://localhost:8000` for GraphQL playground

## Deployment

Since we use modern javascript syntax, we need to perform a build step before
deploying to production. The compiled API is put in `lib/`.

* provision postgres database
* `npm run build`
* `npm start`

#### .env file

Since this boilerplate project is using PostgreSQL, you have to install it for your machine and get a database up and running. You find everything for the set up over here: [Setup PostgreSQL with Sequelize in Express Tutorial](https://www.robinwieruch.de/postgres-express-setup-tutorial). After you have created a database and a database user, you can fill out the environment variables in the *server/.env* file.

```
DATABASE=mydatabase
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
DATABASE_URL=postgres://username:password@localhost:5432/mydatabase
SECRET=asdlplplfwfwefwekwself.2342.dawasdq
```

Expand Down
70 changes: 55 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"node": "10.11.0"
},
"scripts": {
"start": "nodemon --exec babel-node src/index.js",
"start": "npm run build && node lib/index.js",
"build": "babel src --out-dir dist",
"dev": "nodemon --exec babel-node src/index.js",
"heroku-postbuild": "npm run build",
"test:run-server": "TEST_DATABASE=mytestdatabase npm start",
"test:execute-test": "mocha --require @babel/register 'src/**/*.spec.js'",
"test": "echo \"No test specified\" && exit 0"
Expand All @@ -16,15 +19,15 @@
"author": "Robin Wieruch <[email protected]> (https://www.robinwieruch.de)",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.1.6",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/register": "^7.0.0",
"axios": "^0.18.0",
"chai": "^4.2.0",
"mocha": "^5.2.0",
"nodemon": "^1.18.7",
"morgan": "^1.9.1"
"nodemon": "^1.18.7"
},
"dependencies": {
"apollo-server": "^2.2.3",
Expand All @@ -38,6 +41,7 @@
"graphql-iso-date": "^3.6.1",
"graphql-resolvers": "^0.2.2",
"jsonwebtoken": "^8.4.0",
"morgan": "^1.9.1",
"pg": "^7.6.1",
"sequelize": "^4.41.2",
"uuid": "^3.3.2"
Expand Down

0 comments on commit 1d81cfa

Please sign in to comment.