Skip to content

inezamanda/bloggie-synrgy

Repository files navigation

Backend Mini Project Synrgy Academy Team A

Content sharing blogs that allow users to create cross-category posts. Every post can contain photos, files, and text. Blogie supports likes, comments, save and sharing posts. Every user can set what categories preferences to be displayed on the homepage.

Pre-initialization

  • Please copy example.env file
  • Rename file to .env
  • Insert your database credential and port to run this application

Initialization

  1. Cloning this repository to your local computer.
  2. Install all dependencies using command:
npm install
  1. Create database using command:
sequelize db:create
  1. Migrate database schema using command:
sequelize db:migrate
  1. Seed data dummy using command:
sequelize db:seed:all
  1. Run this application using command:
npm run dev

or

npm start

Git Workflow

  1. Create branch feature from branch deploy with format: feature/(feature-name)
    How to create branch?
  • Gitlab
    Choose icon plus beside list branch and choose this repository new branch.
  • Visual Studio Code
    Ctrl+Shift+P and then search git:create branch.
  1. In visual studio code, checkout to new branch using command:
git checkout feature/(feature-name)
  1. Make change to your code.
  2. After that, move modified files to staging area using command:
git add .
  1. Make a note of all changes using command:
git commit -m "(your change log)"
  1. Push your commit to your branch using command:
git push origin feature/(feature-name)
  1. After your feature done, go to repository gitlab and choose create merge request.
  • Add title.
  • Describe your changes in description column.
  • In Assignees, choose assign to me.
  • In Reviewers, choose your tech lead.
  • Submit merge request

After Review

  1. If there is a problem or code need fixing, tech lead will create comment in your code or create comments in your merge request.
    1. Update your branch using command:
      > git fetch
    2. Pull update your branch using command:
      > git pull
    3. Fix your code
    4. Make a note of all changes using command:
      > git commit -m "(your change log)"
    5. Push your commit to your branch using command:
      > git push origin feature/(feature-name)
    6. Go to gitlab and create comment with tag to your tech lead to inform you already fix your code
  2. If there is no problem, tech lead will create comments LGTM (Looks good to me) to your merge request.
  3. Your merge request will be closed

Dependencies

  • bcrypt
  • dotenv
  • ejs
  • express
  • faker
  • jsonwebtoken
  • nanoid
  • passport
  • passport-jwt
  • pg
  • sequelize

