Skip to content

jinyun3075/GamgyulServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 

Repository files navigation

감귤서버 API (2022-01-16 ~ 2022-02-14)

UI

실행 방법

  • git clone https://github.com/jinyun3075/GamgyulServer.git
  • GamgyulServer -> GamgyulServer 폴더로 이동한다.
  • model -> config.js 파일에서 DB 설정
  • .env 파일을 만들고 원하는 DB 경로 및 토큰 값을 채워넣는다.
    예시)
        DATA_URL= "Atlas link" : Atlas 몽고 DB
        DOCKER = "mongodb://docker:27017/gamgyul" : 도커DB
        LOCAL = "mongodb://localhost:27017/gamgyul" : 로컬DB
        TOKEN = "진윤재" : 1 토큰
        TOKEN2 = "짱" : 2 토큰
  • " npm install " 를 입력하여 패키지를 다운받는다.
  • nodemon 이 설치 되어있다면 " npm start " 없을 경우 " npm run-script start2 " 를 터미널에 입력하여 서버 실행

Docker 실행법

결과

image

DB관계도

image

구조

image

목차

1. 유저

2. 이미지

3. 프로필

4. 댓글

5. 게시글

6. 좋아요

7. 댓글

8. 상품

📌유저

회원가입

  • api

    • /user (post)
  • req

    • user
      • username: String
      • email: String
      • password: String
      • accountname: String
      • intro: String
      • image: String
  • res

    • user
      • _id: String
      • username: String
      • email: String
      • accountname: String
      • intro: String
      • image: String
  • fail

    • email, password, accountname, username 중 하나라도 작성하지 않을 경우 필수 입력사항을 입력해주세요.
    • password를 6자 이상 입력하지 않을 경우 비밀번호는 6자 이상이어야 합니다.
    • eamil 형식이 잘못될 경우 잘못된 이메일 형식입니다.
    • 가입된 email일 경우 이미 가입된 이메일 주소입니다.
    • accountname에 지정된 문자 이외의 문자가 들어갈 경우 영문, 숫자, 밑줄, 마침표만 사용할 수 있습니다.
    • 가입된 accountname일 경우 이미 사용중인 계정 ID입니다.

로그인

  • api
    • /user/login (post)
  • req
    • user
      • email: String
      • password: String
  • res
    • user
      • _id: String,
      • username: String
      • email: String
      • accountname: String
      • image: String
      • token: String
  • fail
    • 이메일 또는 비밀번호를 입력하지 않을때

전체 유저

  • api
    • /user (get)
  • res
    • user: []
      • _id: String
      • email: String
      • hearts: []
      • following: []
      • follower: []
      • password: String
      • username: String
      • accountname: String
      • intro: String
      • image: String

📌이미지

이미지 업로드

  • api

    • /image/uploadfile (post)
  • header

    • apl
  • req

    • key: image
    • value: 이미지 파일
  • res

    • fieldname: String
    • originalname: String
    • encoding: String
    • mimetype: String
    • destination: String
    • filename: String
    • path: String
    • size: number
  • fail

    • 이미지 파일(*.jpg, *.gif, *.png, *.jpeg, *.bmp, *.tif) 확장자명이 다를 때
    • 이미지 파일만 업로드가 가능합니다.

여러 이미지 업로드

  • api

    • /image/uploadfiles (post)
  • req

    • key: images
    • value: 이미지 파일
  • fail

    • 이미지 최대 3개
    • 이미지 파일만 업로드

이미지 자세히 보기

  • api
    • /filename.이미지 확장자
  • res
    • 사진
  • fail
    • status 404

📌프로필

프로필 수정

  • api

    • /user (put)
  • req

    • user
      • username: String
      • accountname: String
      • intro: String
      • image: String
  • header

    • "Authorization" : “Bearer key”
    • "Content-type" : application/json
  • res

    • user
      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • following: []
      • follower: []
      • followerCount: Number
      • followingCount: Number }

