<h1 align="center">Welcome to <%- projectName %> API 👋</h1>
<p>
  <img alt="Version" src="https://img.shields.io/badge/version-0.1.0-blue.svg?cacheSeconds=2592000" />
</p>

> Readme created by generator-express-api-generator

See documentation in [generator-express-api-generator](https://github.com/cristopher1/generator-express-api-generator/tree/main)

### [Index](#index)

- [Run the API in localhost](#localhost)
- [Run the API using DockerFile created by generator-express-api-generator](#docker-support)
- [Run the API using docker-compose.yml created by generator-express-api-generator](#docker-compose-support)

### <a id="localhost"></a> Run the API in localhost

#### Prerequisites

- The database you are going to use must be installed, configured and running

**Enter the api folder**

```sh
cd api
```

**Install dependencies**

if the package-lock.json or node_modules are missing. Run the following command

```sh
npm install
```

**Environment variables**

Configure the environment variables into .env file

**Run API in development mode**

Runs the API using the following command

```sh
npm run dev
```

**The API documentation is in http://localhost:${PORT}/api/v1/docs**

**See PORT environment variables from .env file**

### <a id="docker-support"></a> Run the API using Dockerfile created by generator-express-api-generator

#### Prerequisites

- You must have Docker installed
- <a ref="https://docs.docker.com/build/buildkit/">You must have Docker BuildKit</a>
- The database you are going to use must be installed, configured and running

**Enter the api folder**

```sh
cd api
```

**Environment variables**

Configure the environment variables into .env file

**Create the Docker image**

```sh
docker buildx build --target development -t SOME_TAG .
```

Replace SOME_TAG by some name to identify the image, example: my_api:1.0.0 or my_api

--target: Used when the Dockerfile contains AS (target), for example: AS base, AS development, AS production, etc
The Dockerfile generated by generator-express-api-generator contains two target: base and development

For more information, use:

```sh
docker buildx build --help
```

**Create the Docker container**

```sh
docker run --env-file .env -p HOST_PORT:PORT THE_TAG_USED_IN_DOCKER_BUILD
```

For more information, use:

```sh
docker run --help
```

Where HOST_PORT is the port in the host used to access to API and PORT is a environment variable that is in .env file

**The API documentation is in http://localhost:HOST_PORT/api/v1/docs**

### <a id="docker-compose-support"></a> Run the API using docker-compose.yml created by generator-express-api-generator

#### Prerequisites

- You must have Docker and Docker Compose installed
- <a ref="https://docs.docker.com/build/buildkit/">You must have Docker BuildKit</a>

**In the folder that contains the docker-compose.yml file.Run the following command**

```sh
docker-compose up --build
```

**If you use the default settings. The api is running on port 3000**

**The API documentation is in http://localhost:3000/api/v1/docs**

---

_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
