This repository houses code for Todo List's backend.
This is a RESTful API for a todo list. Part of an assessment for Spoke.AI. It allows a user to:
- Register a new account.
- Log in to the created account.
- Create a todo item (Auth protected)
- List all todo items in paginated manner and optionally filter the results based on status (created, in-progress, completed)
- Update a todo item (Auth protected)
- Delete a todo item (Auth protected)
.
├── ...
├── .husky # husky configuration file
│ ├── pre-commit # git pre-commit commands
├── data # seed data
├── src # source files
│ ├── __tests__ # folder containing automated tests
│ ├── config # Configuration files, database etc
│ ├── controllers # app business logic files
│ ├── helpers # helper functions
│ ├── middlewares # app middleware and route middlewares
│ ├── models # models/ entities
│ ├── routes # routes for navigating the application
│ ├── app.ts # express application
│ ├── index.ts # entry file- server file
├── .env.example # example environment file
├── .eslintignore # eslint ginore file
├── .eslintrc.json # eslint configuration file
├── .gitignore # gitginore file
├── .prettierignore # prettier ginore file
├── .prettierrc.json # prettier configuration file
├── jest.config.js # jest configuration file
├── package.json # application configuration
├── README.md # this file!!
├── tsconfig.json # typescript configuration file
└──Each response will be returned with one of the following HTTP status codes:
200OKThe request was successful400Bad RequestThere was a problem with the request (security, malformed)401UnauthorizedThe supplied API credentials are invalid404Not FoundAn attempt was made to access a resource that does not exist in the API500Server ErrorAn error on the server occurred
The API response, to the best of my ability, is structure after JSEnd specifications.
- For a
successresponse, the server will return a response of this format:
{
"status": "success",
"message": "success message from the API server"
"data": { ... }
}
- For an
errorresponse, the server will return a response of this format. Thetracekey in theerrorobject is returned ifNODE_ENV !== production.
{
"status": "error",
"error": {
"message": "error message from the API server",
"trace": {
"statusCode": <status-code>
}
}
}
This project uses Express.js v4.17. It has the following dependencies:
This project is hosted on Github. You can clone this project directly using this command:
git clone https://github.com/mykoman/spoke-dot-ai-backend-challenge-todo-list.git- Create two PostgreSQL database by running the
cmdbelow one for the main database and the other for test database:
psql
CREATE DATABASE <database_name>
CREATE DATABASE <test_database_name>- After cloning the repository, create a
.envfile from.env.exampleand set your local.env.variable(s).
cp .env.example .env- Install the dependencies
npm install- Run Development server
npm run devTo run tests, run
npm test