개인 프로필

  • api

    • /profile/:accountname (get)
  • header

    • Authorization : “Bearer key”
    • Content-type : "application/json"
  • res

    • profile
      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: []
      • followerCount: Number
      • followingCount: Number }
  • fail

    • 해당 계정이 존재하지 않습니다.

팔로우

  • api
    • /profile/:accountname/follow (post)
  • header
    • Authorization : Bearer key
    • Content-type : application/json
  • res
    • follow 한 사용자의 프로필

    • profile

      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: ["접속한 사용자의 id"]
      • followerCount: 1
      • followingCount: 0 }
    • 접속한 사용자의 프로필

    • profile

      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: ["팔로우 한 사용자의 id"]
      • follower: []
      • followerCount: 0
      • followingCount: 1 }
  • fail
    • 해당 계정이 존재하지 않습니다.

언팔로우

  • api
    • /profile/:accountname/unfollow (delete)
  • header
    • Authorization : Bearer key
    • Content-type : application/json
  • res
    • follow 한 사용자의 프로필

    • profile

      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: []
      • followerCount: 0
      • followingCount: 0
    • 접속한 사용자의 프로필

    • profile

      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: []
      • followerCount: 0
      • followingCount: 0 }
  • fail
    • 해당 계정이 존재하지 않습니다.

팔로잉 리스트

  • api
    • /profile/:accountname/following (get)
    • /profile/:accountname/following?limit=Number&skip=Number (get)
  • header
    • Authorization: Bearer key
    • Content-type: application/json
  • res
    • []
      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: ["접속한 사용자의 id"]
      • followerCount: 1
      • followingCount: 0
  • fail
    • 해당 계정이 존재하지 않습니다.

팔로워 리스트

  • api
    • /profile/:accountname/follower (get)
    • /profile/:accountname/follower/?limit=Number&skip=Number (get)
  • header
    • Authorization: Bearer key
    • Content-type: application/json
  • res
    • []
      • _id: String
      • username: String
      • accountname: String
      • intro: String
      • image: String
      • isfollow: Boolean
      • following: []
      • follower: ["접속한 사용자의 id"]
      • followerCount: 1
      • followingCount: 0
  • fail
    • 해당 계정이 존재하지 않습니다.

📌검색

유저 검색

  • api
    • /user/searchuser/?keyword=keyword
  • header
    • Authorization: Bearer key
    • Content-type: application/json
  • res
    • []
      • id: String
      • username: String
      • accountname: String
      • following: []
      • follower: []
      • followerCount: Number
      • followingCount: Number

📌게시글

게시글 작성

  • api
    • /post (post)
  • header
    • Authorization: Bearer key
    • Content-type: application/json
  • req
    • post
      • content : String
      • image : [""]
  • res
    • post
      • id : String
      • content : String
      • image : String
      • createdAt : String
      • updatedAt : String
      • hearted : False
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail
    • 내용 또는 이미지를 입력하지 않았을 떄

