Section 13: Creating JSON API's with Node and Mongo Flashcards

1
Q

Define IDE

A

Integrated development environment.

An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools and a debugger.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you start writing a node application so that you can keep track of all dependencies?

A

With the command:

‘npm init’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you install express?

A

npm install –save express

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What steps are needed to start the most basic express app?

A
  1. Install express
  2. Require express
    express = require(‘express’)
  3. Execute contents of express
    app = express()
  4. Start server
    app.listen()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you stop the server, or Mongod in the terminal?

A

ctrl + c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you define a schema with mongoose?

A
var newSchema = new mongoose.Schema({
      completed: {
          type: Boolean, 
          default: false
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you declare a mongoose model?

A

var Todo = mongoose.model(‘Todo’, todoSchema);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you export things out of a js file while using node.js?

A

Use:

module.exports = (thing-to-export)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you start a MongoDB?

A

./mongod

In the root directory, and leave it running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you get ‘/api/todos’ in front of all of your routes?

A

app. use(‘/api/todos’, todoRoutes);

* This will put that prefix in front of all of them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you gain the ability to reference the body?

A
  1. Install Body Parser:
    npm install –save body-parser
  2. Require it:
    bodyParser = require(‘body-parser’);
  3. Use it: (twice)
    app. use(bodyParser.json());
    app. use(bodyParser.urlencoded({extended: true}));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you get things out of the GET request?

A

router.get(‘/:todoID’, function(req, res){
db.Todo.findById(req.params.todoID);
})

  • You pass in the id in as a route variable, and then it’s stored in the ‘params’ object under the id you gave it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Name the 7 routes

A
  1. Index
  2. New
  3. Create
  4. Show
  5. Edit
  6. Update
  7. Destroy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s the route, URL and HTTP Verb to display a list of all blogs?

A

Index
/blogs
GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s the route, URL and HTTP Verb to show a form to make new blogs?

A

New
/blog/new
GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the route, URL and HTTP Verb to add a new blog to database, then redirect?

A

Create
/blogs
POST

17
Q

What’s the route, URL and HTTP Verb to show info about one blog?

A

Show
/blogs/:id
GET

18
Q

What’s the route, URL and HTTP Verb to show an edit form of one blog?

A

Edit
/blogs/:id/edit
GET

19
Q

What’s the route, URL and HTTP Verb to update a particular blog, then redirect?

A

Update
/blogs/:id
PUT

20
Q

What’s the route, URL and HTTP Verb to delete a particular blog, then redirect?

A

Destroy
/blogs/:id
DELETE