From the course: Advanced Express

Understanding and running the sample project

From the course: Advanced Express

Start my 1-month free trial

Understanding and running the sample project

- [Instructor] This course uses a sample project as starting point. You find it in the Exercise Files folder. Additionally, the Exercise Files folder contains sub folders with start and end states for every video that contains changes to the code. I've already opened the sample project. It's the meetup folder in the Exercise Files in Visual Studio Code and there you see it's a typical Express application with the main application file in server, app.js. Please take your time to get acquainted with the overall structure of the project but as you see, we have a routes directory that contains all the respective routes of the application and we have a config directory that contains the application configuration and this configuration is also environment aware as you see here on line six or line 17 because we distinguish between development, production and test. If we look at individual route, maybe one in users, index.js, we see that my routes are functions which means that in theory we could pass in arguments to parametrize the route. We will also do this in this course. This project also includes tests and by the end of this course, they should all pass successfully. Throughout the course, I will mention when to run individual tests to make sure that you are on track. So, let's try that out. First of all, to set up the project, we have to run npm install because this will pull down all our dependencies and now for our first test, I run npx, that's the new command executor of npm, mocha test/server/app.test.js and the fact that those four tests already passing successfully tells us that the basic setup of the application is done. We won't cover testing in this course but the tests contained should give you a very nice headstart on how to test different aspects of an Express application. You find all tests in the test folder. To run this application, we can execute npm start on the terminal but the project also contains a launch configuration for the debugger, so if you like, you can also start it up with an attached debugger and use all the debugging features like breakpoints. Let's look at the page, so I'm opening it in the browser localhost:3000. It's a conference or Meetup page and it's based on the project that I covered in my course Building a Website with Node.js and Express.js. The site already contains the basic building blocks for what we're going to implement throughout the course, so if we look into Account, for instance, we already have a working route for Register. For Login, we will build out the route later but the templates are all in place already. With the sample app now up and running, we are now ready to dive right into the course.

Contents