- Clone this repo using
git clone https://github.com/wchopite/workast_challenge.git
- Rename the file
config/database.example.js
toconfig/database.js
and setup the database - 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
config/database.js
- Run the application in development mode with
npm run start:dev
- Access
http://localhost:8080/api/users
The API validates a token sent in the headers. This token must be configured in the .env file (step number 3
). Each request to the API must include the following headers (including the Authorization header):
Content-Type: "application/json"
Authorization: "Bearer 5CD4ED173E1C95FE763B753A297D5"
- Create an user using the
/api/users
endpoint - Use the id from of the recently created user, and create an article
Check the 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 test suite
For testing, mocha
, chai
, and supertest
are used
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 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)
This API uses swagger for the documentation of endpoints. To access this, 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: https://workast-challenge.herokuapp.com/
- Swagger API Documentation: https://workast-challenge.herokuapp.com/api/docs/
- Add more
test
and improve the current test configuration - Make unit test using
mongodb-memory-server
,sinon
if necessary - Add input validation on endpoints using
ajv
https://www.npmjs.com/package/ajv, and generate the docs from this point (this can allow to deleteswagger docs
) - Maybe is a good idea to remove the
structure package
fordomain objects
and find a way to use the sameajv
to validate them - Use
nyc
forcoverage
- Add a
cache layer
withredis
- Separate in multiple files
express error middleware
. Create custom errors - Allow to add a token to the swagger documentation (while still it use)
- Add files configuration to
CI/CD
(codeship, google cloud build, etc)