Giter Club home page Giter Club logo

bigstack's Introduction

BigStack

Read the Docs Ask Me Anything ! made-for-VSCode GitHub issues GitHub top language GitHub forks GitHub stars GitHub last commit GitHub license

A Node JS Project which is a miniature model of Stack Overflow Backend where users can post questions, answers and also upvote the answers. The users have login feature and has to be authenticated to upvote an answer. User Data is fetched from Mongo DB.

๐Ÿ‘‰ If you like this repo then please give it a โญ๏ธ

Description

A Node JS Project where the User gets option to Login, all the user details are stored in Mongo DB. This application has features to post questions in the forum where users can answer them or even upvote them. For the answer to get upvoted the user Object ID has to be fetched from Mongo DB, which also means that the user has to be logged in/authenticated.

This project is completely deployable and can be used with any FrontEnd. It uses RESTful API and explicitly takes advantages of HTTP methodologies.

Prerequisites

To run this project on your system you need to meet these criterias:

  • Basic understanding of Node.js and JavaScript.
  • A terminal app for MacOS and Linux or PowerShell for Windows.
  • Node.js v8+ and a Node.js package manager installed locally.

To install Node.js and NPM, use any of the official Node.js installers provided for your operating system.

Initialization

GitHub package.json version Read the Docs

Create a project directory named Bigstack to hold your application, and make that your working directory. Use the npm init command to create a package.json file for your application.

Inside package.json set the 'main' to "server.js" as that is going to be our primary end point of the application.

Instead of using the node command to run the application, we'll use, a tool called nodemon that monitors our application and automatically restarts the server when source code changes. With node, we'd have to restart the server manually when changes are made.

Install nodemon as a dependency of your Node.js application:

npm install nodemon

To make nodemon recognize the entry point of our application we need to map it with our main javaScript file. To do that open package.json and add the following line, after main:

"scripts": {
    "start": "node server.js"
 }

Dependencies Used

node node node node node node

To install these dependencies simply type this in the terminal:

npm install express body-parser mongoose passport bcryptjs passport-jwt validator jsonwebtoken

--save is not required to be typed since after node v5+ release all the packages are automatically saved inside package.json

server.js

GitHub top language

This is the primary end point of the application. This javaScript file handles the Strategies as well as routes.

It creates a running connection with Mongo DB and displays a message in the terminal on which port the web server is currently running and also if Mongo DB is successfully connected or not.

It connects our application to the RESTful API through custom routes.

Schemas

In this project we have three schemas namely Profile Schema, Question Schema and User Schema.(They can be modified according to the developer as per what details they want to take from the Users).

Profile Schema -- It takes neccessary informations like username and launguges, other information are optional. The user data is fetched from Mongo DB by their Object ID :

user: {
        type: Schema.Types.ObjectId,
        ref: "myPerson"
    }

Where myPerson is the Mongoose Model for the User Schema.

Question Schema -- In this Schema compulsory attributes are textone, texttwo and answers.text. Again the user data is fetched from Mongo DB to only allow the logged in users to answer questions and also to upvote.

user: {
        type: Schema.Types.ObjectId,
        ref: "myPerson"
    }

Where myPerson is the Mongoose Model for User Schema.

User Schema -- This Schema is used to register users for the first time. It has necessary attributes like name, email, password and gender Based on the gender it switches the default avatar picture. It adds the user to the database and creates a Mongoose Model called myPerson

NOTE:

This project is subject to change by the developer and is still in development

Pull Request

Pull Requests are welcome. Please follow these rules for the ease of understanding:

  • Make sure to check for available issues before raising one
  • Give me a maximum of 24-48 hours to respond
  • Have proper documentation on the parts you are changing/adding

Feel free to contribute

Developed & Maintained by

Sayan Mondal ๐Ÿ“ท Insta ๐Ÿค Twitter Twitter

License

GitHub license


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Getting Started

For help getting started with Node, view our online documentation.

bigstack's People

Contributors

dependabot[bot] avatar s-ayanide avatar

Stargazers

 avatar  avatar  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.