Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/brunormferreira/nodejs-docker
- Owner: brunormferreira
- Created: 2020-03-12T18:59:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T05:04:18.000Z (about 2 years ago)
- Last Synced: 2024-10-11T13:25:37.038Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 250 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodejs-docker
- 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.
```