Skip to content

sprint challenge complete Russell Stinson CSPT1#253

Open
rcs784 wants to merge 1 commit intobloominstituteoftechnology:masterfrom
CSPT1-TEAMS:russell-stinson
Open

sprint challenge complete Russell Stinson CSPT1#253
rcs784 wants to merge 1 commit intobloominstituteoftechnology:masterfrom
CSPT1-TEAMS:russell-stinson

Conversation

@rcs784
Copy link

@rcs784 rcs784 commented Jun 10, 2018

No description provided.


const expenseSchema = new Schema({
amount: {
type: number,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

number should be Number.

@@ -0,0 +1,26 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const objectId = Schema.Types.ObjectId;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectId should be ObjectId since we're referring it as such on line 17 and 21.

@@ -1,10 +1,94 @@
const express = require('express'); // remember to install your npm packages
const express = require('express');
const bodyParser = require('body-parser');
Copy link

@frankfaustino frankfaustino Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of version 4.16.0, Express has included a built-in JSON parsing middleware (https://expressjs.com/en/api.html#express.json). So we don't actually need body-parser anymore. We can just do this:

const express = require('express');
const server = express();

server.use(express.json());

server.get('/', (req, res) => res.send('API Running...'));

server.post('/budgets', (req, res) => {
const { title, budgetAmount } = req.body;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not using title and budgetAmount any where, we don't have to destructure the req.body object. Instead, just create your new Budget by passing req.body:

const budget = new Budget(req.body);

@frankfaustino
Copy link

Please make sure you're installing the required packages by doing the following.

In your Git-Bash window:

$ npm i express mongoose
$ npm i -D nodemon  // this installs nodemon as a dev dependency

Then run your server:

$ nodemon server.js

And test the endpoints with Postman.

@frankfaustino
Copy link

Good work, Russell! I really like the hard work you've been putting in lately! Let's keep that momentum going. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants