# 2008-FSA Cookie Jar: Express, Async/Await
## In today’s lecture we added `morgan` to our package as a dev dependency, and used it in our server code. (If I understand correctly,) Dev dependencies aren’t installed if the package is installed for production.
***Question continued:*** If we intended to publish this code on `npm` for others to use in production, would we need to go back through our server code and strip out uses of the `morgan` module?
- ***Answer:***
- First, I want to address the second part of your question, and distinguish the difference between node modules and web application code.
**Node modules** are packages that engineers **leverage** in their web applications (e.g. `const express = require('express')`). These node modules have a vast variety of dependences themselves (see `package-lock.json` file) that are simultaneously installed when you install the desired node module. For example, take a look at the [`express` npm page](https://www.npmjs.com/package/express). Click the "Dependencies" tab. You can see there are 30 dependencies and 18 dev dependencies in the `express` library - so by running `npm install express`, you are also installing all of these dependencies.
In your question, what "If we intended to publish this code on `npm` for others to use" implies to me is that you're building an npm node module like Express, Morgan, Nodemon, etc. If Morgan is a part of your npm node module you're building then it sounds like it would be a dependency of it.
- While we haven't covered `webpack` yet, it will be covered next week. I highly suggest taking a look at this article, [JavaScript Ramblings: Do "dependencies" and "devDependencies" matter when using Webpack?](https://jsramblings.com/do-dependencies-devdependencies-matter-when-using-webpack/).
- **TL;DR** When using Webpack to bundle your application for production, where you put your dependencies in package.json **doesn't matter** - as Webpack will simply follow **all** import statements, starting with the entryPoint. So, even if `morgan` runs in production, the client cannot see its logs since they exist on the server (backend) not the browser (frontend). HOWEVER, if you have `console.log`s in the frontend, they **will** print in the browser's console. (We haven't gotten there yet.) If you keep the console open as you browse the internet, you might find that a number of websites accidentally (or maybe purposefully) leave logs in their production code bases.
## What is the difference between a tagged template literal and a template literal? What are the use cases? Thanks!
***Related questions from Exit Ticket:*** What is the purpose of a tagged template literal? **AND** Why is escaping important, (asking because partner and I had issues with trying to use two of the html template literal tags at once, and had to cancel autoescape)
- ***Answer:*** Please refer to the following article to shed more light:
- [JavaScript: Tagged Template Literals](https://medium.com/@js_tut/tagged-template-literals-1e1f175c21e4)
- _Note, we won't really be seeing these after this week._
## Does order matter when it comes to how we define our routes, middleware?
- ***Answer:*** Please see morning review demo code, specifically, the `server.js` file.
## Dynamic route handling with parameters
- ***Answer:*** Please see morning review demo code, specifically, the `server.js` file.
## I'm not sure if we covered it, but if we don't use express, what syntax is used for get request. Further, what declarative syntax defines a get request for client side vs server side ( maybe I can explain this in more depth if its not clear what I am asking). Thanks!
- ***Answer:*** Please see morning review demo code, specifically, the `server.js` file.
## The bonus section, specifically how to use node time-ago
- ***Answer:*** `node-time-ago` is an npm package. Please refer to the [documentation](https://github.com/thatisuday/npm-time-ago#readme). The code snippet shows that once you install (`npm install node-time-ago`) and require it into your file (`const timeAgo = require('node-time-ago'`), you can pass a date into the `timeAgo` method in order to calculate how long ago that date is from now relatively speaking (e.g. "a minute ago", "3 months ago", etc.).
## How to correctly use error handling
- ***Answer:*** Depends on the code. If you're using `async`/`await`, use `try`/`catch` blocks (see Lab: Async/Await solution code linked in your cohort repo). If you are Promise chaining (i.e. `Promise.then()`...) _then_ use a `.catch` at the end of your code to catch an error that may be thrown upstream in the chain. Please see the morning review demo code in the `sandbox.js` file linked in your cohort repo.