Node / Express Flashcards

1
Q

What is the difference between Node.js and Express.js?

A

Node.js is a javascript runtime environment used to write server side code while Express.js is a web application framework that employs Node.js to run it.

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

What is the error-first callback pattern?

A

This is a pattern used in Node callbacks that means the error will be passed in as the first parameter to a callback function. if no error, this will be null and the function will proceed. otherwise, the error can be handled first in order to create a bit more efficiency by not running any more code.

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

What is -middleware -?

A

middleware is essential code that is run in the middle of an HTTP request. It will run right after the request comes in, but before any of the functionality of the route is performed. It can be used on all routes, specific routes, or even specific sets of routes when used in conjunction with a router. Because of it’s placement, it has access to req, res, and next allowing it to be very powerfully in perfoming functionality that would be common to a large set of routes.

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

What does the next function do?

A

next will send the application to the next piece of middleware (or 404 error handler if in use). When anything is passed into next as a parameter, the next function will automatically move to the error handler route which can be very useful for cleanly catching and handling errors in an application.

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

What is the value of using JSONSchema for validation?

A

JSONSchema is very easy to make and edit and has a wide variety of validation available. When building a JSON API, this can save a lot extra validation code and still keep all of the important validation on the server side.

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