TO-DO api
TO-DO api is a simple api that lets you create unlimited tasks which can help you to plan, track and get more tasks done.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Here are the environment prerequisites for the web app
- NodeJS
- Postgress
- Docker
A step by step series of examples that tell you how to get a development env running
Say what the step will be
- Clone the repository
- Copy .env.example to .env then correct change the corresponding variables
- Run
npm installto install node packages - Run
npm run migrateto setup models in Database - Run
npm run devto start the web app
- Clone the repository
- Copy .env.example to .env then correct change the corresponding variables
- Run
npm installto install node packages - RUN
npm run test
- Clone the repository
- Copy .env.example to .env then correct change the corresponding variables
- Run
npm installto install node packages - RUN
npm run devto start the appp in development - browse to
localhost:[PORT]/api-doc
- Clone the repository
- Copy .env.example to .env then correct change the corresponding variables
To spin up all containers and running the application, use docker-compose up. After pulling new changes, containers might be deprecated and you are required to execute docker-compose up --build for spinning up containers and run the application or docker-compose build --no-cache for re/building new containers with no cache.
To run a migration/seed, conect first to the api-server by execuring docker-compose run --rm api-server sh. Once you are in, you can run a sequelize command such as npx sequelize db:migrate to migrate all the modeld and then start the app using npm run dev.
For better testing the application, spin up the api-testing server by execuring docker-compose run --rm test-api-server sh. Once you are in, you can execute any testing command such as ``npm run test`. It is not recommended to test under api-server container.
Using Postman to access these endpoints
| Endpoint | Methods | Functionalities | Authentication required |
|---|---|---|---|
| /api/v1/auth/login | POST | Login a User | No |
| /api/v1/auth/register | POST | Register for a User | NO |
| /api/v1/todos/ | GET | Fetch all Todo Items | YES |
| /api/v1/todos/ | POST | Add new Todo item | Yes |
/api/v1/todos/<todo_id> |
GET | Fetch One todo Item | NO |
/api/v1/todos/<todo_id> |
PUT | update Item info | YES |
/api/v1/todos/<todo_id> |
DELETE | Delete a Todo Item | YES |
- Javascript as a language
- NodeJS / Express backend Framework
- Postgress as Database Engine
- Mocha and Chai for testing
- Travis CI for continuos integration
- nyc for test coverage
The server runs on Node.js with Express.js as its main framework. Compared to the front end, the server contains various folders that are explained as follow:
/src/configsfor system configuration files. In most of cases you will not need to work with that folder as all configs are stored in the/src/.envfile./src/controllersholds all business logic. It is coupled to the API through/src/routerfolder./src/utilscontains reusable code such as functions./src/modelscontains System models./src/routerscontains API endpoints./testscontains both unit test and integration tests. It is composed of two packages that are "unit" for unit test integration for "integration" test.
The database package contains migrations and seeds. Refer to Sequelize official documentation (v5) to learn more about it.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Nshimyumukiza Christian
This project is licensed under the MIT License - see the LICENSE.md file for details