This API is designed using multiple layers:
API
: Presentation Layer (Routes and Controllers).Service
: Layer with all the business logic.DAL (Data Access Layer)
: This layer separates access to data sources (databases). Use a type ofRepository Pattern
, trying to maintain a common interface to theservice layer
, allowing if necessary change the database engine (for example: changeMongoDB
forMySQL
)Shared
: This layer contains modules common to all layers, such as anhttp client
and thelogger
Of course
this is a beginning. A good idea is to add a central layer called Domain
, with all the business logic, and create models
for each layer. In other words, try to apply a full
Clean Architecture` https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
- Clone this repo using
git clone https://github.com/wchopite/settle-challenge.git
- Rename the file
.env.example
to.env
and setup the environment vars - Install the dependencies with
npm install
- Create the databases you have setup on
step 2
- Run the application in development mode with
npm run start:dev
- Access
http://localhost:8080/
Each request to the API must include the following headers:
Content-Type: "application/json"
- Create a rate from the default provider (
fixerio
) using the/api/provider_rates
endpoint - To create an custom rate (rate with a custom fee)
Check the future
swagger doc
/api/docs
for more information
This repo comes with some npm scripts, you will run them with npm run <script name>
:
start
Run the application in production modestart:dev
: Run the application in development modelint
: Lint the codebasetest
: Run the all test suitecoverage
: Run the coverage using nycverify
: Run thelint
andtest
command
For testing, mocha
, chai
, and supertest
are used
(Pending
)
If you wish, you can run the app using Docker and Docker Compose. For this, you need:
Install Docker
: https://docs.docker.com/compose/install/Install Docker Compose
: https://docs.docker.com/compose/install/
Once you have installed them, in the root folder of the project you need to run docker-compose up
. This command generate the containers with the node app and mongo database. Then you can test it using an application like Postman (for example)
(Pending
)
This API will use swagger for the documentation of endpoints. To access this (in future
), you just need to start the server and then access http://server:port/api/docs
, for example: http://localhost:8080/api/docs
- Global health check: http://ec2-3-134-92-245.us-east-2.compute.amazonaws.com:8080/
- Swagger API Documentation:
aws code deployed, docs endpoint
(Pending)
- Add unit and integration
test
- Add input validation on endpoints using
joi
https://hapi.dev/family/joi/ - To improve
error management
- To improve
coverage
withnyc
lib - Add a new command to run in a separate way the
unit
andintegration
test - Allow pagination in the endpoints
- Create a separate file for the
server
- Add files configuration to
CI/CD
(codeship, google cloud build...) - To improve the abstraction on the repositories (DAL layer, access to database) and define a better interface to the
service layer
- To improve management dependencies, using for example an
IoC (Inversion of Control) container
, like:awilix
,bottlejs
,inversify