The Global Goals
Website for The United Nations Global Goals for Sustainable Development www.globalgoals.org
The application requires Node.js version 7 or later. Start with installing all dependencies by running the following command:
$ npm install
The application (both server and front end) depend on a set of environment variables. Define them in a .env file in the project root. The following command will generate a template for you which you to populate with secret keys and whatnot:
$ npm run setup
Start the server
During development use the
restart script which loads the variables in the
.env file, before starting the server. The server watches for file changes and restarts when needed.
$ npm restart
Routing to and rendering views are all handled by Choo, the server only fetches content and caches the response.
Koa is a small framework for node which uses the new
async/await syntax of ES2017. Just like most other popular web frameworks, Koa relies on middleware that intercepts and handles requests before (optionally) falling through to the next middleware. With
Promises and the new
async/await syntax this makes for building very lean and expressive applications.
Note: Choo is currently exploring ways to incorporate components at the framework level. A preview of the proposed solution is implemented in this application.
Build and deploy
When building the application, take care to update the version field in package.json. The version number is used for breaking cache and ensuring that clients are receiving up to date assets. Npm has a
version command that does just this, commits it and generates a git tag.
$ npm version 2.1.0
To build and minify the client application and styles run the build command. The build script will try and load the local
.env file so make sure to define (overwriting) the appropriate variables before executing the script.
$ NODE_ENV=production npm run build
The application is built for running on Now but is in no way required to. Any server with node installed should be able to build and host the application.