#Goal
Build a simple multi-tenant server application using Hapi.JS configured with:
- Token-based Authentication (jwt)
- Simple REST API for fetching site configuration
- Minimal file-based user and site management, ready to be swapped in with the solution of your choice
- Internationalization with use of Accept-language header
This application is meant to be accessed solely via the REST API and it's /api endpoint. It is designed to be published under a single domain alongside kit-client-react which provides a single-page-app (SPA) user experience.
- node
^6.2.0
for use of basic es2015 language features though earlier could work - npm
^3.0.0
$ cd into top-level directory
$ npm install
Settings can be found in settings/settings.js
.
- Register a Mapbox account and generate your own readonly key. Enter as token for each view
npm start
The server app should now be listening on port 3001
The settings file has some reasonable defaults but before publishing this application publicly you must generate a new secret key and user account passwords at the very least so that the user account and web tokens are not compromised.
- Generate and set the secret key
- Create and set new users and passwords.
PM2 is a great production process manager for the Node environment. You should install it on your system and then start the server process
pm2 start server
server
simple refers to the server.js filename
If you make code changes or upgrade versions you will need to restart the process
pm2 restart server
By default the application will listen on port 3001 and is setup to be published together under the same domain with kit-server-client
. The easiest way to make this work is to use a web server like NGINX to reverse proxy requests from port 80/443 to port 3001. See the documentation for the client to see how to configure it with NGINX.
# Server app reverse proxy
location /api {
proxy_pass http://127.0.0.1:3000;
}