Website 4: NodeJS Session Users

A website primer for Node Express sessions using Redis for in-memory storage and Postgres for disk storage. This site is built upon Website 2: NodeJS Marko Templates which uses Marko (v4+), Twitter Bootstrap (v3.3), Bootstrap-Dialog, JQuery, lodash, numeral, moment, and zazzy-browser.

This website template includes support for (simple) page-tracking and user session management.

It also uses a docker-compose to assist in the creation and deletion of Redis/Postgres.

Install docker-compose

Follow the directions to install docker and docker-compose

Note: We purposefully retain comments in the source to assist users.

Redis and Postgres

Run Redis and Postgres in the background.

$ docker-compose -p web4 -f docker-dev.yml up -d

Destroy Redis and Postgres. This will stop the containers if they are already running.

$ docker-compose -p web4 -f docker-dev.yml down

Stop Redis and Postgres but do not destroy them.

$ docker-compose -p web4 -f docker-dev.yml stop

Install node

Download NodeJS and install the version for your operating system.

Install npm and bower modules

We include a script, install.sh that initializes:

  • local npm modules in directory node_modules
  • local bower modules in directory bower_components

Then it copies only the required files from bower_components/ into public/_third/, a directory we use to serve public web pages.

Run installation:

./install.sh

Run

We've switched to using npm, so we can easily set modes for production or development.

For production mode, run

$ npm run start

For development (debug) mode, run

$ npm run debug

Note: Type Ctrl-C to quit the server.

Open the client web browser to url http://localhost:8080.

MIT Licensed