A demo app for express
- Clone this repo in
git clone https://github.com/imranhsayed/express-app
git checkout branch-name
The
express.static()
middleware that comes shipped with express, automatically servers theindex.html
on root url'/'
without having to create a route usingapp.get( '/' )
app.use( express.static( 'public' ) )
- Creates a custom middleware called loggerMiddleWare.
- Run
npm run dev
- Open browser at
http://localhost:5000
- Every time you refresh the page, a GET request to
http://localhost:5000/
is made and the middleware intercepts that request and when the response for that request is finished it calculates the time it took for that request to complete and prints that.
npm run dev
Starts Node server athttp://localhost:5000