Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lbrulet/apinit
[apiREST] Setup | NodeJS - Mongoose - JWT with Docker
https://github.com/lbrulet/apinit
api-rest docker-compose javascript jwt-token mongodb mongoose nodejs
Last synced: about 1 month ago
JSON representation
[apiREST] Setup | NodeJS - Mongoose - JWT with Docker
- Host: GitHub
- URL: https://github.com/lbrulet/apinit
- Owner: lbrulet
- License: mit
- Created: 2018-11-21T08:17:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T11:49:01.000Z (about 2 years ago)
- Last Synced: 2023-03-08T17:23:43.784Z (almost 2 years ago)
- Topics: api-rest, docker-compose, javascript, jwt-token, mongodb, mongoose, nodejs
- Language: JavaScript
- Homepage:
- Size: 401 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# APINIT
APINIT is a setup of an apiREST using nodeJS with a mongo database and Docker.
There is a simple model of user implemented with these methods (GET/POST/PUT/DELETE), and an authentification service using JWT.
## Installation
Use [curl](https://curl.haxx.se/) to install [Docker Compose](https://docs.docker.com/compose/install/#install-compose).
```bash
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
```
Then apply executable permissions to the binary:```bash
sudo chmod +x /usr/local/bin/docker-compose
```## Usage
To start the container
```bash
sudo docker-compose up --build
```
Does not forget to create a '.env' file with :
```bash
SECRET = "your secret"
```## AUTHENTIFICATION
Mind always to use the __"user"__ object into your request
* __POST__: localhost:8080/auth/login
```json
{
"user": {
"username": "sankamille",
"password": "password123"
}
}
```* __PUT__: localhost:8080/auth/register
```json
{
"user": {
"username": "sankamille",
"password": "password123"
}
}
```## API CALLS
Mind always to use the __"user"__ object into your request
* __GET__: localhost:8080/api/user + [Bearer auth]
```json
nothing to send
```
* __PUT__: localhost:8080/api/user + [Bearer auth]```json
{
"user": {
"username": "sankamille",
"password": "password123"
}
}
```* __POST__: localhost:8080/api/user + [Bearer auth]
```json
{
"user": {
"_id": "5bf6499c3d5ce90012a9722c"
}
}
```* __DELETE__: localhost:8080/api/user + [Bearer auth]
```json
{
"user": {
"_id": "5bf6499c3d5ce90012a9722c"
}
}
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)