Node.js Theory Flashcards

Learn the basic theory surrounding Node.js. Do the labs to learn the code, will more than likely need it in the exam.

1
Q

What is a Web Server?

A

A system that listens for and responds to HTTP requests

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

What to Web Servers typically respond to requests with?

A
  • A web application with an interface (eg a HTML doc)
  • A web service. These are resources (eg info on whether a user is registered with a site), commonly in JSON or XML format.

A single server can serve both applications and data.

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

What is an API?

A

Application Programming Interface

A way of externally accessing resources made available by a web service

  • Typically specify endpoints as URLs
  • Interact with endpoints by making HTTP requests
  • Requests and responses typically use XML or JSON

We can think of requests to endpoints as being like a function/method call

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

Name the two key attributes of RESTful APIs

A

They are stateless

  • APIs don’t depend on the server remembering previous interactions with the client
  • Requests contain all info necessary to respond

Uniform Interface

  • Endpoints provide availability to interact with some collection of resources through some appropriate noun (eg /movies at the end of a URL)
  • When a client has a representation of a resource, it should have enough info to modify or delete it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 3 key features of Node.js?

A

Event driven execution
- When used properly, this allows for thousands of concurrent connections on a single thread

It is JavaScript
- This allows you to use the same language on both client and serverr

Node Package Manager

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

Should you use Asynchronous Execution loops or Synchronous Execution loops? Why

A

Asynchronous

Need to use a non-blocking I/O, otherwise functions in the stack that take a long time to execute will block execution for all users

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

Should you use the main thread for expensive computations?

A

No, never, and never synchronously wait for a response for some external system.

A function operating on the main thread blocks executions and makes the server unresponsive

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

What is Express?

A

A web application framework for node

Allows you to build web applications and services in node

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

How is data persistence maintained in a Node.js Server?

A

Node does not store data - it is designed to process HTTP requests.

Need to use a database for this

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

What is MongoDB?

A

A document oriented database

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

How is data stored in MongoDB?

A

Data is stored in a collection of JSON-like documents

It makes reading and writing from JS straightforward

The structure isn’t constrained - it can change within a collection from document to document

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