This project is a code test for Camillion to evaluate my programming skills. The project consists of an API to feed a home of news about their platform. The test consists of two main user stories, one to create news and the other one to show those news in the feed.
The project has been built in NodeJS. The database has been stored in MongoDB.
Here the most important used libraries and frameworks.
Only a few things are needed to start using the project.
If you don't have node installed on your pc you should do it by downloading the installer here.
If you don't have npm installed on your pc you should do it with this command.
npm install npm@latest -g
If you don't have mongodb installed on your pc you should do it following the steps in the official guide.
- Clone the repo
git clone https://github.com/Galerix/camillion-code-test.git
- Install NPM packages in the project folder. (They are already included in the repository because I forgot to include the node_modules folder in the .gitignore but it would be convenient to run the command anyway to avoid errors.)
npm install
The API runs on port 3080 by default, and the root can be accessed by navigating to http://localhost:3080/api.
npm start
You can post a news item by making a POST request to http://localhost:3080/api/news passing it as parameters the name and the text. You need to write "admin" in the Authorization header otherwise you will not be able to post any news.
You can get all home news by making a GET request to http://localhost:3080/api/news. The news will be ordered in pages, four news will appear per page (you can change the news per page) and you can select which page of the news by adding the number to the address in this way: http://localhost:3080/api/news/2. You need to write "admin" or "user" in the Authorization header otherwise you will not be able to get any news.
The functions can be found in controllers/homenews.js
.
To make requests you can use Postman.
To ensure the quality of the project I used Mocha and Chai to perform unit tests, also I used Travis for continuous integration, you can see the builds here.
npm run test
The tests can be found in test/homenews.js
.
Distributed under the MIT License. See LICENSE
for more information.
David Galera - LinkedIn - dgalerarodriguez@gmail.com
Project Link: https://github.com/Galerix/camillion-code-test