Node & Express Flashcards
To better remember node and express syntax and concepts
What is the syntax to import the express library into Node?
const express = require(‘express’)
What is this line doing? const app = express( )
Returns an instance of an Express application. This application can then be used to start a server and specify server behavior.
What is the purpose of a server
To listen for requests, perform whatever action is required to satisfy the request, and then return a response.
Syntax to establish a port number and console log a message to verify it is working
const PORT = 4001; app.listen(PORT, () => { console.log(`Server is listening on port ${PORT}`); });
What does API Stand for?
Application Program Interface
what are the two types of databases?
Relational Databases, and NoSQL databases
What is the command to see what version of node you have installed?
node -v
how to access repl (read-eval-print-loop) in the command prompt?
type node and hit enter
a > character will then appear to show you are REPL is running and prompting your input
while in repl mode in the command prompt how can you type and have multiple lines evaluated at once?
type .editor, then control D when you are ready for your input to be evaluated.
- How do you create a package.json in the command Prompt? 2. How do you skip the questions proceeding this command?
- npm init
2 npm init -y
how to get your node browser to start listening using command line?
nodemon
or if in folder nodemon server/index - for example
how to export an object to parent?
module.exports = {what you want to export}
can be done
module.exports = name of what you want to export
- if only exporting one thing
app.use(express.json());
what does the above line do?
takes in a javascript string and converts it to a javascript object,
configures the app to parse json from the body
how do u install express to your root folder on command prompt?
npm install express
how do you import a new component into main file?
const nameyoumakeup = require(“./filepathtocomponanteyou’reimporting”)