Skip to content

Jennievon/node-rest-todo-api

Repository files navigation

Build Status Coverage Status

Express REST API

Todo REST API complete with user accounts and authentication.

Buzzwords

  • Node.js
  • Express
  • MongoDB
  • Mongoose
  • Mocha
  • REST API Design
  • Clean Arquitecture
  • Clean Code
  • JWT Authentication
  • Version control with Git

Installation

$ git clone git@github.com:AFGM/node-terminal-weather.git
$ cd node-terminal-weather
$ npm install

Usage

Write command above to create config.json.

$ echo "{\"development\": {\"PORT\": 3000, \"MONGODB_URI\": \"mongodb://localhost:27017/todoapp\",\"JWT_SECRET\": \"ultrasecret\"}}" >> server/config/config.json
$ npm start

HTTP Verbs

Here's an example of how HTTP verbs map to create, read, update, delete operations in a particular context:

HTTP METHOD POST GET PATCH DELETE
/todos Create new todo List all todos from user - -
/todos/:id - List specific todo Update todo Delete todo
/users Create user - - -
/users/me - List user informations - -
/users/login Login - - -
/users/me/token - - - Logout

Error handling

Error handling acording with REST API standards

Code Description
200 The request has succeeded
400 The request could not be understood by the server due to malformed syntax
401 The request requires user authentication. The response must include a WWW-Authenticate header field
404 The server has not found anything matching the Request-URI

Request & Response Examples

API Resources

POST /users

Request body:

{
	"email": "test@gmail.com",
	"password": "default"
}

POST /todos

Request body:

{
	"text": "Sample todo"
}

GET /todos/:id

Response body:

{
	"todo": {
		"_id": "5aa587d1cfce06ecbef0a7ae",
		"text": "Sample Todo2",
		"_creator": "5aa58675cfce06ecbef0a7a7",
		"__v": 0,
		"completedAt": null,
		"completed": false
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors