Giter Site home page Giter Site logo

wudnodeauthentication's Introduction

WUDNodeAuthentication

Tutorial - authenticataion sessionbased application using Nodejs

How to setup application

  1. Clone git repo branch
  2. Install dependencies npm i
  3. Copy file .env-example to file named .env
  4. Use .env file to set application secrets | variables.

How to run application

  1. Start server node server
  2. Open a browser and visit localhost:3000

Comments...

Server event order

  1. dependencies
  2. middleware | sessions, handle posts
  3. routes | endpoints: api response json, render page using template engine
  4. static files
  5. 404 not found - custom page | info
  6. 500 server error
  7. listen on server requests

Template engine

EJS - Embedded JavaScript templating

Use Visual Studio Code extension EJS Language support

https://ejs.co/

folder structure

  • views
    • partials
      • header.ejs
      • footer.js
      • nav.ejs
  • index.ejs
  • about.ejs
  • user.ejs
  • ...

Routes

  • routes
    • route-start.js
    • route-about.js

MVC - Model View Controller

folder structure

  • controllers
    • controller-user.js
  • models
    • User.js
    • UserSchema.js
  • views
    • user.ejs
    • login.ejs
    • register.ejs
    • users.ejs
    • ...

MongoDB

Set MongoDB URL and MongoDB database name (collection) in .env file

  • MONGODB_URL="mongodb+srv://...?retryWrites=true&w=majority"
  • MONGODB_NAME=""

wudnodeauthentication's People

Contributors

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