W6. NodeJS Express Flashcards
What is the purpose of Express?
Express is a framework for Node.js
Makes it easier to make RESTful APIs
Provides structure for server-side code to mirror structure in URL code we are serving
What are 3 benefits of using Express?
- ) Defines a routing table used to perform different actions based on HTTP Method and URL
- ) Permits dynamic rendering of HTML pages based on passing arguments to templates
- ) Makes server code simpler by imposing structure
(also ability to mix static HTML with web pages
What is the purpose of Routes?
Allow you to tidy-up directory structure and scale up a web server to industrial-scale structure
What are templates?
- static template files
- describe some structure expanded into HTML
- HTML expressed at higher-level using template language
- At runtime, a template engine converts all variables in template into actual values and sends HTML to the client
What template engine does Express use by default?
Pug (formerly Jade)
Advantages and disadvantages of Pug
Advantages:
- templating allows boilerplate pages to be created that can be specialised
- Good readability - write paragraphs
- indentation (white space) instead of tags for structure
Disadvantages:
- white space indentation is error prone
- cannot use a mixture of template language and HTML, in Pug - only Pug!