benrondeau / Bluemix-MEAN-Stack

Template for using the MEAN stack on the Bluemix PaaS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MEAN Boilerplate Overview

This is a basic boilerplate for the MEAN stack (MongoDB, Express, AngularJS and Node.js) on IBM Bluemix.

Live Example: https://nodejs-mean-stack.mybluemix.net

This application uses the MongoDB experimental service and Node.js runtime on Bluemix.

Features

  • MVC project structure
  • Create, edit and delete user accounts
  • Authentication with username/password
  • Protected routes that can only be accessed by authenticated users
  • Bootstrap CSS framework & Cosmo theme
  • HTTPS built-in if deployed to Bluemix
  • Mongoose for MongoDB interactions.
  • PassportJS for authentication, with over 300 authentication strategies to pick from.

Application Requirements

Getting Started

Local Application Development
  1. Clone or download this repo onto your machine.
  2. Install application requirements if not done so already.
  3. Open application directory in your terminal and run npm install
  4. Rename .env.example file to .env. Edit the contents as needed, at a minimum adding your own SESSION_SECRET.
  5. Start up your local MongoDB server (typically just mongod, see docs here)
  6. Run node server.js to start your app
  7. Open a browser to the link provided in the terminal prompt to view your app
Deploy to Bluemix

Option 1 (launch this app directly from this repo):

Deploy to Bluemix

Option 2 (deploy from your local machine):

  1. Clone or download this repo onto your machine.
  2. Open a terminal prompt to the directory of your application.
  3. If you don't have a Bluemix account, create a free one here.
  4. Set your Cloud Foundry CLI tool's API endpoint to Bluemix: cf api https://api.ng.bluemix.net
  5. Login to Bluemix via the command line: cf login
  6. Create the MongoDB service on Bluemix: cf create-service mongodb 100 mean-mongo
  7. Push your app to bluemix with cf push

Problems or Questions?

Find us on Stack Overflow and tag your question with 'bluemix'.

Critical Files & Folders

File Description
manifest.yml File that defines Bluemix deployment paramaters. More info here
.env.example Set custom environment variables for your application. This is the proper way to store credentials and other sensitive values.
server.js Main server file that the Node.js runtime uses. It contains all the server logic.
/server Folder for files used by the Node.js server
/server/models/user.model.js Model for storing users in MongoDB
/public Folder for files delivered to users, such as html and css files
/public/js/app.js Angular application for manipulating and rendering data in browser

Application

  • MongoDB stores user account information and persists sessions (so that a server crash does not log out all users.)
  • Express functions Node.js middleware to handle all HTTP requests and routing.
  • Angular handles HTML templating and data manipulation.
  • Node.js is the runtime for the application.

There is also generous commenting throughout the application which helps explain critical parts of the application.

Contribute

Please create a pull request with your desired changes.

Troubleshooting

The primary source of debugging information for your Bluemix app is the logs. To see them, run the following command using the Cloud Foundry CLI:

$ cf logs <application-name> --recent

If you are not sure what your application name is, use this command to print your application name(s):

$ cf apps

For more detailed information on troubleshooting your application, see the Troubleshooting section in the Bluemix documentation.

License

See LICENSE.MD for license information.

About

Template for using the MEAN stack on the Bluemix PaaS

License:Apache License 2.0


Languages

Language:JavaScript 63.5%Language:HTML 36.2%Language:CSS 0.3%