A note app made in Javascript using express-js as http server and mongodb as database. Api routes are live feel free to try out.
LINK TO WEBSITE : it's Live Here
to get this repository, run this command in your terminal
$git clone https://github.com/nikhilkrn/Note-App-Backend.git
to run this you will node js installed in your system. you can download it from https://nodejs.org/en/download
once you have downloaded node-js, open cloned repo in your IDE or code editor and run the command
$npm install
create a .env file and add your follwing data in file:
- ACCESS_TOKEN_SECRET
- ACCESS_TOKEN_EXPIRY
- PORT
- MONGOOSE_URL
now run
$node index.js
once your server is hosted, go to http://localhost:3000/users/signup
and sign up user as per here
Feel free to change or add data in db and use. Happy coding :)
POST /signup
Body Parameters
{
"username": "test1",
"password": "12345",
"email": "[email protected]"
}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
» username | body | string | yes | none |
» password | body | string | yes | none |
body | string | yes | none |
Response Examples
{
"data": "User Created successfully",
"msg": {
"username": "test1",
"password": "$2b$10$nt49U4x8mIkc88U8AbFxpOmORTVMwLcLM50PxHzdI2fzHRqRxrDca",
"email": "[email protected]",
"_id": "6784e36d85260f900e739af5",
"__v": 0
},
"statuscode": 200,
"success": true
}
{
"statuscode": 403,
"msg": "User Already Exists",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
POST /signin
Body Parameters
{
"username": "test1",
"password": "12345"
}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
» username | body | string | yes | none |
» password | body | string | yes | none |
Response Examples
{
"data": {
"user": {
"_id": "6784e36d85260f900e739af5",
"username": "test1",
"email": "[email protected]",
"__v": 0
},
"refreshtoken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3ODRlMzZkODUyNjBmOTAwZTczOWFmNSIsInVzZXJuYW1lIjoidGVzdDEiLCJlbWFpbCI6ImhlbGxvMUB0ZXN0LmNvbSIsImlhdCI6MTczNjc2MjI0OCwiZXhwIjoxNzM3NjI2MjQ4fQ.qAQaawINuFFLj_JYaMuMiJtn-wetEWNTU_tsymcng8I"
},
"msg": "loggedin successfully",
"statuscode": 200,
"success": true
}
{
"statuscode": 403,
"msg": "user not found",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
POST /signout
Body Parameters
{}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
Response Examples
{
"data": {
"user": "User Logged Out"
},
"msg": "logged Out successfully",
"statuscode": 200,
"success": true
}
{
"statuscode": 403,
"msg": "Unauthorized request",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
POST /addnote
Body Parameters
{
"title": "first Note",
"description": "first note added"
}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
» title | body | string | yes | none |
» description | body | string | yes | none |
Response Examples
{
"data": {
"data": {
"title": "first Note",
"description": "first note added",
"createdBy": "test1",
"_id": "6784e39685260f900e739b04",
"createdAt": "2025-01-13T09:57:42.763Z",
"updatedAt": "2025-01-13T09:57:42.763Z",
"__v": 0
}
},
"msg": "Note Added Successully",
"statuscode": 201,
"success": true
}
{
"statuscode": 403,
"msg": "Task already present",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
PUT /updatenote/6784e39685260f900e739b04
copy id from _id from db and paste insted of 678405d71b160d180218a310 which is params
Body Parameters
{
"title": "first Note",
"description": "first note added"
}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
» title | body | string | yes | none |
» description | body | string | yes | none |
Response Examples
{
"data": {
"title": "first Note",
"description": "first note added"
},
"msg": "Task Updated Successfullt",
"statuscode": 201,
"success": true
}
{
"statuscode": 403,
"msg": "Note Not Found",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
GET /getnotes
Response Examples
{
"data": {
"Notes": [
[
"Title: first Note",
"Description: first note added",
"Created By: test1"
]
]
},
"msg": "Fetched All Todos",
"statuscode": 200,
"success": true
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
DELETE /delete
Body Parameters
{
"title": "first Note",
"_id": "6784e39685260f900e739b04"
}
Name | Location | Type | Required | Description |
---|---|---|---|---|
body | body | object | no | none |
» title | body | string | yes | none |
» _id | body | string | yes | none |
Response Examples
{
"data": {
"_id": "6784e39685260f900e739b04",
"title": "first Note",
"description": "first note added",
"createdBy": "test1",
"createdAt": "2025-01-13T09:57:42.763Z",
"updatedAt": "2025-01-13T09:58:18.651Z",
"__v": 0
},
"msg": "Note Deleted",
"statuscode": 200,
"success": true
}
{
"statuscode": 403,
"msg": "Something went wrong",
"errors": [],
"success": false,
"data": null
}
HTTP Status Code | Meaning | Description | Data schema |
---|---|---|---|
200 | OK | none | Inline |
Feel free to change or add data in db and use. Happy coding :)