The example-logging system
We've seen the main features of Express. Now let's build something real. The next few pages present a simple website where users can read only if they are logged in. Let's start and set up the application. We are going to use Express' command-line instrument. It should be installed using npm install -g express-generator
. We create a new folder for the example, navigate to it via the terminal, and execute express --css less site
. A new directory, site
, will be created. If we go there and run npm install
, Express will download all the required dependencies. As we saw earlier, by default, we have two routes and two controllers. To simplify the example, we will use only the first one: app.use('/', routes)
. Let's change the views/index.jade
file content to the following HTML code:
doctype html html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body h1= title hr p...