This repository contain backend and frontend. A Study Connect is a place to share your own notes and read other notes at the same time.
- Frontend: React.js
- Backend: Node.js with Express.js
- Database: MariaDB/MySQL2
Feature | Description |
---|---|
login/register | signup and login to Study Connect |
show all notes | show all note that the user wrote |
view note | view details of the note |
shared notes | show all note that other users wrote |
create note | create a note with a title and description |
edit note | edit the details of note |
delete note | remove the note |
cd to frontend then run.
npm install
then use
npm run dev
cd to backend then run.
npm install
then use
nodemon index.js
Parameter | Type | Description |
---|---|---|
success | boolean | the status of request |
msg | string | message for each request |
data | JSON | the actual data |
POST /auth/login
Parameter | Type | Description |
---|---|---|
String | ||
password | String | password must be at least 8 characters with uppercase letter, lowercase letter and number. |
Example
{
"email" : "nonsomroop@gmail.com",
"password" : "Non12345"
}
Response
200
login success
Parameter | Type | Description |
---|---|---|
String | user email | |
username | String | username |
id | String | user id |
Example
{
"success": true,
"message": "login success",
"user": {
"id": 8,
"email": "nonsomroop@gmail.com",
"first_name": "Non",
"last_name": "Somroop",
"is_admin": 0,
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...E"
}
noted: If success, the Response will be sent with cookie named UserToken
POST /auth/register
Parameter | Type | Description |
---|---|---|
firstname | String | firstname |
lastname | String | surname |
String | ||
password | String | password |
Example
{
"firstname":"Non",
"lastname":"Somroop",
"email":"nonsomroop@gmail.com",
"password" : "Non12345"
}
200
register success
no response body
GET /auth/checklogin
Parameter | Type | Description |
---|---|---|
user | String | decode token of user |
Example
{
"user":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...E"
}
Response
200
"User is logged in with ID: " + decoded.userId
GET /user/:userId
Parameter | Type | Description |
---|---|---|
userId | int | Id of user |
200
got data
Parameter | Type | Description |
---|---|---|
id | int | user id |
String | user email | |
firstname | String | first name |
lastname | String | surname |
Example
{
"id": 8,
"email": "nonsomroop@gmail.com",
"first_name": "Non",
"last_name": "Somroop",
"is_admin": 0,
}
GET /note/notes/:userId
No Request Body
200
found notes
Response
Parameter | Type | Description |
---|---|---|
no parameter | Array of note | all notes related to user |
the note object
Parameter | Type | Description |
---|---|---|
id | string | id of note |
title | string | note title |
content | string | note description |
createdAt | DateTime | create Time |
updatedAt | DateTime | latest updated time |
Example
[
{
"id": 7,
"user_id": 7,
"title": "ewww",
"content": "wwwwwwww",
"created_at": "2023-05-20T07:17:01.000Z",
"updated_at": "2023-05-20T07:17:01.000Z"
},
{
"id": 11,
"user_id": 7,
"title": "My db chai mai dai",
"content": "mai whai leaw",
"created_at": "2023-05-21T00:37:22.000Z",
"updated_at": "2023-05-21T00:37:22.000Z"
},
...
]
get note by id
GET /note/:noteId
Parameter | Type | Description |
---|---|---|
noteId | String | id of note |
No Request Body
Response
200
success
Parameter | Type | Description |
---|---|---|
id | string | id of note |
user_id | string | id of user |
title | string | note title |
content | string | note description |
updatedAt | DateTime | latest updated time |
createdAt | DateTime | create Time |
Example
{
"id": 7,
"user_id": 7,
"title": "ewww",
"content": "wwwwwwww",
"created_at": "2023-05-20T07:17:01.000Z",
"updated_at": "2023-05-20T07:17:01.000Z"
}
PATCH /note/notes
Parameter | Type | Description |
---|---|---|
noteId | string | id of note |
title | string | note title |
content | string | note description |
Response
200
success
Parameter | Type | Description |
---|---|---|
id | string | id of note |
title | string | note title |
content | string | note description |
updatedAt | DateTime | latest updated time |
createdAt | DateTime | create Time |
Example
{
"id": 7,
"user_id": 7,
"title": "ewww",
"content": "wwwwwwww",
"created_at": "2023-05-20T07:17:01.000Z",
"updated_at": "2023-05-20T07:17:01.000Z"
}
POST /note/
Parameter | Type | Description |
---|---|---|
title | string | note title |
content | string | note description |
Response
200
success
Parameter | Type | Description |
---|---|---|
id | string | id of note |
title | string | note title |
content | string | note description |
updatedAt | DateTime | latest updated time |
createdAt | DateTime | create Time |
Example
{
"id" : "1",
"title" : "Note1",
"content" : "today is a good day",
"updatedAt" : "2023-04-25T14:58:58.264Z",
"createdAt" : "2023-04-25T14:58:58.264Z",
}
DELETE /note/:noteId
Parameter | Type | Description |
---|---|---|
noteId | String | id of note |
No Request Body
Response
200
delete success
no response body
GET /note/sharednotes
No Request Body
200
found notes
Response
Parameter | Type | Description |
---|---|---|
no parameter | Array of shared note | all notes related to other user |
the note object
Parameter | Type | Description |
---|---|---|
id | string | id of note |
title | string | note title |
content | string | note description |
createdAt | DateTime | create Time |
updatedAt | DateTime | latest updated time |
Example
[
{
"id": 1,
"user_id": 1,
"title": "Database Design",
"content": "Introduction to database design...",
"created_at": "2023-05-08T10:08:57.000Z",
"updated_at": "2023-05-08T10:08:57.000Z"
},
{
"id": 2,
"user_id": 2,
"title": "Object-Oriented Programming",
"content": "Fundamentals of OOP...",
"created_at": "2023-05-08T10:08:57.000Z",
"updated_at": "2023-05-08T10:08:57.000Z"
},
{
"id": 3,
"user_id": 3,
"title": "Web Development",
"content": "HTML, CSS, JavaScript...",
"created_at": "2023-05-08T10:08:57.000Z",
"updated_at": "2023-05-08T10:08:57.000Z"
},
{
"id": 4,
"user_id": 4,
"title": "Data Structures",
"content": "Arrays, Linked Lists, Trees...",
"created_at": "2023-05-08T10:08:57.000Z",
"updated_at": "2023-05-08T10:08:57.000Z"
},
{
"id": 5,
"user_id": 5,
"title": "Algorithms",
"content": "Sorting, Searching, Graph Algorithms...",
"created_at": "2023-05-08T10:08:57.000Z",
"updated_at": "2023-05-08T10:08:57.000Z"
},
{
"id": 6,
"user_id": 6,
"title": "My New Note",
"content": "This is a sample note.",
"created_at": "2023-05-20T06:51:16.000Z",
"updated_at": "2023-05-20T06:51:16.000Z"
},
{
"id": 7,
"user_id": 7,
"title": "ewww",
"content": "wwwwwwww",
"created_at": "2023-05-20T07:17:01.000Z",
"updated_at": "2023-05-20T07:17:01.000Z"
},
{
"id": 11,
"user_id": 7,
"title": "My db chai mai dai",
"content": "mai whai leaw",
"created_at": "2023-05-21T00:37:22.000Z",
"updated_at": "2023-05-21T00:37:22.000Z"
},
{
"id": 19,
"user_id": 10,
"title": "CSC105",
"content": "Bye",
"created_at": "2023-06-01T07:08:43.000Z",
"updated_at": "2023-06-01T07:08:43.000Z"
}
]