Git Product home page Git Product logo

nodejs-login's Introduction

NodeJS-Login

This repo is for practice using NodeJS to create user login and hashing passwords.

The sole purpose of this is to demonstrate the usage of NodeJS and bcrypt, in effort to store Usernames and Passwords.

NOTE

This should NOT be used in real world applications. Credentials can be accessed if hacked into. Yes, the passwords are hashed but it is possible to dycrpt them.

Proper use would include storing the users in a database of some sort.

To get started, here is an outline of a general set up.

#Create Project folder

#Init project npm init -y (setting up environment, 'y' gives all default values for ) #Init package . json

#Install packages used for express server npm i express bcrypt (express is the server, bcrypt will be where we do password hashing and security)

Install nodemon to allow restart of server without crashing the site

npm i --save-dev nodemon (this is a dev dependency, used for development)

#create a script to start server using nodemon

GO-TO --> package.json --> "scripts"

add devStart --> equal to nodemon server.js

#create server.js file #set up express here const express = require('express') # constant for express module const app = express() # app for express

app.listen(3000) # listening on port 3000 (localhost) for server

test run to make sure it is working

npm run devStart (should do nothing but start the server) (ROUTES NOT YET SET UP)

Create user variable for storage

const users = [] ###NOTE### In real world applications, you want to store this in a database

Create a route

for getting all of our users

app.get('/users', (req,res) =>{ res.json(users) }) ###NOTE### In real world applications, you DO NOT want to set up a route that exposes user information

#create request.rest file for REST requests

in VS Code, install extension REST Client for making request directly in the IDE

In requests.rest

GET http://localhost:3000/users

should return an empty array of users , until added

nodejs-login's People

Contributors

ethan-baranowski 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.