Skip to content

jyuunnii/ddat-hmm-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

DDAT-HMM Server

📍 Table of Contents

🔎 About The Project

This is REST API server for ddat-hmm project.

Built With

Features

  • Save ddat-hmm data of user, friend(following / follower), and message(sent / received)
  • REST API for CRUD in ddat-hmm

💡 Getting Started

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.

Prerequisites

  • npm
npm install npm@latest -g
  • Postgres Server

Available to replace another server instead of postgres server. See typeorm documents for connection server.

Installation

  1. Run Postgres
psql -U userName
  1. Clone the repository
git clone https://github.com/jyuunnii/hmm-server.git
  1. Change current directory to the project directory
  2. Install npm packages
npm install
  1. Run server
npm start

Success to installation writes App Listening on PORT [port_number] DB connected ! on your terminal.

✅ Usage

API

🔹 Login authentication

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"
}

🔸 Get all users

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)"
  },
]

🔸 Get a list of user public data

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)"
  },
]

🔸 Get a specific user public data

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"  
}

🔹 Post a new user

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 !"
}

🔹 Patch a user data

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 !"
}

🔺 Delete a specific user

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 !"
}

🔸 Get a following and follower list

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"
  },
  ]
}

🔹 Post a new following

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 !"
}

🔺 Delete a specific following

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"
}

🔸 Get all messages of user

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"
  },
]
}

🔹 Post a new message

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!"
}

Roadmap

See the open issues for a list of proposed features

Releases

No releases published

Packages

No packages published