Permalink
Browse files

GET /todos

  • Loading branch information...
amejiarosario committed Oct 2, 2014
1 parent afc9080 commit 54ab912ea9aa2b6633ae12816beb6e6c3d2702e6
Showing with 17 additions and 11 deletions.
  1. +2 −2 app.js
  2. +15 −0 routes/todos.js
  3. +0 −9 routes/users.js
View
4 app.js
@@ -6,7 +6,7 @@ var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
-var users = require('./routes/users');
+var todos = require('./routes/todos');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/todoApp', function(err) {
@@ -32,7 +32,7 @@ app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
-app.use('/users', users);
+app.use('/todos', todos);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
View
@@ -0,0 +1,15 @@
+var express = require('express');
+var router = express.Router();
+
+var mongoose = require('mongoose');
+var Todo = require('../models/Todo.js');
+
+/* GET /todos listing. */
+router.get('/', function(req, res, next) {
+ Todo.find(function (err, todos) {
+ if (err) return next(err);
+ res.json(todos);
+ });
+});
+
+module.exports = router;
View
@@ -1,9 +0,0 @@
-var express = require('express');
-var router = express.Router();
-
-/* GET users listing. */
-router.get('/', function(req, res) {
- res.send('respond with a resource');
-});
-
-module.exports = router;

2 comments on commit 54ab912

@selbekk

This comment has been minimized.

Show comment
Hide comment
@selbekk

selbekk Feb 5, 2015

Why do you still include mongoose in this file?

Why do you still include mongoose in this file?

@amejiarosario

This comment has been minimized.

Show comment
Hide comment
Owner

amejiarosario replied Aug 6, 2016

@selbekk removed!

Please sign in to comment.