Skip to content

Commit d53534d

Browse files
committed
feat: add postgres docker compose file
1 parent 4b46592 commit d53534d

4 files changed

Lines changed: 22 additions & 43 deletions

File tree

.env.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ SWAGGER_ENABLE = true
77
# Database
88
TYPEORM_CONNECTION = postgres
99
TYPEORM_HOST = localhost
10-
TYPEORM_USERNAME = root
11-
TYPEORM_PASSWORD =
12-
TYPEORM_DATABASE = nestjs
10+
TYPEORM_USERNAME = realworld
11+
TYPEORM_PASSWORD = 123456
12+
TYPEORM_DATABASE = nestjs_realworld
1313
TYPEORM_PORT = 5432
1414
TYPEORM_SYNCHRONIZE = true
1515
TYPEORM_LOGGING = true

README.md

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,14 @@
77

88
# Getting started
99

10-
## Installation
10+
```bash
11+
yarn install
12+
cp .env.template .env
13+
docker compose up
14+
```
1115

12-
...
13-
14-
----------
15-
16-
## Database
17-
18-
The example codebase uses [Typeorm](http://typeorm.io/) with Postgres.
19-
20-
Create a new postgres database with the name `nestjsrealworld` (or the name you specified in the ormconfig.json)
21-
22-
Set mysql database settings in ormconfig.json
23-
24-
{
25-
"type": "mysql",
26-
"host": "localhost",
27-
"port": 3306,
28-
"username": "your-mysql-username",
29-
"password": "your-mysql-password",
30-
"database": "nestjsrealworld",
31-
"entities": ["src/**/**.entity{.ts,.js}"],
32-
"synchronize": true
33-
}
34-
35-
Start local mysql server and create new database 'nestjs_realworld'
36-
37-
On application start, tables for all entities will be created.
16+
- Open `http://localhost:3000/api/articles` in your favourite browser`
17+
- Open `http://localhost:3000/docs` to view swagger API document
3818

3919
----------
4020

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

49-
----------
50-
51-
## Start application
52-
53-
- `npm start`
54-
- Test api with `http://localhost:3000/api/articles` in your favourite browser
5529

5630
----------
5731

5832
# Authentication
5933

6034
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.
61-
62-
----------
63-
64-
# Swagger API docs
65-
66-
This example repo uses the NestJS swagger module for API documentation. [NestJS Swagger](https://github.com/nestjs/swagger) - [www.swagger.io](https://swagger.io/)

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.1'
2+
3+
services:
4+
postgres:
5+
image: postgres
6+
environment:
7+
POSTGRES_USER: ${TYPEORM_USERNAME:-"realworld"}
8+
POSTGRES_PASSWORD: ${TYPEORM_PASSWORD:-"123456"}
9+
POSTGRES_DB: ${TYPEORM_DATABASE:-"nestjs_realworld"}
10+
ports:
11+
- "5432:5432"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-realworld-example-app",
3-
"version": "0.1.1",
3+
"version": "0.2",
44
"main": "index.js",
55
"repository": "https://github.com/mutoe/nestjs-realworld-example-app",
66
"author": "mutoe <mutoe@foxmail.com>",

0 commit comments

Comments
 (0)