팔로워 게시글 목록(피드)

  • api

    • /post/feed (get)
    • /post/feed/?limit=Number&skip=Number (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • 팔로워한 사용자가 있을때
    • post: []
      • id : String
      • content : String
      • image : []
      • createdAt : String
      • updatedAt : String
      • hearted : False
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail

    • follow 한 사용자가 없을 때
    • post : []

나의 게시글 목록

  • api

    • /post/:accountname/userpost (get)
    • /post/:accountname/userpost/?limit=Number&skip=Number (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • post: []

      • id : String
      • content : String
      • image : []
      • createdAt : String
      • updatedAt : String
      • hearted : false
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
    • 해당 계정의 게시물이 존재하지 않을 떄

      • post: []
  • fail

    • 해당 계정이 존재하지 않습니다.

게시글 상세

  • api

    • /post/:post_id (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • post
      • id: String
      • content: String
      • image: []
      • createdAt: String
      • updatedAt: String
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail

    • 게시글이 존재하지 않습니다.

게시글 수정

  • api

    • /post/:post_id (put)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • req

    • post
      • content: String
      • image: []
  • res

    • post
      • id : String
      • content : String
      • image : []
      • createdAt : String
      • updatedAt : String
      • hearted : false
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail

    • 존재하지 않는 게시글입니다.
    • 잘못된 요청입니다. 로그인 정보를 확인하세요. ( 다른 사용자가 해당 게시물을 수정할 경우)

게시글 삭제

  • api

    • /post/:post_id (delete)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • 삭제되었습니다.
  • fail

    • 존재하지 않는 게시글입니다.
    • 잘못된 요청입니다. 로그인 정보를 확인하세요. ( 다른 사용자가 해당 게시물을 수정할 경우)]

📌좋아요

좋아요

  • api

    • /post/:post_id/heart (post)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • post
      • id : String
      • content : String
      • image : []
      • createdAt : String
      • updatedAt : String
      • hearted : true
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail

    • 존재하지 않는 게시글입니다.

좋아요 취소

  • api

    • /post/:post_id/unheart (delete)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • post
      • id : String
      • content : String
      • image : []
      • createdAt : String
      • updatedAt : String
      • hearted : true
      • heartCount : Number
      • commentCount : Number
      • author
        • id : String
        • username : String
        • accountname : String
        • following : []
        • follower : []
        • followerCount : Number
        • followingCount : Number
  • fail

    • 존재하지 않는 게시글입니다.

📌댓글

댓글 작성

  • api

    • /post/:post_id/comments (post)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • req

    • comment
      • content: String
  • res

    • comment
      • id: Sting
      • content: Sting
      • createdAt: Sting
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number
  • fail

    • 존재하지 않는 게시글입니다.
    • 댓글을 입력해주세요.

댓글 리스트

  • api

    • /post/:post_id/comments (get)
    • /post/:post_id/comments/?limit=Number&skip=Number (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • comment: []
      • id: Sting
      • content: Sting
      • createdAt: Sting
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number
  • 댓글이 존재하지 않는 경우

    • comment: []
  • fail

    • 존재하지 않는 게시글입니다.

댓글 삭제

  • api

    • /post/:post_id/comments/:comment_id (delete)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • 댓글이 삭제되었습니다
  • fail

    • 존재하지 않는 게시글입니다.
    • 댓글이 존재하지 않습니다.

📌상품

상품 등록

  • api

    • /product (post)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • req

    • product
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
  • res

    • product
      • id: String
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number
  • fail

    • 필수 입력사항을 입력해 주세요. (하나라도 입력이 되어있지 않을 경우)
    • 가격은 숫자로 입력해주세요.

상품 리스트

  • api

    • /product/:accountname (get)
    • /product/:accountname/?limit=Number&skip=Number (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • data: Number // 상품 수
    • product: []
      • id: String
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number
  • fail (상품 없을 때)

    • data: 0
    • product:[]

상품 상세

  • api

    • /product/detail/:product_id (get)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • product
      • id: String
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number

상품 수정

  • api

    • /product/:product_id (put)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • req

    • product
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
  • res

    • product
      • id: String
      • itemName: String
      • price: Number
      • link: String
      • itemImage: String
      • author
        • _id: "작성자 id"
        • username: String
        • accountname: String
        • intro: String
        • image: String
        • following: []
        • follower: []
        • followerCount: Number
        • followingCount: Number
  • fail

    • 등록된 상품이 없습니다.
    • 잘못된 요청입니다. 로그인 정보를 확인하세요.

상품 삭제

  • api

    • /product/:product_id (delete)
  • header

    • Authorization: Bearer key
    • Content-type: application/json
  • res

    • 삭제되었습니다.
  • fail

    • 등록된 상품이 없습니다.
    • 잘못된 요청입니다. 로그인 정보를 확인하세요.

About

감귤마켓 서버!!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published