Skip to content

Commit bc662aa

Browse files
authored
Merge pull request #7 from howtographql/chapter-9-finish
Add code for chapter 9
2 parents 88da520 + 8618cd0 commit bc662aa

File tree

16 files changed

+127
-68
lines changed

16 files changed

+127
-68
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# rename file to .env
2+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/hackernews-db

.github/workflows/deployment.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
name: deploy-hackernews-app-heroku
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- run: npm ci
16+
- name: Run production migration
17+
run: npm run migrate:deploy
18+
env:
19+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
20+
- uses: akhileshns/[email protected]
21+
with:
22+
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
23+
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
24+
heroku_email: ${{ secrets.HEROKU_EMAIL }}
25+

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
node_modules
2-
# Keep environment variables out of version control
32
.env
4-
.idea
53
.vscode
6-
dist
4+
dist
5+
.idea

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ Tutorial for HowToGraphQL with Typescript, Apollo-Server, Nexus and Prisma.
44

55
### Installation
66

7-
1. Run `npm install`
8-
2. Run `npx prisma generate`
9-
3. Run `npm dev`
7+
1. Install dependencies: `npm install`
8+
2. Start a PostgreSQL database with docker using: `docker-compose up -d`.
9+
- If you have a local instance of PostgreSQL running, you can skip this step.
10+
3. Create a `.env` file and add the `DATABASE_URL` environment variable with a [PostgreSQL connection string](https://www.prisma.io/docs/concepts/database-connectors/postgresql#connection-details).
11+
- The `.env.example` file is provided as reference.
12+
4. Apply database migrations: `npx prisma migrate dev`
13+
5. Start the project: `npm dev`
14+
1015

11-
_Note:_ There's no need to run migrations on the database because the SQLite Database is added to version control for convenience.

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.8'
2+
services:
3+
4+
# Docker connection string for local machine: postgres://postgres:postgres@localhost:5432/
5+
6+
postgres:
7+
image: postgres:13.5
8+
restart: always
9+
environment:
10+
- POSTGRES_USER=postgres
11+
- POSTGRES_PASSWORD=postgres
12+
volumes:
13+
- postgres:/var/lib/postgresql/data
14+
ports:
15+
- '5432:5432'
16+
17+
volumes:
18+
postgres:
19+

package-lock.json

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"dev": "ts-node-dev --transpile-only --no-notify --exit-child src/index.ts",
99
"generate": "ts-node --transpile-only src/schema",
10-
"prettier-format": "prettier 'src/**/*.ts' --write"
10+
"prettier-format": "prettier 'src/**/*.ts' --write",
11+
"migrate:deploy": "prisma migrate deploy",
12+
"build": "prisma generate && npm run generate && tsc",
13+
"start": "node dist/src/index.js"
1114
},
1215
"keywords": [],
1316
"author": "",

prisma/dev.db

-40 KB
Binary file not shown.

prisma/migrations/20211116205624_init/migration.sql

Lines changed: 0 additions & 7 deletions
This file was deleted.

prisma/migrations/20211120093350_user/migration.sql

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)