Link to front end
This is the backend of the Notefy app. It is a simple note taking app that allows users to create, edit, and delete notes.
- Download the repo
- Run
npm installto install the required packages - Add the .env variable in file
- Run
npm startto start the server - Open http://localhost:5000/ to view the API
For registration and login, use the following endpoints:
Register User:
-
POST /api/v2/auth/register- will register a new userWith the following body:
{ "name":"[username]", "email":"[email]", "password":"[password]" }We will return the following object if successful:
{ "user": { "name": "[username]", "email": "[email]", "theme": "dark" }, "token": "xxx" }Currently we only support registering with email and password.
We support two themes:
darkandlight.
Login User:
-
POST /api/v2/auth/login- will login a userWith the following body:
{ "email":"[email]", "password":"[password]" }We will return the following object if successful:
{ "user": { "name": "[username]", "email": "[email]", "theme": "dark" }, "token": "xxx" }
Update User:
-
PATCH /api/v2/auth/user- will update a userAuthentication bearer token in header needed
With the following body:
{ "name": "[username]", "email":"[email]", "password":"[password]" }We will return the following object if successful:
{ "user": { "name": "[username]", "email": "[email]", "theme": "dark" }, "token": "xxx" }Delete User:
-
DELETE /api/v2/auth/user- will update a userAuthentication bearer token in header needed
With the following body:
{ "password":"[password]" }We will return the following object if successful:
{ "msg": "[username] deleted" }
Create File:
-
POST /api/v2/file- will create a fileAuthentication bearer token in header needed
With the following body:
{ "name":"test", "type":"folder", "path": "" }We will return the following object if successful:
{ "folder": { "folder": { "name": "test", "tags": [], "path": [""], "color": "amber", "createdBy": "[user]", "_id": "[id]", "createdAt": "[Time]", "updatedAt": "[Time]", "__v": 0 } } }For file type we only have
folderandnote.For path if you want to create a folder or note at root then path as empty string, else path should the path of the folder preceded by a
/.- In root =
{path: ""} - In folder1 =
{path: "/folder1"} - In folder1 in folder2 =
{path: "/folder1/folder2"}
- In root =
Get File At Root:
-
GET /api/v2/file- will get all files at root folder.Authentication bearer token in header needed
We will return the following object if successful:
{ "folders": [ { "_id": "[id]", "name": "work", "tags": [], "path": [""], "color": "amber", "createdBy": "[user]", "createdAt": "[Time]", "updatedAt": "[Time]", "__v": 0 } ], "notes": [], "count": { "folders": 1, "notes": 0 } }foldersandnotesare arrays of folder and notes.
Get File:
-
GET /api/v2/file/:id- will get the file based onid.Authentication bearer token in header needed
For
folderswe will return the folder datails and the list of folders and notes under the folder.For
noteswe will return the note details.
Update File:
-
PATCH /api/v2/file/:id- will update the file based onid.Authentication bearer token in header needed
The file URL decides the type of file to update. The propeties of the update are based on the type of file.
- For
folderwe will update the foldername,tagsandcolor. - For
notewe will update the notetitle,data,tagsandpath.
- For
Delete File:
-
DELETE /api/v2/file/:id- will delete the file based onid.Authentication bearer token in header needed
We will return the following object if successful:
{ "result": { "status": "success", "msg": "Note Deleted" } }