Skip to content

brentwalter/sampleExpressApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Express App

Installation and Setup

You need to have Node.js installed, then:

  1. Clone the repo: git clone https://github.com/brentwalter/sampleExpressApp.git
  2. cd sampleExpressApp
  3. Install project dependencies: npm install (use sudo if necessary)
  4. Start the app in development mode: node app.
  5. [OPTIONAL] If you want to connect to a database, fill out the config/database.example.js file, and rename it to database.js. Then start your app with NODE_ENV=production node app. Your database will need a schema that is compatible with the SQL queries in the models.

Demonstrated Features

  • Structuring Express.js application with sub-applications
  • Serving static assets with Express.js
  • Creating external REST, JSON APIs
  • Rendering a view with Jade templates via Express and the jade module
  • Consuming external APIs with the request module
  • Managing multiple asynchronous operations with the async module
  • Managing MySQL database requests by creating models based on the mysql module
  • Mocking database requests with the use of NODE_ENV environment variable

App Pages

  • http://localhost:3000/: view the dashboard page

App Data API Endpoints

  • http://localhost:3000/api/donations: get summary data for donations
  • http://localhost:3000/api/campaigns: get summary data for campaigns

App Project Structure

app.js              [MAIN FILE THAT INITIALIZES APPLICATION]
app                 [HOLDS THE MAIN APPLICATION LOGIC]
├── campaigns-api   [EXTERNAL JSON API]
│   └── index.js
├── dashboard-page  [RENDERS MAIN DASHBOARD PAGE]
│   ├── dash.jade
│   └── index.js
├── donations-api   [EXTERNAL JSON API]
│   └── index.js
├── models          [RETURN DATA FROM DATABASE]
│   ├── campaigns
│   │   ├── index.js
│   │   └── mock.js
│   └── donations
│       ├── index.js
│       └── mock.js
└── views            [SHARED TEMPLATE]
    └── layout.jade
config               [SETUP DATABASE CONNECTION]
└── database.example.js
public                [SERVE STATIC ASSETS]
└── style.css

About

Sample express app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published