NodeJS boilerplate for express apps
Go to file
2020-04-06 09:16:15 +02:00
.vs pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
config pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
public pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
routes pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
views pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
.gitignore Initial commit 2020-03-29 22:22:34 +02:00
app.js pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
LICENSE Initial commit 2020-03-29 22:22:34 +02:00
package.json pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00
readme.md pruned security vulnerabilities and added mail route 2020-03-31 14:57:20 +02:00

NodeJS Boilerplate for Express Apps

This repository show you a simple but powerful way to start up your NodeJS Projects with Express.

Get started

  1. Clone/Fork this repository to your computer
  2. install all requirements
    1. node
    2. mysql
  3. set the config files
    1. change "mail.js" credentials
    2. change "database.js" credentials
  4. start your development server with "npm run dev"
  5. feel free to do what you want to do

Routing

URL Method Desc
/ GET Index Site
/ POST nothing yet, work on it
/ DELETE nothing yet, work on it
/mail GET view Mail form
/mail SEND send mail via nodemailer
/api GET Your API starts here

npm Packages

Name Version Description
body-parser ^1.19.0 Parse incoming request bodies in a middleware before your handlers, available under the req.body property.
connect-flash ^0.1.1 The flash is a special area of the session used for storing messages
cookie-parser ^1.4.5 Parse Cookie header and populate req.cookies with an object keyed by the cookie names
env-cmd ^10.1.0 A simple node program for executing commands using an environment from an env file
express ^4.17.1 Fast, unopinionated, minimalist web framework for node
express-session ^1.17.0 Create a session middleware
method-override ^3.0.0 Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it
morgan ^1.10.0 HTTP request logger middleware for node.js
mysql ^2.18.1 This is a node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.
nodemailer ^6.4.6 Send e-mails from Node.js <20> easy as cake!
nodemon ^2.0.2 nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
pug ^2.0.4 Pug is a high performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers

Folder Overview

  • config: all your apps configuration files for databases, connections and other
    • .env-cmdrc.json: all environment variables for your servers
    • database.js: your database connections and table overview
    • db-test.js: test your database connection with this js
    • mail.js: your mail connection
    • robots.js: get a robot.txt file with this script
    • sitemap-generator.js: get a sitemap with this script
  • public: all files your Guests can access directly
    • css: your css files
      • main.css: a starter .css file
    • img: all your images
    • js: all your JS scripts
  • routes: whereever you are routing, keep it simple and structured
    • api.js: here every /api requests goes
    • index.js: here every / reqest goes
    • middlewear.js: use middlewear for repeating actions across multiple routes like authorisation/authentication
  • views: here lies what your guests can later see in pug.js
    • index: all files for index routes
      • index.pug: the index routes view
    • layout.pug: make it easy with a standarized layout for all your files
    • app.js: entry file to start everything up
    • gitignore: ignore some files in your git repository that don't matter
    • package.json: overview and scripts for your packages
    • package-lock.json
    • readme.md: log everything to never forget anything