Coder Social home page Coder Social logo

geezer686 / docker-fastify-restful-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinceladasdaweb/docker-fastify-restful-api

0.0 0.0 0.0 3.64 MB

Node.js RESTful API boilerplate using Traefik, Docker, Docker Compose, Fastify, JWT and Mongodb

License: MIT License

JavaScript 95.91% Makefile 2.32% Dockerfile 1.77%

docker-fastify-restful-api's Introduction

Docker Fastify RESTful API

Node.js RESTful API boilerplate using Traefik, Docker, Docker Compose, Fastify, JWT and Mongodb.

Requirements

  1. Node.js >= 16
  2. Docker
  3. Docker compose

Getting started

Install packages using docker:

docker run --rm -it \
-v ${PWD}:/usr/src/app \
-w /usr/src/app \
node:16-alpine npm i

Windows users should switch the PWD variable to your current directory. Alternatively, you can run npm install as follows:

docker-compose run --rm api npm install

Or if you have node installed in your system, install using npm:

npm install

Configuration

  1. Rename the .env.example file to .env and fill variables. The Postgres variables are required for Sonarqube. The SENTRY_DSN variable is not obligatory.

  2. Edit your hosts file with:

127.0.0.1 fastify.localhost

127.0.0.1 sonarqube.localhost

Run

In the root of project, run:

docker-compose up

API Request

Endpoint HTTP Method Description
/api/v1 GET Healthcheck
/api/v1/users/register POST Adds a new user
/api/v1/users/auth POST Authenticate user
/api/v1/movies GET List all movies
/api/v1/movies/:id GET Get movie
/api/v1/movies POST Adds a new movie
/api/v1/movies/:id PATCH Update a movie
/api/v1/movies/:id DELETE Delete a movie

Test API locally using curl

  • Healthcheck

Request

curl -i --request GET 'http://fastify.localhost/api/v1'

Response

{
  "message": "Fastify API is on fire"
}

Insominia Collection

I exported Insomnia collection/data for so you can test all the endpoints.

Sonarqube dashboard

To access Sonarqube dashboard, simple access in your browser:

http://sonarqube.localhost

Follow the guide to learn more about the settings and how to run Sonar code analysis.

Traefik dashboard

To access Traefik dashboard, simple access in your browser:

http://localhost:8080

Infrastructure model

Infrastructure model

Happy coding!

docker-fastify-restful-api's People

Contributors

pinceladasdaweb avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.