/TodoKernel

TodoKernel is an API ready to go allowing you to create todolists. #api

Primary LanguageJavaScriptMIT LicenseMIT

TodoKernel

You want to create a todolist app without bothering too much with a backend code. Here's how TodoKernel can help you! ๐Ÿ˜ƒ

TodoKernel is an API ready to go allowing you to create todolists. Then all you have to do is to create a sweat little UI that fit your need! ๐Ÿ˜Š


Index ๐Ÿ“–


Installation

Make sure that node and MongoDb are installed on your machine/server ๐Ÿ˜‰

  1. The very first step is to install is to fetch the TodoKernel project. To do so, you can:

    Clone the project via git, by running the following command:

    git clone https://github.com/bricefriha/TodoKernel.git 

    If you don't have git installed you can still download the project.

  2. Next you'll have to install all the required npm packages. Thus, move to the TodoKernel folder an run this command:

    npm install 
  3. Then, to make sure to get access to the project config, rename config-dist to config

  4. Now all you have to do is starting your app

    npm start 
  5. Finally, the most important part: Enjoy! ๐Ÿ˜€


Dependencies ๐Ÿงท

  • Express: Node version

  • Jwt: Node version

  • Mongoose Node version

  • nodemailer Node version


Api methods

Registration ๐Ÿ”‘

Request type: POST

route: "/users/register"

body:

{
    "firstName": "BriceFriha",
    "lastName": "BriceFriha",
    "username": "BriceFriha",
    "email": "brice.friha@email.com",
    "password": "pwd"
}

response:

{
    "username": "BriceFriha",
    "firstName": "BriceFriha",
    "lastName": "BriceFriha",
    "email": "brice.friha@email.com",
    "todolists": [
    ],
    "token": "<your token>"
}

Authentification ๐Ÿ™‹๐Ÿฝโ€โ™‚๏ธ๐Ÿ™‹๐Ÿฝโ€โ™€๏ธ

Request type: POST

route: "/users/authenticate"

body:

{
    "username": "BriceFriha",
    "password": "pwd"
}

with an email

{
    "email": "brice.friha@email.com",
    "password": "pwd"
}

response:

{
    "username": "BriceFriha",
    "firstName": "BriceFriha",
    "lastName": "BriceFriha",
    "todolists": [
       
    ],
    "token": "<your token>"
}

Update user's informations ๐Ÿ™๐Ÿฝโ€โ™‚๏ธ๐Ÿ™๐Ÿฝโ€โ™€๏ธโœ๐Ÿฝ

โš  You must use a bearer token to perform this action

Request type: PUT

route: "/users/register"

body:

{
	"username": "JustinC",
	"firstName": "Justin",
	"lastName": "Case",
        "email": "brice.friha@email.com",
    	"newPassword": "TheNewPassword",
	"password": "TheOldPassword"
	
}

โ„น If you don't want to modify the password, just don't fill the "newPassword" field

response:

{
    "status": "OK",
    "result": "Changes saved"
}

Get user's informations ๐Ÿ™๐Ÿฝโ€โ™‚๏ธ๐Ÿ™๐Ÿฝโ€โ™€๏ธ

โš  You must use a bearer token to perform this action

Request type: GET

route: "/users/current"

body:

{
	"username": "JustinC",
	"firstName": "Justin",
	"lastName": "Case",
	"password": "pass"
	
}

Send email to recover a password ๐Ÿ“ฉ๐Ÿ”‘

Request type: POST

route: "/users/forgot"

Body:

{
	"email": "brice.friha@outlook.com"
	
}

Response:

{
    "status": "OK"
}

Change a forgotten password ๐Ÿ‘‰๐Ÿฝ๐Ÿ”‘

Request type: PUT

route: "/users/recovery"

Body:

{
	"recoveryCode": "[recovery code sent via email]",
    "newPassword": "pwd"
}

โ„น it's worth noting that the user is automatically connected after this action

Response:

{
    "username": "BriceFriha",
    "email": "brice.friha@outlook.com",
    "firstName": "Brice",
    "lastName": "Friha",
    "todolists": [
        {
            "items": [
                "5ee0eb0dc551c20d74674086"
            ],
            "_id": "5ee0eaf2c551c20d74674085",
            "title": "Shopping list",
            "user": "5ee0e25556294c2c70ee128b",
            "__v": 1
        }
    ],
    "token": "<your token>"
}

