Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tut1 starter #16

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ Node provides the RESTful API. Angular provides the frontend and accesses the AP

## Tutorial Series

This repo corresponds to the Node Todo Tutorial Series on [scotch.io](http://scotch.io)

Each branch represents a certain tutorial.
- tut1-starter: [Creating a Single Page Todo App with Node and Angular](http://scotch.io/tutorials/javascript/creating-a-single-page-todo-app-with-node-and-angular)
- tut2-services: Coming Soon
- tut3-auth: Coming Soon
- tut4-sockets: Coming Soon
- tut5-redis: Coming Soon
- tut6-organization: Coming Soon
This repo corresponds to the [Node Todo Tutorial Series](http://scotch.io/series/node-and-angular-to-do-app) on [scotch.io](http://scotch.io)

Happy Todo-ing!

Expand Down
4 changes: 2 additions & 2 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {

// the database url to connect
url : 'mongodb://node:node@mongo.onmodulus.net:27017/uwO3mypu'
}
url : 'mongodb://node:nodeuser@mongo.onmodulus.net:27017/uwO3mypu'
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"main" : "server.js",
"author" : "Scotch",
"dependencies" : {
"express" : "~3.4.4",
"mongoose" : "~3.6.2"
"express" : "~4.7.2",
"mongoose" : "~3.6.2",
"morgan" : "~1.2.2",
"body-parser": "~1.5.2",
"method-override": "~2.1.2"
}
}
5 changes: 3 additions & 2 deletions public/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ function mainController($scope, $http) {
$scope.createTodo = function() {
$http.post('/api/todos', $scope.formData)
.success(function(data) {
$scope.formData.text = '';
$scope.formData = {}; // clear the form so our user is ready to enter another
$scope.todos = data;
console.log(data);
})
.error(function(data) {
console.log('Error: ' + data);
Expand All @@ -35,4 +36,4 @@ function mainController($scope, $http) {
});
};

}
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ <h1>I'm a Todo-aholic <span class="label label-info">{{ todos.length }}</span></
</div>

</body>
</html>
</html>
16 changes: 10 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ var mongoose = require('mongoose'); // mongoose for mongodb
var port = process.env.PORT || 8080; // set the port
var database = require('./config/database'); // load the database config

var morgan = require('morgan'); // log requests to the console (express4)
var bodyParser = require('body-parser'); // pull information from HTML POST (express4)
var methodOverride = require('method-override'); // simulate DELETE and PUT (express4)

// configuration ===============================================================
mongoose.connect(database.url); // connect to mongoDB database on modulus.io

app.configure(function() {
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(express.logger('dev')); // log every request to the console
app.use(express.bodyParser()); // pull information from html in POST
app.use(express.methodOverride()); // simulate DELETE and PUT
});
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(morgan('dev')); // log every request to the console
app.use(bodyParser.urlencoded({'extended':'true'})); // parse application/x-www-form-urlencoded
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
app.use(methodOverride());

// routes ======================================================================
require('./app/routes.js')(app);
Expand Down