Exercise 1 Flashcards

1
Q

What is Node.js

A

A platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

Runtime Environment for JS code.
Minimal overhead
Not a framework, not a language

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

What is Node.js Non-blocking/Asynchronous Nature about?

A
  • it is a single thread that is used to handle multiple requests
  • if a request needs to query a DB then the thread does not wait for the DB to return data, but moves to the next request and handles it
  • As soon as the DB result is ready, it is added to the event queue
  • node monitors this queue continuously and whenever it finds an event in this queue, it takes and processes it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Node.js event loop

A

The Node.js event loop is a single-threaded model that allows asynchronous processing. It works by continuously checking the message queue for new messages (also known as “tasks”) and executing them one by one. Once all the tasks are done, the event loop checks the queue again for new messages. This cycle continues until the process is stopped. The event loop provides non-blocking I/O and helps in managing the concurrency in Node.js applications.

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

callback

A

A function that is called when a certain event or operation is completed.

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

when to use node.js?

A

Real time applications: apps that have to process a high volume of short messages and require low latency

Fast and scalable environment:
- many requests with low response times

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

When not to use node.js

A

CPU-heavy jobs:
- Node.js uses only a single CPU core
- CPU-heavy operations will just block incoming requests
Simple Web Applications: Using Node.js would be superfluous for simple HTML apps in which you don’t need a separate API, all data comes directly from the server

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

install express module

A

RUN npm install express

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

install express module and add in package.json

A

RUN npm install express –save

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

install express globally

A

RUN npm install -g express

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

What is REST API

A

Representational State Transfer

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

Is REST API resources based?

A

Yes. It deals with things instead of actions (like an address)

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

6 constraints that make a web service a true RESTful API

A
  1. Uniform Interface
  2. Stateless
  3. Client-server
  4. Cacheable
  5. Layered System
  6. Code on demand (optional)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is stateless about?

A

meaning that no client context is stored on the server between requests.

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

What is client-server about?

A

RESTful API must have a clear separation of responsibilities between the client and the server. The client is responsible for making requests, while the server is responsible for serving the requested data.

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

Cacheable

A

RESTful API must provide explicit and clear indications of whether the response to a request can be cached or not,

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

layered system

A

RESTful API must allow the API architecture to be composed of multiple layers of servers, each of which can improve security, scalability, and other non-functional aspects.

17
Q

How is a REST API composed?

A
18
Q

What is Mongo DB?

A

-open-source
- high-performance
- high availability
- automatic scaling