An open API service indexing awesome lists of open source software.

https://github.com/leonardovff/nodejs-bookstore-api

Bookstore API using docker, nodejs, typescript, mongodb, prisma orm and jest. Trying to follow the clean architecture.
https://github.com/leonardovff/nodejs-bookstore-api

docker docker-compose jest mongodb nodejs prisma typescript

Last synced: 2 months ago
JSON representation

Bookstore API using docker, nodejs, typescript, mongodb, prisma orm and jest. Trying to follow the clean architecture.

Awesome Lists containing this project

README

          

# BOOKSTORE NODE.JS API
A bookstore API created using node.js, typescript/javascript, mongodb, prisma orm, and jest.

Trying to follow the depency rule and layers described in clean architecture, but avoiding to use or create a dependency injection mechanism.

## Requirements to run the project
Docker and docker compose (it is installed together with docker in the last versions)

## Development setup
```bash
# Copy the .env-example to .env
cp .env-example .env

# It will init all the containers required to run the project
docker compose up -d

# If you want to check the logs you can use
docker compose logs

# or if you want to check the logs of just one container
docker compose logs node
```

## Development setup: steps by step
1. Start the mongodb server
```bash
# Copy the .env-example to .env
cp .env-example .env

# Up the containers with mongodb working with replicas (it is required by prisma)
docker compose up -d mongo1 mongo2 mongo3
```
2. If you want, there is a web visual client for mongodb in the project:
```bash
# Up the containers with mongo-express (the web visual client)
docker compose up -d mongo-ui

# Now you can open the link http://localhost:8086 in your browser
```

3. Start the dev server container
```bash
docker compose up node
```

## API documentation
By default a open api documentation and swagger ui is generated and is available the /api-docs endpoint

## Run commands inside the node container
```bash
docker compose exec node sh
```

### Seed the database
```bash
docker compose exec node sh -c 'npm run seed'
```

### Run lint
```bash
docker compose exec node sh -c 'npm run lint'
```

### Run tests
```bash
docker compose exec node sh -c 'npm run test'

# if you want you can run it in watch mode
docker compose exec node sh -c 'npm run test -- --watchAll'
```

### To improve developer experience - we recommend:
- Use in vscode the following extensions:
1. editorconfig
2. eslint
3. prisma