This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"start": "nodemon ./bin/www" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
mongoose.connect('mongodb://127.0.0.1:27017/todoapp', { useMongoClient: true}) | |
.then(()=> { console.log(`Succesfully Connected to the Mongodb Database at URL : mongodb://127.0.0.1:27017/todoapp`)}) | |
.catch(()=> { console.log(`Error Connecting to the Mongodb Database at URL : mongodb://127.0.0.1:27017/todoapp`)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bluebird = require('bluebird') | |
/* | |
Other Codes | |
*/ | |
var mongoose = require('mongoose') | |
mongoose.Promise = bluebird |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var router = express.Router() | |
var todos = require('./api/todos.route') | |
router.use('/todos', todos); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var router = express.Router() | |
// Getting the Todo Controller that we just created | |
var ToDoController = require('../../controllers/todos.controller'); | |
// Map each API to the Controller FUnctions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
var mongoosePaginate = require('mongoose-paginate') | |
var ToDoSchema = new mongoose.Schema({ | |
title: String, | |
description: String, | |
date: Date, | |
status: String | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gettign the Newly created Mongoose Model we just created | |
var ToDo = require('../models/todo.model') | |
// Saving the context of this module inside the _the variable | |
_this = this | |
// Async function to get the To do List | |
exports.getTodos = async function(query, page, limit){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accessing the Service that we just created | |
var TodoService = require('../services/todos.service') | |
// Saving the context of this module inside the _the variable | |
_this = this | |
// Async Controller function to get the To do List |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Anatomy of a Async Function | |
exports.some_function = async function(){ | |
try{ | |
// await keyword pauses the execution of the function and returns the resolved value once completed | |
let value = await promise() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Other Require statements ... | |
var index = require('./routes/index.route'); | |
var users = require('./routes/users.route'); | |
// Get the API route ... | |
var api = require('./routes/api.route') |
OlderNewer