Skip to content

Commit

Permalink
feat: add postgres docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Dec 26, 2021
1 parent 5289a21 commit 4c79928
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ SWAGGER_ENABLE = true
# Database
TYPEORM_CONNECTION = postgres
TYPEORM_HOST = localhost
TYPEORM_USERNAME = root
TYPEORM_PASSWORD =
TYPEORM_DATABASE = nestjs
TYPEORM_USERNAME = realworld
TYPEORM_PASSWORD = 123456
TYPEORM_DATABASE = nestjs_realworld
TYPEORM_PORT = 5432
TYPEORM_SYNCHRONIZE = true
TYPEORM_LOGGING = true
Expand Down
45 changes: 6 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,13 @@

# Getting started

## Installation
```bash
yarn install
cp .env.template .env
docker compose up
```

...

----------

## Database

The example codebase uses [Typeorm](http://typeorm.io/) with Postgres.

Create a new postgres database with the name `nestjsrealworld` (or the name you specified in the ormconfig.json)

Set mysql database settings in ormconfig.json

{
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "your-mysql-username",
"password": "your-mysql-password",
"database": "nestjsrealworld",
"entities": ["src/**/**.entity{.ts,.js}"],
"synchronize": true
}

Start local mysql server and create new database 'nestjs_realworld'

On application start, tables for all entities will be created.
- Open `http://localhost:3000/api/articles` in your favourite browser`

----------

Expand All @@ -46,21 +25,9 @@ This application adheres to the api specifications set by the [Thinkster](https:
More information regarding the project can be found here https://github.com/gothinkster/realworld

----------

## Start application

- `npm start`
- Test api with `http://localhost:3000/api/articles` in your favourite browser

----------

# Authentication

This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the `Authorization` header with `Token` scheme. The JWT authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT.

----------

# Swagger API docs

This example repo uses the NestJS swagger module for API documentation. [NestJS Swagger](https://github.com/nestjs/swagger) - [www.swagger.io](https://swagger.io/)
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.1'

services:
postgres:
image: postgres
environment:
POSTGRES_USER: ${TYPEORM_USERNAME:-"realworld"}
POSTGRES_PASSWORD: ${TYPEORM_PASSWORD:-"123456"}
POSTGRES_DB: ${TYPEORM_DATABASE:-"nestjs_realworld"}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nestjs-realworld-example-app",
"version": "0.1.1",
"version": "0.2",
"main": "index.js",
"repository": "https://github.com/mutoe/nestjs-realworld-example-app",
"author": "mutoe <[email protected]>",
Expand Down

0 comments on commit 4c79928

Please sign in to comment.