Git Product home page Git Product logo

stack-overflow-clone's Introduction

Stack Overflow Clone

This project is a simple implementation of the basic features of StackOverflow. It was developed using the stack below, and managed with Pivotal Tracker

Coverage Status Build Status

Stack

  • Server: NodeJS, Express
  • Database: MongoDB (with Mongoose ORM)

Hosted Application

Project Management

Documentation

Features

  • Signup
  • Login
  • Ask Questions
  • View Questions
  • Upvote or Downvote a question
  • Answer Question
  • Search (Questions, Answers, Users)

Getting Started

  • Clone the repo
  • Ensure you set up environment variables based on the .env.sample file
  • Run the following commands
npm install
npm run start:dev

API

Signup

POST /api/v1/auth/signup

Sample Request
  • required: displayName, email, password
{
  "displayName": "john123",
  "email": "[email protected]",
  "password": "john1234",
}
Response

{
    "message": "sucessfully created user!",
    "data": {
        "id": "5d9e17a86ad68437fc740109",
        "email": "[email protected]",
        "displayName": "john123",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOWUxN2E4NmFkNjg0MzdmYzc0MDEwOSIsImlhdCI6MTU3MDY0MjA3NCwiZXhwIjoxNTcwNzI4NDc0fQ.itSBwRRaN22OWzzToBoSP-u1HbhIeYUcmWQzLjeFafk"
    }
}

Login

POST /api/v1/auth/login

Sample Request
  • required: email, password
{
  "email": "[email protected]",
  "password": "john1234",
}
Response

{
  "message": "login successful",
  "data": {
    "id": "5d9e17a86ad68437fc740109",
    "email": "[email protected]",
    "displayName": "john123",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOWUxN2E4NmFkNjg0MzdmYzc0MDEwOSIsImlhdCI6MTU3MDY0MjA3NCwiZXhwIjoxNTcwNzI4NDc0fQ.itSBwRRaN22OWzzToBoSP-u1HbhIeYUcmWQzLjeFafk"
  }
}

Ask a Question

POST /api/v1/questions

Sample Request
  • required: title, body, authorization(in header)
  • optional: tags
{
	"title": "Javascript or python, which is better",
	"body": "I want to know the better of javascript and python",
	"tags": ["javascript", "python"]
}
Response

{
  "message": "successfully asked a question!",
  "data": {
    "tags": [
        "javascript",
        "python"
    ],
    "answers": [],
    "_id": "5d9e19bf6ad68437fc74010a",
    "owner": "5d9e17a86ad68437fc740109",
    "title": "Javascript or python, which is better",
    "body": "I want to know the better of javascript and python",
    "votes": [],
    "updatedAt": "2019-10-09T17:32:47.734Z",
    "createdAt": "2019-10-09T17:32:47.734Z",
    "__v": 0
  }
}

View all Questions

GET /api/v1/questions

Sample Request
  • required: authorization(in header)
  • optional: page (defaults to 1), limit (defaults to 20)
Response

{
  "message": "succesfully returned questions",
  "currentPage": 1,
  "totalPages": 1,
  "limit": 20,
  "data": [
    {
      "id": "5d9e19bf6ad68437fc74010a",
      "owner": "john123",
      "title": "Javascript or python, which is better",
      "body": "I want to know the better of javascript and python",
      "tags": [
          "javascript",
          "python"
      ],
      "answers": [],
      "upvotes": 0,
      "downvotes": 0,
      "createdAt": "2019-10-09T17:32:47.734Z",
      "updatedAt": "2019-10-09T17:32:47.734Z"
    }
  ]
}

View single Question

GET /api/v1/questions/:questionId

Sample Request
  • required: authorization(in header)
  • where: questionId = 5d9a5867e0c2622f2805848f
Response

{
  "message": "successfully returned question",
  "data": [
    {
      "id": "5d9e19bf6ad68437fc74010a",
      "title": "Javascript or python, which is bettere",
      "body": "I want to know the better of javascript and python",
      "tags": [
          "javascript",
          "python"
      ],
      "answers": [],
      "upvotes": 0,
      "downvotes": 0,
      "createdAt": "2019-10-09T17:32:47.734Z",
      "updatedAt": "2019-10-09T17:32:47.734Z"
    }
  ]
}

Upvote or Downvote a Question

PATCH /api/v1/questions/:questionId/vote

Sample Request
  • required: voteType (in query), authorization(in header)
  • where: questionId = 5d9a5867e0c2622f2805848f, voteType = up
Response

{
  "message": "you have successfully upvoted this question"
}

Answer a Question

POST /api/v1/questions/:questionId/answers

Sample Request
  • required: body, authorization(in header)
  • where: questionId = 5d9a5867e0c2622f2805848f
{
	"body": "both are very good"
}
Response

{
  "message": "successfully answered a question!",
  "data": {
    "_id": "5d9e1ea06ad68437fc74010c",
    "owner": "5d9e17a86ad68437fc740109",
    "body": "both are very good",
    "updatedAt": "2019-10-09T17:53:36.750Z",
    "createdAt": "2019-10-09T17:53:36.750Z",
    "__v": 0
  }
}

Search Questions, Answers or Users

GET /api/v1/search

Sample Request
  • required: type (in query), value (in query), authorization(in header)
  • where: type = questions, value = python
Response

{
  "message": "successfully returned questions",
  "data": [
    {
      "id": "5d9e19bf6ad68437fc74010a",
      "owner": "john123",
      "title": "Javascript or python, which is bettere",
      "body": "I want to know the better of javascript and python",
      "tags": [
          "javascript",
          "python"
      ],
      "answers": [
          {
              "body": "both a very good",
              "createdAt": "2019-10-09T17:53:36.750Z"
          }
      ],
      "upvotes": 1,
      "downvotes": 0,
      "createdAt": "2019-10-09T17:32:47.734Z",
      "updatedAt": "2019-10-09T17:53:36.753Z"
    }
  ]
}

Contributions

Contributions are welcome, kindly clone the repo, create a new branch and raise a Pull Request

stack-overflow-clone's People

Contributors

ukhu avatar

Stargazers

Roman avatar Paulo Coghi avatar

Watchers

 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.