Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/brunormferreira/nodejs-docker

a basic example to create a rest api with nodejs/express and docker
https://github.com/brunormferreira/nodejs-docker

Last synced: 2 months ago
JSON representation

a basic example to create a rest api with nodejs/express and docker

Awesome Lists containing this project

README

        

# nodejs-docker




run-in-insomnia
100% coverage
stars

- A basic example to create an api with [Nodejs](https://nodejs.org/en/) and containering with [Docker](https://www.docker.com/).

- Tests API Calls with [Insomnia REST Client](https://insomnia.rest/).

- Pizza API. :P

## Table of Contents

- [Docker](#docker)
- [Packages](#packages)
- [HTTP Methods](#http-methods)
- [API Reference](#api-reference)

## Docker

- On command line, do as follow:

```sh
$ sudo docker build # > rebuild image
```

```sh
$ sudo docker-compose up # > up container
```

- Or run only

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

## Packages

- uuidv4;
- nodemon;
- express;
- cors;

## HTTP methods

- GET
- POST
- PUT
- DELETE

## API Reference

All requests require a key parameter, eg `/api/`

---

|Endpoint|Method|
|:--|:--|
|/api/pizzas|GET|

Sample Response
```json
[
{ "name": "Basca", "flavor": "meat and vegetables", "price": 50.40 },
{ "name": "Pepperoni", "flavor": "Pepperoni and herbs", "price": 44.70 }
]
```
---
|Endpoint|Method|
|:--|:--|
|/api/pizzas|POST|

Sample Response
```json
{
"id": "01dac858-cf38-4b8a-885d-ad2af6c03653",
"name": "Pepperoni",
"flavor": "Pepperoni and herbs",
"price": 44.80
}
```
---

|Endpoint|Method|
|:--|:--|
|/api/pizzas/:id|PUT|

Sample Response
```json
{
"id": "01dac858-cf38-4b8a-885d-ad2af6c03653",
"name": "Chesse",
"flavor": "Cheese and Pepperoni",
"price": 51.20
}
```
---

|Endpoint|Method|
|:--|:--|
|/api/pizzas/:id|DELETE|

No Response
```js
Only status 204.
```