Skip to content

Latest commit

 

History

History
86 lines (74 loc) · 2.98 KB

README.md

File metadata and controls

86 lines (74 loc) · 2.98 KB

Node.js Server App

Install and Run

  1. Requires node.js (install using nvm)
  2. Make sure to build the client first (instructions).
  3. Install dependencies and run server through run.sh.†
  4. Use browser to go to localhost:8010

†Set NODE_ENV=prod to run the server in production mode (e.g., w/ cache-control header set on server responses).

If you want to start the server on ports other than the defaults (8010 and 9010), or under an application prefix use

NODE_BASE_URL='/myapp' REVERSE_PROXY_PORT=8010 HTTP_SERVER_PORT=9010 npm start

You can specify these values in an env.sh file (see env.example.sh for an example), and then run run.sh.

Directory Structure

  # Existing files
    app/                # Main express.js app 
    config/             # Server configuration
    lib/                # Utility functions (e.g db querying, logging)
    proj/               # Project specific server apps (mirrors main app directory structure)
      index.js          # Hookup of server apps to main express.js
    sass/               # Templated css files
    static/             # All our static html, css, data goes here
    test/               # Need some more tests
    views/              # Template .jade (pug) files for generating html
    
  # Generated files
  node_modules/      # dependent node modules (populated by npm install)
  logs/              # generated log files go here

Setting up a new instance

  cp env.example.sh env.sh  
  # Edit env.sh to change the ports and base url
  ./build.sh
  cd server
  ./run.sh
  # Update apache settings to proxy new ports as needed

Running server side rendering server

  ./ssc-server.js

Directory Structure

  # Existing files
  app/                     # Main server app
    routes/
      proxy-rules.js       # Add routes here to access data on other servers and webservices
  config/                  # Update annotation database connection info and other configurations
  lib/                     # Utility functions 
  proj/                    # Add your project specific app code here
  sass/                    # scss (templated styles)
  static/                  # static content
    css/                   # static stylesheets
    data/                  # Global data and assets here
    html/                  # static pages
    images/
    js/
  views/                   # Templated jade files
    
  # Example project directory (mirror main app)
  proj/
    proj1/
      data/
      static/
      views/
      index.js
      
  # Generated files
  logs/              # Server logs
  node_modules/      # dependent node modules (populated by npm install)

Running style check and tests

  • Static checking and style checking <-> npm run lint
  • Unit/integration tests and code coverage* <-> npm run cover
  • Run everything! <-> npm test
    *Note: Code coverage is only over files touched by unit/integration tests