Skip to content

Commit

Permalink
Amending readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jpb06 committed Nov 28, 2021
1 parent 93e7d20 commit c77c3f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,71 +35,77 @@ So let's talk about the stack (pushing on an open door here, but hey):

## :zap: Guidelines

### :diamonds: Schema splitting
### 🔶 Schema splitting

We do not want a huge prisma schema. We want to isolate each model (table or set of tables) in its own file.

### :diamonds: Well documented routes
### 🔶 Well documented routes

Let's have a swagger documenting properly exposed routes, that is mainly for each route:

- a description.
- the list of possible responses.
- a definition of the inputs and outputs.

### :diamonds: Full testing coverage
### 🔶 Full testing coverage

We want to test everything to learn how to properly test, and to face every single difficulty that comes with testing. We will at very least do end to end using superagent, controllers testing, service testing.

### :diamonds: No testing against the database
### 🔶 No testing against the database

All tests should run without any interaction with a database.

## :zap: Usage

### :diamonds: run locally
### 🔶 run locally

:point_down: Since our prisma schemas are split within modules, we will have to merge them all in one file prisma can understand. Let's do just that:
#### 👇 Since our prisma schemas are split within modules, we will have to merge them all in one file prisma can understand. Let's do just that:

```bash
yarn prisma:merge
```

:point_down: Now, we need to tell prisma to generate in node_modules the code actually allowing us to interact with the database:
#### 👇 Now, we need to tell prisma to generate in node_modules the code actually allowing us to interact with the database:

```bash
yarn prisma:gen
```

:point_down: You will need docker and docker-compose to get the postgres database up and running. You can use this command to launch the database container:
#### 👇 You will need docker and docker-compose to get the postgres database up and running. You can use this command to launch the database container:

```bash
yarn dev:db
yarn docker
```

:point_down: Then, let's inject some data in our dev database using:
#### 👇 Then, let's inject some data in our dev database using:

```bash
yarn prisma:seed
```

:point_down: We can now launch the backend in dev:
#### 👇 We can now launch the backend in dev:

```bash
yarn dev
```

### :diamonds: test all the things
#### 😵 You can do the merge, gen & seed steps all at once using the following command:

```bash
yarn dev:db
```

### 🔶 test all the things

:point_down: We can run all the tests and get a coverage report using the following:
🔶 We can run all the tests and get a coverage report using the following:

```bash
yarn test:dev
```

## :zap: Subjects

### :diamonds: Authentication
### 🔶 Authentication

Let's use passport to setup jwt based authentication.

Expand All @@ -126,7 +132,7 @@ We have two users in database to play with the routes:
- :white_check_mark: services
- :white_check_mark: local passport strategy

### :diamonds: CRUD
### 🔶 CRUD

Let's create CRUD routes to manage a list of books.
We want to make sure to give a proper feedback when foreign keys violations do occur (when we try to delete an entry whose key is referenced in another table or when we try to update an entry with a foreign key that does not exist). Let's use filters for that!
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"dev": "nest start --watch",
"dev:db": "yarn prisma:merge && yarn prisma:gen && yarn prisma:seed",
"docker": "docker-compose down && docker-compose up sandbox-postgres",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
Expand Down

0 comments on commit c77c3f7

Please sign in to comment.