Permalink
Browse files

Mongoose user model added

  • Loading branch information...
1 parent 5d3aa5d commit de6fe0bfc404b40d001b62df40964451c38ecd46 @Hitman666 committed Jan 7, 2015
View
@@ -0,0 +1,3 @@
+{
+ directory: 'public/js'
+}
View
@@ -0,0 +1,27 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
+node_modules
View
@@ -1 +1,9 @@
-# MEAN_MVC_3rdTutorial
+MEAN_MVC_3rdTutorial
+====================
+
+Code acompanying the third blog post (not yet publicaly published) in a series of posts which will teach you how to take advantage of the MEAN stack in becoming a full-stack JavaScript developer.
+
+[Second blog post](https://hackhands.com/delving-node-js-express-web-framework/) was all about Node.js and Express.
+[First blog post](https://hackhands.com/how-to-get-started-on-the-mean-stack/) was about getting started on the MEAN stack.
+
+![](http://www.nikola-breznjak.com/blog/wp-content/uploads/2014/11/allTheThingsInJustOneJsFile.jpg)
@@ -0,0 +1,5 @@
+exports.render = function(req, res) {
+ res.render('index', {
+ title: 'MEAN MVC'
+ });
+};
@@ -0,0 +1,11 @@
+var mongoose = require('mongoose'),
+ Schema = mongoose.Schema;
+
+var UserSchema = new Schema({
+ name: String,
+ email: String,
+ username: String,
+ password: String
+});
+
+mongoose.model('User', UserSchema);
@@ -0,0 +1,4 @@
+module.exports = function(app) {
+ var index = require('../controllers/index.server.controller');
+ app.get('/', index.render);
+};
View
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title><%= title %></title>
+</head>
+
+<body>
+ <h1><%= title %></h1>
+ <img src="img/logo.jpg" alt="Hack Hands logo">
+</body>
+</html>
View
@@ -0,0 +1 @@
+module.exports = require('./env/' + process.env.NODE_ENV + '.js');
@@ -0,0 +1,3 @@
+module.exports = {
+ db: 'mongodb://localhost/todos'
+};
View
@@ -0,0 +1,13 @@
+var express = require('express');
+module.exports = function() {
+ var app = express();
+
+ app.set('views', './app/views');
+ app.set('view engine', 'ejs');
+
+ require('../app/routes/index.server.routes.js')(app);
+
+ app.use(express.static('./public'));
+
+ return app;
+};
View
@@ -0,0 +1,10 @@
+var config = require('./config'),
+ mongoose = require('mongoose');
+
+module.exports = function() {
+ var db = mongoose.connect(config.db);
+
+ require('../app/models/user.server.model');
+
+ return db;
+};
View
@@ -0,0 +1,28 @@
+{
+ "name": "MEAN_MVC_2ndTutorial",
+ "version": "1.0.0",
+ "description": "Code acompanying the [second blog post](https://hackhands.com/delving-node-js-express-web-framework/)",
+ "main": "server.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/Hitman666/MEAN_MVC_2ndTutorial.git"
+ },
+ "keywords": [
+ "MEAN",
+ "MVC"
+ ],
+ "author": "Nikola Brežnjak <nikola.breznjak@gmail.com> (http://www.nikola-breznjak.com/)",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/Hitman666/MEAN_MVC_2ndTutorial/issues"
+ },
+ "homepage": "https://github.com/Hitman666/MEAN_MVC_2ndTutorial",
+ "dependencies": {
+ "ejs": "^2.0.6",
+ "express": "^4.10.7",
+ "mongoose": "^3.8.21"
+ }
+}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,13 @@
+process.env.NODE_ENV = process.env.NODE_ENV || 'development';
+
+var port = 1337;
+var mongoose = require('./config/mongoose'),
+ express = require('./config/express');
+
+var db = mongoose(),
+ app = express();
+
+app.listen(port);
+
+module.exports = app;
+console.log('Server running at http://localhost:' + port);

0 comments on commit de6fe0b

Please sign in to comment.