soyjuanmacias / server-basic-express-juan

Base Node Express Project for Ironhack Students

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic and empty Node.js & Express.js server with auth ready for start to code

Here you have a basic config for a server with Node.js and Express and authentication with Passport.

Project created by Juan Macías with original idea by Xenock. Link to the original repository

This repository contains a server with the necessary packages to start any project in Node.js

Everything is installed, you only have to run:

npm install --save

And you will install all packages with this command.

Features:

  • App.js only 10 lines:

App.js

  • Design with MVC pattern (Model, View, Controller)
  • Work with controllers folder where we take on all our project action. Cleaner and tidier code.
  • Middleware for save user data and send it in all requests (res.locals.user)

Pre-installed packages (By alphabetical order)

  • Lib to help you hash passwords.
  • Parse incoming request bodies in a middleware before your handlers, available under the req.body property.
    • So, without body parser you can't do req.body.foo
  • This middleware ensures that a user is logged in.
    • If a request is received that is unauthenticated, the request will be redirected to a login page.
    • The URL will be saved in the session, so the user can be conveniently returned to the page that was originally requested.
  • Parse Cookie header and populate req.cookies with an object keyed by the cookie names. Optionally you may enable signed cookie support by passing a secret string, which assigns req.secret so it may be used by other middleware.
  • Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. We use this for create schema models for MongoDB and make sure that the data we save in Mongo is correct.
  • Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.
  • EJS is an embedded Javascript templating library for render and show the view in our server.
  • The crown jewel for Node.js. Fast and minimalist web framework with routing, and others great features. It will allow us to create the model view controller easily and simply. Simplifying everything to create our backend easily.
  • Layout support for ejs in express.
  • This is a Node.js module available through the npm registry. Installation is done using the npm install command
$ npm install express-session
  • Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
  • HTTP request logger middleware for node.js
  • Passport's sole purpose is to authenticate requests, which it does through an extensible set of plugins known as strategies. Passport does not mount routes or assume any particular database schema, which maximizes flexibility and allows application-level decisions to be made by the developer. The API is simple: you provide Passport a request to authenticate, and Passport provides hooks for controlling what occurs when authentication succeeds or fails.
  • Passport strategy for authenticating with a username and password.

  • This module lets you authenticate using a username and password in your Node.js applications. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Español

Basic and empty Node.js & Express.js server with auth ready for start to code

Aquí tienes la configuración básica para un servidor montado con Node.js y Express con autentificación con Passport.

Proyecto creado por Juan Macías con idea original de Xenock. Enlace al repositorio original

Este repositorio contiene un servidor con los paquetes necesarios para iniciar cualquier proyecto en Node.js

Todo está requerido en el archivo package.json, solo tienes que descargar este repositorio y ejecutar:

npm install --save

Y tendrás instalados todos los paquetes con ese comando.

Características:

  • App.js solo 10 líneas:

App.js

  • Diseño siguiendo el patrón MVC (Modelo, Vista, Controlador)
  • En lugar de llevar a cabo la acción del controlador en las rutas, pasamos a ejecutar las acciones al controlador. Código mas limpio y ordenado.
  • Middeware para guardar los datos del usuario y enviarlo a cualquier petición. (res.locals.user)

Idea original: Xenock

About

Base Node Express Project for Ironhack Students


Languages

Language:JavaScript 70.9%Language:HTML 27.6%Language:CSS 1.5%