Node & Express Flashcards

To better remember node and express syntax and concepts

1
Q

What is the syntax to import the express library into Node?

A

const express = require(‘express’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What is this line doing?
const app = express( )
A

Returns an instance of an Express application. This application can then be used to start a server and specify server behavior.

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

What is the purpose of a server

A

To listen for requests, perform whatever action is required to satisfy the request, and then return a response.

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

Syntax to establish a port number and console log a message to verify it is working

A
const PORT = 4001;
app.listen(PORT, () => {
  console.log(`Server is listening on port ${PORT}`);
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does API Stand for?

A

Application Program Interface

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

what are the two types of databases?

A

Relational Databases, and NoSQL databases

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

What is the command to see what version of node you have installed?

A

node -v

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

how to access repl (read-eval-print-loop) in the command prompt?

A

type node and hit enter

a > character will then appear to show you are REPL is running and prompting your input

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

while in repl mode in the command prompt how can you type and have multiple lines evaluated at once?

A

type .editor, then control D when you are ready for your input to be evaluated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. How do you create a package.json in the command Prompt? 2. How do you skip the questions proceeding this command?
A
  1. npm init

2 npm init -y

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

how to get your node browser to start listening using command line?

A

nodemon

or if in folder nodemon server/index - for example

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

how to export an object to parent?

A

module.exports = {what you want to export}
can be done
module.exports = name of what you want to export
- if only exporting one thing

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

app.use(express.json());

what does the above line do?

A

takes in a javascript string and converts it to a javascript object,
configures the app to parse json from the body

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

how do u install express to your root folder on command prompt?

A

npm install express

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

how do you import a new component into main file?

A

const nameyoumakeup = require(“./filepathtocomponanteyou’reimporting”)

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

What are the commands to use for CRUD in sequential order?

A

Get, post, put, delete

17
Q

switches to new branch according to whatever name you give it

A

git checkout name

18
Q

how to return to the master branch from a git checkout

A

git checkout master

19
Q

saves all the changes since the last commit in a temporary location in a hidden.git folder,
will give you an id to recover if necessary ]

A

git stash

20
Q

define error stack trace

A

a printed message containing information about where the error occurred, what type of error was thrown, and a description of the error.

21
Q

how to install nodemon globally?

A

in the terminal
npm i -g nodemon
if on mac and have not configured permissions properly need to put sudo first

22
Q

setup port to be dynamically assigned according to the hosting environment?

A

const port = process.env.port || 5150