Delete current user ๐Ÿ—‘๐Ÿ™๐Ÿฝโ€โ™‚๏ธ๐Ÿ™๐Ÿฝโ€โ™€๏ธ

โš  You must use a bearer token to perform this action

Request type: DELETE

route: "/users/current"

response:

{
    "status": "OK",
    "result": " deleted"
}

Create a todolist ๐Ÿ“

โš  You must use a bearer token to perform this action

Request type: POST

route: "/todolists/create"

body:

{
	"title":"Shopping list"
}

response:

{
    "items": [],
    "_id": "5ed7f3d335670f2f348c8cbc",
    "title": "Shopping list",
    "user": "5ecd5cb5048a7231d8ddbb15",
    "__v": 0
}

Add an item to a todolist โœ

โš  You must use a bearer token to perform this action

Request type: POST

route: "/todos/add"

body:

{
	"name":"Eggs",
	"todolistId": "5ed7f3d335670f2f348c8cbc"
}

response:

{
    "_id": "5ed7f43f35670f2f348c8cbd",
    "name": "Eggs",
    "done": false,
    "todolist": "5ed7f3d335670f2f348c8cbc",
    "user": "5ecd5cb5048a7231d8ddbb15",
    "order": 0,
    "__v": 0
}

Delete an item from a todolist ๐Ÿ—‘โœ

โš  You must use a bearer token to perform this action

Request type: DELETE

route: "/todos/[item id]"

response:

{
    "status": "OK",
    "result": " deleted"
}

Get all your todolists ๐Ÿ“š

โš  You must use a bearer token to perform this action

Request type: GET

route: "/todolists/"

response:

[
    {
        "items": [
 	],
        "_id": "5ed385135151de45f4b637df",
        "title": "Shopping list",
        "user": "5ecd5cb5048a7231d8ddbb15",
        "order": 0,
        "__v": 2
    },
    {
        "items": [
        ],
        "_id": "5ed7f3d335670f2f348c8cbc",
        "title": "Shopping list",
        "user": "5ecd5cb5048a7231d8ddbb15",
        "order": 1,
        "__v": 1
    }
]

Check or uncheck a todolist item โœ…โŽ๐Ÿ“„

โš  You must use a bearer token to perform this action

Request type: PUT

route: "/todos/Check/[item id]"

response:

{
    "status": "OK"
}

Get all items of a todolist

โš  You must use a bearer token to perform this action

Request type: GET

Route: "/todos/get"

Body:

{
    "todolistId": "[todolist in which you want to put it]"
	
}

Move a todolist item ๐Ÿ“„ โ†•

โš  You must use a bearer token to perform this action

Request type: PUT

Route: "/todos/move/[Todolist id]"

Body:

{
	"newPosition": "[the new position (order attribut)]",
    "todolistId": "[todolist in which you want to put it]"
	
}

Response:

{
	"name": "Fries"	
}

Rename a todolist item โœ๐Ÿฝ๐Ÿ“„

โš  You must use a bearer token to perform this action

Request type: PUT

Route: "/todos/rename/[Todolist id]"

Body:

{
	"name": "Fries"
}

Response:

{
	"name": "Fries"	
}

Delete a todolist ๐Ÿ—‘๐Ÿ“š

โš  You must use a bearer token to perform this action

Request type: DELETE

route: "/todolists/[Todolist id]"

response:

{
    "status": "OK",
    "result": " deleted"
}

Rename a todolist โœ๐Ÿฝ๐Ÿ“š

โš  You must use a bearer token to perform this action

Request type: PUT

Route: "/todolists/rename/[Todolist id]"

Body:

{
	"title": "Workout"
	
}

Response:

{
    "items": [
        
    ],
    "_id": "5ed7f3d335670f2f348c8cbc",
    "title": "Workout",
    "user": "5ecd5cb5048a7231d8ddbb15",
    "__v": 2
}

Delete a todolist ๐Ÿ—‘๐Ÿ“š

โš  You must use a bearer token to perform this action

Request type: DELETE

route: "/todolists/[Todolist id]"

response:

{
    "status": "OK",
    "result": " deleted"
}

Delete all current's user todolists ๐Ÿ—‘๐Ÿ“š๐Ÿ“š๐Ÿ“š๐Ÿ“š

โš  You must use a bearer token to perform this action

Request type: DELETE

route: "/users/cleanup"

response:

{
    "status": "OK",
    "result": " deleted"
}