This is REST API server for ddat-hmm project.
- Save ddat-hmm data of user, friend(following / follower), and message(sent / received)
- REST API for CRUD in ddat-hmm
This is how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
- npm
npm install npm@latest -g
- Postgres Server
Available to replace another server instead of postgres server. See typeorm documents for connection server.
- Run Postgres
psql -U userName
- Clone the repository
git clone https://github.com/jyuunnii/hmm-server.git
- Change current directory to the project directory
- Install npm packages
npm install
- Run server
npm start
Success to installation writes
App Listening on PORT [port_number] DB connected !
on your terminal.
POST /auth/login
🔹GET /user
🔸GET /user/name?:name
🔸GET /user/:id
🔸POST /user
🔹PATCH /user/:id
🔹DELETE /user/:id
🔺GET /follow/:id
🔸POST /follow/:id
🔹DELETE /follow/:id
🔺GET /message/:id
🔸POST /message/:id
🔹
URI | Method | Description |
---|---|---|
/auth/login |
POST |
Validate if email and password are correct |
- Request Parameter :
Not Required
- Request Body :
{
"email" : "user email",
"password" : "user password"
}
- Response :
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
URI | Method | Description |
---|---|---|
/user |
GET |
Get a list of all users private data in the service |
- Request Parameter :
Not Required
- Request Body :
Not Required
- Response :
[
{
"id": "user id in Postgres DB",
"name": "user name",
"email": "user email",
"profileImageUri": "user profile image URI and default image is /images/person.png",
"backgroundImageUri": "user background image URI",
"comment": "user comment",
"createdAt": "creation date (type: timestamp)",
"updatedAt": "update date (type : timestamp)"
},
]
URI | Method | Description |
---|---|---|
/user/name?:name |
GET |
Get a list of all users public data by user name |
- Request Parameter :
user_name
- Request Body :
Not Required
- Response :
[
{
"id": "user id in Postgres DB",
"name" : "user name",
"email" : "user email",
"profileImageUri" : "user profile image URI and default image is /images/person.png",
"backgroundImageUri" : "user background image URI",
"comment" : "user comment",
"createdAt": "creation date (type: timestamp)",
"updatedAt": "update date (type : timestamp)"
},
]
URI | Method | Description |
---|---|---|
/user/:id |
GET |
Get a specific user public data by user id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
Not Required
- Response :
{
"id" : "user id in Postgres DB",
"name" : "user name",
"profileImageUri" : "user profile image URI and default image is /images/person.png",
"backgroundImageUri" : "user background image URI",
"comment": "user comment"
}
URI | Method | Description |
---|---|---|
/user |
POST |
Create a new user in the service |
- Request Parameter :
Not Required
- Request Body :
{
"name": "user name",
"email" : "user email",
"password" : "user password",
"profileImageUri": "user profile image URI and default image is /images/person.png",
"backgroundImageUri": "user background image URI",
"comment": "user comment (optional)"
}
- Response :
{
"User Created !"
}
URI | Method | Description |
---|---|---|
/user/:id |
PATCH |
Modify some of specific user data by user id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
Not Required
Input need_to_be_modified fields.
- Response :
{
"User data modified !"
}
URI | Method | Description |
---|---|---|
/user/:id |
DELETE |
Delete a specific user in the service by user id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
Not Required
Input need_to_be_modified fields.
- Response :
{
"User deleted !"
}
URI | Method | Description |
---|---|---|
/follow/:id |
GET |
Get a list of following-user and follower-user by user id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
Not Required
- Response :
{
"following":[
{
"id" : "user id in Postgres DB",
"name" : "user name",
"profileImageUri" : "user profile image URI and default image is /images/person.png",
"backgroundImageUri" : "user background image URI",
"comment": "user comment"
},
],
"follower": [
{
"id" : "user id in Postgres DB",
"name" : "user name",
"profileImageUri" : "user profile image URI and default image is /images/person.png",
"backgroundImageUri" : "user background image URI",
"comment": "user comment"
},
]
}
URI | Method | Description |
---|---|---|
/follow/:id |
POST |
Add a new following-user into following list |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
{
"followingName" : "user name who wish to follow"
}
- Response :
{
"New followed !"
}
URI | Method | Description |
---|---|---|
/follow/:id |
DELETE |
Delete a following-user from following list by user id and friend id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
{
"followingName" : "user name who wish to follow"
}
- Response :
{
"Unfollow"
}
URI | Method | Description |
---|---|---|
/message/:id |
GET |
GET a list of messages that a user sent or received in the service today by user id and message id |
- Request Parameter :
id
: User primary key in Postgres DB - Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
Not Required
- Response :
{
"sent": [
{
"sender" : "user name who sent the message",
"receiver" : "user name who received the message",
"content" : "message",
"type" : "true : message sent"
},
],
"received": [
{
"sender" : "user name who sent the message",
"receiver" : "user name who received the message",
"content" : "message",
"type" : "false : message received"
},
]
}
URI | Method | Description |
---|---|---|
/message/:id |
POST |
Send a message to one of following users and the message is stored as a sent message |
- Request Parameter :
Not Required
- Payload :
id, token
: User primary key and published non-expired token id
{
"id" : "user id in Postgres DB",
"token" : "published Json Web Token to the user which expiration hour is 1 hour and issuer is hmm"
}
- Request Body :
{
"targetUserId" : "user id who wish to be sent",
"content" : "message"
}
- Response :
{
"Message sent!"
}
See the open issues for a list of proposed features