Skip to content

Galerix/camillion-code-test

Repository files navigation

CAMILLION CODE TEST

Table of Contents

About The Project

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.

Built With

The project has been built in NodeJS. The database has been stored in MongoDB.

Here the most important used libraries and frameworks.

Getting Started

Only a few things are needed to start using the project.

Prerequisites

  • Node

If you don't have node installed on your pc you should do it by downloading the installer here.

  • npm

If you don't have npm installed on your pc you should do it with this command.

npm install npm@latest -g
  • MongoDB

If you don't have mongodb installed on your pc you should do it following the steps in the official guide.

Installation

  1. Clone the repo
git clone https://github.com/Galerix/camillion-code-test.git
  1. 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

Usage

The API runs on port 3080 by default, and the root can be accessed by navigating to http://localhost:3080/api.

npm start

User Stories

Post a news item

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.

Get home 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.

Tests

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.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

David Galera - LinkedIn - dgalerarodriguez@gmail.com

Project Link: https://github.com/Galerix/camillion-code-test

Acknowledgements

About

Backend code test for camillion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published