Express Flashcards

1
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

application/json charset optional

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

What does the express.json() middleware do and when would you need it?

A

parses incoming request bodies if payload is JSON
It parses incoming JSON requests and puts the parsed data in req.body.
It is needed when content type header is application/json in the HTTP request

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

What is the significance of an HTTP request’s method?

A

Indicate the method to be performed
To tell what function you want ran in the code, e.g. (delete, get etc.)
the intent of the client but does not do anything

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

Why should a full stack Web developer know that computer processes exist?

A

Full stack Web development is based on making multiple processes work together to form one application, so having at least a cursory awareness of computer processes is necessary. This will be extremely important when learning about applications made of multiple components, such as clients, servers, and databases.
web dev is based on making multiple processes work together to form one application

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

What is the process object in a Node.js program?

A

a global object that can be accessed inside any module without requiring it

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

How do you access the process object in a Node.js program?

A

since its global it can be accessed inside any module without requiring it

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

What is the data type of process.argv in Node.js?

A

array of strings

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

What is a JavaScript module?

A

a single .js file

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

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, __dirname LOCAL

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

Give two examples of truly global variables in a Node.js program.

A

process, console and global

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

What is the purpose of module.exports in a Node.js module?

A

Module exports are the instruction that tells Node. js which bits of code (functions, objects, strings, etc.) to “export” from a given file so other files are allowed to access the exported code

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

How do you import functionality into a Node.js module from another Node.js module?

A

use the require function keyword at the top of the file then relative url

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

What is the JavaScript Event Loop?

A

the event loop is responsible for executing the code, collecting and processing events, and executing queued sub-tasks
one task at a time to an extent
look at the task queue and pushes it to the stack

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

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A

blocking assignment takes affect immediately it is processed. A nonblocking assignment takes place at the end of processing the current “time delta”
blocking on the stack, nothing else can happen until it gets popped off
non blocking refers to the task not having asynchronous, off the stack

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

What is a directory?

A

a file system that contains references to other files

type of file that lists other files

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

What is a relative file path?

A

a short hand version of the file url with no root

file path from the current location

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

What is an absolute file path?

A

The url with all the information including the root of the file full URL that goes in href
starts with /

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

What module does Node.js include for manipulating the file system?

A

‘fs” module or file module

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

What method is available in the Node.js fs module for writing data to a file?

A

writeFile method

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

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous writefile and readfile

synchronous writefilesync and readfilesync

21
Q

What is a client?

A

software making use of party requesting service

program/computer that requests access from another program/computer

22
Q

What is a server?

A

provider of the service or resource

program/computer that provides functionality to another program/computer

23
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET method

The browser looks up the IP address for the domain name via DNS. The browser sends a HTTP request to the server.

24
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET method

The browser looks up the IP address for the domain name via DNS. The browser sends a HTTP request to the server.

25
Q

What is on the first line of an HTTP response message?

A

protocol version, status code, status text

26
Q

What are HTTP headers?

A

let the client and the server pass additional information with an HTTP request or response
meta data for the response or request

27
Q

Is a body required for a valid HTTP message?

A

no, they are optional

28
Q

What is NPM?

A

large Software Registry for users to share and borrow packages
the registry is a large public database of JavaScript software and the meta-information surrounding it.
the website
the Command Line Interface (CLI)
the registry
node package manager

29
Q

What is a package?

A

A package is a file or directory that is described by a package.json file
one or more files with a package.json
packages have a package.json

30
Q

What happens when you add a dependency to a package with npm?

A

npm will download dependencies and devDependencies that are listed in package. json that meet the semantic version requirements listed for each.
package was downloaded by the registry in the directory updates the package dependencies in the package.json

31
Q

How do you add express to your package dependencies?

A

create a package.json then install it from the npm registry

npm install express

32
Q

What Express application method starts the server and binds it to a network PORT?

A

listen method

app.listen()

33
Q

How do you mount a middleware with an Express application?

A

use method of app object

Middleware functions are functions that have access to the request object (req), the response object (res)

34
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

the request object ( req ), the response object ( res )

35
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

Content-Type: application/json; charset=utf-8

36
Q

What does the express.json() middleware do and when would you need it?

A

to parse the incoming requests with JSON payloads and is based upon the bodyparser

37
Q

What is Webpack?

A
popular module bundling system built on top of Node. js
JavaScript module bundler that supports both commonJS and ECMA6
makes
38
Q

How do you add a devDependency to a package?

A

–save-dev flag

39
Q

What is an NPM script?

A

a way to bundle common shell commands for your project
property of your package.json file
commands for the npm
command line command

40
Q

How do you execute Webpack with npm run?

A
installing webpack and the webpack-cli
npm run (name of script)
41
Q

How are ES Modules different from CommonJS modules?

A

CommonJS loads modules synchronously, ES modules are asynchronous
commonJS const TodoList = require(‘./todo-list’);
ES import TodoList from ‘./todo-list’;
dont use require vs import keyword
export keyword vs module.exports
imported with { }
es modules are a part of the JS language and commonJS is not

42
Q

What kind of modules can Webpack support?

A
ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules
43
Q

What is React?

A

A JavaScript library for building user interfaces for building user interfaces based on UI components.

44
Q

What is a React element?

A

an element in the dom
React elements are plain objects,

A React element is an object representation of a DOM node or component instance building blocks
an object describing a component instance or DOM node and its desired properties

45
Q

How do you mount a React element to the DOM?

A

with the render method of the reactdom object

ReactDOM.render(element, container[, callback])

46
Q

What does express.static() return?

A

the static files requested

returns a middleware function

47
Q

What is the local __dirname variable in a Node.js module?

A

The directory name of the current module
tells you the absolute path of the directory containing the currently executing file
absolute path of the directory that the module is in

48
Q

What does the join() method of Node’s path module do?

A

combines all the string path arguments together and returns a file path