Skip to content

cavaldos/Reddit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reddit 🌈"💯👍💡 ⭐️ 🔥

Node.js TypeScript Express.js


Manual Installation

  1. Clone project
git clone https://github.com/cavaldos/Reddit.git
  1. Move path
cd Reddit
  1. Move server
cd server
  1. Install
yarn add  # npm install  # pnpm install
  1. Run Production
yarn run  start:prod
  1. Run Development
yarn run dev
  1. Build
yarn run build

Docker

Build docker

1.Build your updated version of the image, using the docker build command.

docker build -t  reddit-clone-server .

2.Start a new container using the updated code.

docker run -dp 3000:3000  reddit-clone-server .

PORT=3000

├─ src
  ├─ api
    ├─ controllers
       └─ index.ts
    ├─ middlewares
       └─ index.ts
    ├─ routes
       └─ index.ts
    └─ validators
        └─ index.ts
  ├─ config
    └─ index.ts
  ├─ loaders
    └─ index.ts
  ├─ models
    └─ index.ts
  └─ utils
      └─ index.ts
├─ main.ts
├─ tsconfig.json
├─ .tsconfig.build.json
├─ .env
├─ README.md
├─ .gitignore
├─ LICENSE
├─ package-lock.json
└─ package.json

API Endpoints

List of available routes:

Auth Routes:

Functionality Method Endpoint Request Header Request Body Response
log in POST /auth { email, password } {user object}
log out GET /auth/logout - -
register POST /auth/register { email, password } -
reset password GET /auth/resetPassword Authorization - -
refresh token GET /auth/refreshToken Authorization -

Post Routes:

object Functionality Method Endpoint Request Header Request Body Response
post get posts GET /post?subredditName=&limit=&page= - - {post objects array}

Subreddit Routes:

object Functionality Method Endpoint Request Header Request Body Response
subreddit search GET /subreddit/search?q= - - { subreddit }
create subreddit POST /subreddit Authorization { name } { subreddit object }
subscribe POST /subreddit/subscribe Authorization { subredditId } { subredditId }
unsubscirbe POST /subreddit/unsubscribe Authorization { subredditId } -
create post in subreddit POST /subreddit/post Authorization { title, content, subredditId } { post object }
comment to post in subreddit PATCH /subreddit/post/comment Authorization { postId, text, replyToId } -
vote to post in subreddit PATCH /subreddit/post/vote Authorization { postId, voteType } {voteCount}
vote to a comment PATCH /subreddit/post/comment/vote Authorization { commentId, voteType } -

User Routes:

object Functionality Method Endpoint Request Header Request Body Response
user get user information GET /user/:\id - { user object }
change username PATCH /user/username Authorization { name } -
upload user imagine POST /user/imagine Authorization { file } -
download user imagine GET /user/imagine Authorization { file } -