├── public ├── js │ ├── appDirectives.js │ ├── app.js │ ├── services │ │ ├── GeekService.js │ │ └── NerdService.js │ ├── controllers │ │ ├── MainCtrl.js │ │ ├── GeekCtrl.js │ │ └── NerdCtrl.js │ └── appRoutes.js ├── css │ └── style.css ├── views │ ├── geek.html │ ├── nerd.html │ └── home.html └── index.html ├── .bowerrc ├── config └── db.js ├── bower.json ├── .gitignore ├── app ├── models │ └── Nerd.js └── routes.js ├── package.json ├── README.md ├── server.js └── Gruntfile.js /public/js/appDirectives.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "public/libs" 3 | } -------------------------------------------------------------------------------- /public/css/style.css: -------------------------------------------------------------------------------- 1 | body { padding-top:30px; } -------------------------------------------------------------------------------- /config/db.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | url : 'mongodb://:@mongo.onmodulus.net:27017/uw45mypu' 3 | } -------------------------------------------------------------------------------- /public/views/geek.html: -------------------------------------------------------------------------------- 1 |
2 |

Geek City

3 | 4 |

{{ geekCtrl.tagline }}

5 |
-------------------------------------------------------------------------------- /public/js/app.js: -------------------------------------------------------------------------------- 1 | angular.module('sampleApp', ['ui.router', 'appRoutes', 'MainCtrl', 'NerdCtrl', 'NerdService', 'GeekCtrl', 'GeekService']); -------------------------------------------------------------------------------- /public/js/services/GeekService.js: -------------------------------------------------------------------------------- 1 | angular.module('GeekService', []).factory('Geek', ['$http', function($http) { 2 | 3 | 4 | 5 | }]); -------------------------------------------------------------------------------- /public/js/services/NerdService.js: -------------------------------------------------------------------------------- 1 | angular.module('NerdService', []).factory('Nerd', ['$http', function($http) { 2 | 3 | 4 | 5 | }]); -------------------------------------------------------------------------------- /public/views/nerd.html: -------------------------------------------------------------------------------- 1 |
2 |

Nerds and Proud

3 | 4 |

{{ nerdCtrl.tagline }}

5 |
-------------------------------------------------------------------------------- /public/views/home.html: -------------------------------------------------------------------------------- 1 |
2 |

Home Page 4 Life

3 | 4 |

{{ mainCtrl.tagline }}