API Spec

  1. Feature signup
    endpoint:

    • POST /signup

    request example:

    {
      "email": "sherlockholmes@gmail.com",
      "password": "1234567890",
      "username": "sherlockholmes",
      "fullName": "Sherlock Holmes",
      "image_profile": "profile.jpg",
      "image_header": "header.jpg",
      "about": "Hi, it's me.",
      "occupation": "Web Developer",
      "location": "Indonesia",
      "role": "User",
    }

    success response example:

    {
      "status": "200 OK",
      "message": "User has been register",
      "data":{
        "id": "EqpcETTeyVJqTI7ReTL9Z",
        "email": "sherlockholmes@gmail.com",
        "username": "sherlockholmes",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IkVxcGNFVFRleVZKcVRJN1JlVEw5WiIsImlhdCI6MTYxNDQ4OTk0Nn0.-cZuPQQ2N4kQkAGtZJk0WTXHRmNYymaqdL2wIRmLiFc"
      }
    }

    error response example:

    {
      "status": "409 Conflict",
      "message": "Username/Email already exists"
    }
  2. Feature Login
    endpoint:

    • POST /signup

    request example:

    {
      "email": "sherlockholmes@gmail.com",
      "password": "1234567890"
    }

    success response example:

    {
      "status": "200 OK",
      "message": "Login successful",
      "data":{
        "id": "EqpcETTeyVJqTI7ReTL9Z",
        "email": "sherlockholmes@gmail.com",
        "username": "sherlockholmes",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IkVxcGNFVFRleVZKcVRJN1JlVEw5WiIsImlhdCI6MTYxNDQ4OTk0Nn0.-cZuPQQ2N4kQkAGtZJk0WTXHRmNYymaqdL2wIRmLiFc"
      }
    }

    error response example:

    {
      "status": "401 Unauthorized",
      "message": "Email/Password incorrect"
    }
  3. CRUD User
    Create User
    endpoint:

    • POST /users

    request example:

    {
      "email": "sherlockholmes@gmail.com",
      "password": "1234567890",
      "username": "sherlockholmes",
      "fullName": "Sherlock Holmes",
      "image_profile": "profile.jpg",
      "image_header": "header.jpg",
      "about": "Hi, it's me.",
      "occupation": "Web Developer",
      "location": "Indonesia",
      "role": "User",
    }

    success response example:

    {
      "status": "200 OK",
      "message": "User has been register",
      "data":{
        "id": "EqpcETTeyVJqTI7ReTL9Z",
        "email": "sherlockholmes@gmail.com",
        "username": "sherlockholmes",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IkVxcGNFVFRleVZKcVRJN1JlVEw5WiIsImlhdCI6MTYxNDQ4OTk0Nn0.-cZuPQQ2N4kQkAGtZJk0WTXHRmNYymaqdL2wIRmLiFc"
      }
    }

    error response example:

    {
      "status": "409 Conflict",
      "message": "Username/Email already exists"
    }
  4. CRUD Post

  5. CRUD Category

  6. CRUD Comment
    Create Comment
    endpoint:

    • POST /comment/

    request example:

    {
      "content": "i have no idea."
    }

    success response example:

    {
      "status": "200 OK",
      "message": "Add Comments successful",
      "data":{
        "id": "U1g-lBI6BHhgHu5IfAC2I",
        "posts_id": "o19vozmrZ_yVBa6hV_g0Q",
        "users_id": "EqpcETTeyVJqTI7ReTL9Z",
        "content": "i have no idea.",
        "createdAt": "2021-02-27T10:11:40.406Z",
        "updatedAt": "2021-02-27T10:11:40.406Z"
      }
    }

    error response example:

    {
      "status": "403 Forbidden",
      "message": "You need to login first"
    }

    Read Comment
    endpoint:

    • GET /comment
    • GET /comment/:id

    success response example:

    {
      "status": "200 OK",
      "message": "Read comments successful",
      "data":{
        "id": "U1g-lBI6BHhgHu5IfAC2I",
        "posts_id": "o19vozmrZ_yVBa6hV_g0Q",
        "users_id": "EqpcETTeyVJqTI7ReTL9Z",
        "content": "i have no idea.",
        "createdAt": "2021-02-27T10:11:40.406Z",
        "updatedAt": "2021-02-27T10:11:40.406Z"
      }
    }

    error response example:

    {
      "status": "404 Not Found",
      "message": "Comments not found"
    }

    Edit Comment
    endpoint:

    • PUT /comment/:id

    request example:

    {
      "content": "i have idea."
    }

    success response example:

    {
      "status": "200 OK",
      "message": "Edit comments successful"
    }

    error response example:

    {
      "status": "400 Bad Request",
      "message": "Comments can't be empty"
    }

    Delete Comment
    endpoint:

    • DELETE /comment/:id

    success response example:

    {
      "status": "200 OK",
      "message": "Delete comments successful"
    }

    error response example:

    {
      "status": "404 Not Found",
      "message": "Comments not found"
    }
  7. GET Saved Post

  8. GET Search Post Title/User

  9. GET Post by Category

  10. GET Post by (latest activity)

  11. GET Users by Following’s Followers (suggestion)

  12. GET Post by Active User

  13. PATCH User (User’s side)

  14. GET Saved Post by Month

  15. GET Saved Post by Week

  16. GET Post by Post’s Likes

  17. GET Post by CreatedAt

  18. GET Post by id

  19. CREATE Post (user’s side)

  20. GET Post user by Interest

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •