Code Monkey home page Code Monkey logo

ddat-hmm-server's Introduction

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

ddat-hmm-server's People

Contributors

jyuunnii avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.