Skip to content

Instantly share code, notes, and snippets.

@erockdotdev
Created May 1, 2017 02:26
Show Gist options
  • Save erockdotdev/4a848b6aa8647af96ff99359a5eabdf4 to your computer and use it in GitHub Desktop.
Save erockdotdev/4a848b6aa8647af96ff99359a5eabdf4 to your computer and use it in GitHub Desktop.
Express Questions

Now some writing. Answer the following questions with one or two sentences in a separate markdown file.

  1. What is a templating language and why do we use it?

    A templating language lets you use javascript in the view file. You can use partials to make resuable parts of code for multiple pages and have access to json objects and can used that information to manipulete the DOM.

  2. How do express routes work? Routes take in client request and reply with a response with the data requested or error message

    What is the difference between app.use('/') and router.get('/')? app.use('/') sets the path for '/' and the data with in that path. Router.get('/') is used to retrieve what '/' was set to.

  3. Explain the word middle in express middleware.

    Middleware is any number of functions that are invoked by express js routing layer before your final request handler is made.

    Order app.use is mounted before the next - order matters

  4. How do the request and response objects relate to express middleware?

    Functions that happen in between http request and http response.

  5. What are express query strings? how and why do we use them? express querry strings are part of the url that we use to enter in a value that we then want to search for. In express we capture that by using req.query and saving that data to a variable.

  6. Explain what CORS is, what does it protect you from? What does it let through and what does it block? Cross Origin Resource Sharing - It blocks other domains form accessing your data (other than images) through an ajax request. If you white list an particular site, or whitlist everyone - then requests can ba made to your sites data.

  7. Explain how npm is realted to the package.json file. What happens when you run npm install?

    npm reads dependencies in package.json and compares that with the installed modules. It will install what is listed in dependencys from npm's service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment