Lesson 12. Capstone: Enhancing the Confetti Cuisine site with Express.js

 

After some consideration, I decided that it would be easier to rely on a web framework to assist me in building a web application for Confetti Cuisine. Building custom routes and application logic has become a tedious task, so I’m converting my application to use Express.js.

I still want the application to have home, courses, and sign-up pages. I need to convert the routes to use keywords and syntax found in Express.js. I need to make sure that I serve my static assets out of the public directory and have all necessary package.json configurations set up for launching the application locally. When I feel ready to make this transformation, I’ll start by initializing the project with npm init.

12.1. Initializing the application

To begin this site redesign, I’m going to create a new project directory called confetti_cuisine and enter that folder. Within the project folder in terminal, I’ll initialize the application package.json with npm init.

Remembering the configurations that I previously set, I’ll keep the default settings for the project name and use entry point main.js.

Now that my package.json is set up, I’m going to add a start script under "scripts", which will allow me to run the application by using npm start instead of node <filename>. I add "start": "node main.js" to my list of scripts.

Tip

Don’t forget to separate multiple script items with a comma.

12.2. Building the application

12.3. Adding more routes

12.4. Routing to views

12.5. Serving static views

12.6. Passing content to the views

12.7. Handling the errors

Summary