5 |
-------------------------------------------------------------------------------- /public/js/controllers/MainCtrl.js: -------------------------------------------------------------------------------- 1 | angular.module('MainCtrl', []).controller('MainController', function() { 2 | 3 | var vm = this; 4 | vm.tagline = 'To the moon and back!'; 5 | 6 | }); -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "bootstrap": "latest", 6 | "angular": "latest", 7 | "angular-ui-router": "latest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /public/js/controllers/GeekCtrl.js: -------------------------------------------------------------------------------- 1 | angular.module('GeekCtrl', []).controller('GeekController', function() { 2 | 3 | var vm = this; 4 | vm.tagline = 'The square root of life is pi!'; 5 | 6 | }); -------------------------------------------------------------------------------- /public/js/controllers/NerdCtrl.js: -------------------------------------------------------------------------------- 1 | angular.module('NerdCtrl', []).controller('NerdController', function() { 2 | 3 | var vm = this; 4 | vm.tagline = 'Nothing beats a pocket protector!'; 5 | 6 | }); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Webstorm IDE 2 | .idea/ 3 | 4 | lib-cov 5 | *.seed 6 | *.log 7 | *.csv 8 | *.dat 9 | *.out 10 | *.pid 11 | *.gz 12 | 13 | pids 14 | logs 15 | results 16 | 17 | npm-debug.log 18 | node_modules 19 | 20 | public/libs -------------------------------------------------------------------------------- /app/models/Nerd.js: -------------------------------------------------------------------------------- 1 | // grab the mongoose module 2 | var mongoose = require('mongoose'); 3 | 4 | // define our nerd model 5 | // module.exports allows us to pass this to other files when it is called 6 | module.exports = mongoose.model('Nerd', { 7 | name : {type : String, default: ''} 8 | }); 9 | -------------------------------------------------------------------------------- /app/routes.js: -------------------------------------------------------------------------------- 1 | module.exports = function(app) { 2 | 3 | // server routes =========================================================== 4 | // handle things like api calls 5 | // authentication routes 6 | 7 | // frontend routes ========================================================= 8 | // route to handle all angular requests 9 | app.get('*', function(req, res) { 10 | res.sendfile('./public/index.html'); 11 | }); 12 | 13 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starter-node-angular", 3 | "main": "server.js", 4 | "dependencies": { 5 | "express": "~4.5.1", 6 | "mongoose": "~3.8.0", 7 | "body-parser": "~1.4.2", 8 | "method-override": "~2.0.2" 9 | }, 10 | "devDependencies": { 11 | "grunt": "^0.4.5", 12 | "grunt-concurrent": "^1.0.0", 13 | "grunt-contrib-cssmin": "^0.12.2", 14 | "grunt-contrib-jshint": "^0.11.0", 15 | "grunt-contrib-uglify": "^0.8.0", 16 | "grunt-contrib-watch": "^0.6.1", 17 | "grunt-nodemon": "^0.4.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /public/js/appRoutes.js: -------------------------------------------------------------------------------- 1 | angular.module('appRoutes', []).config(function($stateProvider, $urlRouterProvider) { 2 | 3 | $urlRouterProvider.otherwise('/'); 4 | 5 | $stateProvider 6 | .state('home', { 7 | url: '/', 8 | templateUrl: 'views/home.html', 9 | controller: 'MainController as mainCtrl' 10 | }) 11 | 12 | .state('nerds', { 13 | url: '/nerds', 14 | templateUrl: 'views/nerd.html', 15 | controller: 'NerdController as nerdCtrl' 16 | }) 17 | 18 | .state('geeks', { 19 | url: '/geeks', 20 | templateUrl: 'views/geek.html', 21 | controller: 'GeekController as geekCtrl' 22 | }); 23 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MEAN Stack Single Page Application Starter 2 | 3 | This is a repo for a starter appliation for a Single Page MEAN Stack application. Just download and install and you have a good foundation for building application. 4 | 5 | ## Installation 6 | 1. Download the repository 7 | 2. Install npm modules: `npm install` 8 | 3. Install bower dependencies `bower install` 9 | 4. Start up the server: `node server.js` or `grunt` 10 | 5. View in browser at http://localhost:8080 11 | 12 | Use this starter kit to build any MEAN stack application you like. 13 | 14 | ## Future Additions 15 | - CRUD examples 16 | - Development and Production Environments 17 | - Link examples 18 | - Single Page AngularJS Animations 19 | - Using [Angular-ui-router](https://github.com/angular-ui/ui-router) as the routing system 20 | - Using ControllerAs syntax 21 | - [Using Grunt to automate your development](https://scotch.io/tutorials/using-gruntjs-in-a-mean-stack-application) -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Starter Node and Angular 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 40 | 41 | 42 |
43 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | // modules ================================================= 2 | var express = require('express'); 3 | var app = express(); 4 | var mongoose = require('mongoose'); 5 | var bodyParser = require('body-parser'); 6 | var methodOverride = require('method-override'); 7 | 8 | // configuration =========================================== 9 | 10 | // config files 11 | var db = require('./config/db'); 12 | 13 | var port = process.env.PORT || 8080; // set our port 14 | // mongoose.connect(db.url); // connect to our mongoDB database (commented out after you enter in your own credentials) 15 | 16 | // get all data/stuff of the body (POST) parameters 17 | app.use(bodyParser.json()); // parse application/json 18 | app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json 19 | app.use(bodyParser.urlencoded({ extended: true })); // parse application/x-www-form-urlencoded 20 | 21 | app.use(methodOverride('X-HTTP-Method-Override')); // override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT 22 | app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users 23 | 24 | // routes ================================================== 25 | require('./app/routes')(app); // pass our application into our routes 26 | 27 | // start app =============================================== 28 | app.listen(port); 29 | console.log('Magic happens on port ' + port); // shoutout to the user 30 | exports = module.exports = app; // expose app -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | // ------------------ 4 | // CONFIGURE GRUNT 5 | 6 | grunt.initConfig({ 7 | 8 | // jshint: check all js files for errors 9 | jshint: { 10 | all: ['public/js/**/*.js'] 11 | }, 12 | 13 | // todo: uglify 14 | 15 | // todo: cssmin 16 | 17 | // watch: watch css and js files and process the above tasks 18 | watch: { 19 | css: { 20 | files: ['public/css/**/*.css'], 21 | tasks: [] 22 | }, 23 | 24 | js: { 25 | files: ['public/js/**/*.js'], 26 | tasks: ['jshint'] 27 | } 28 | }, 29 | 30 | // watch our node server for changes 31 | nodemon: { 32 | dev: { 33 | script: 'server.js' 34 | } 35 | }, 36 | 37 | // run watch and nodemon at the same time 38 | concurrent: { 39 | options: { 40 | logConcurrentOutput: true 41 | }, 42 | tasks: ['nodemon', 'watch'] 43 | } 44 | }); 45 | 46 | // ------------------ 47 | // LOAD GRUNT PLUGINS 48 | 49 | grunt.loadNpmTasks('grunt-contrib-jshint'); 50 | grunt.loadNpmTasks('grunt-contrib-uglify'); 51 | grunt.loadNpmTasks('grunt-contrib-cssmin'); 52 | grunt.loadNpmTasks('grunt-contrib-watch'); 53 | grunt.loadNpmTasks('grunt-nodemon'); 54 | grunt.loadNpmTasks('grunt-concurrent'); 55 | 56 | 57 | // ------------------ 58 | // CREATE TASKS 59 | 60 | // register the nodemon task when we runt grunt 61 | grunt.registerTask('default', ['jshint', 'concurrent']); 62 | }; --------------------------------------------------------------------------------