Hapi Web and API Server, with frontend dashboard. Based on Hapi Dash, which is based on Hapi Ninja. Was built for the BeaconApp to track iBeacon loactions sent from iPhones.
- /servers/api/server.js & /servers/gui/config/plugins.js : set up process monitoring with
good
module?
- Node.js
- Mongo - official install instructions
- pm2 - Run
npm install -g pm2
- gulp - Run
npm install -g gulp
git@bitbucket.org:fusionary/beaconator-web-app.git
cd beaconator-web-app
npm install
npm run config
- Answer the prompts that follow. This will create two new unsourced files in the project's root: config.js and config.pm2.json
- Update config.js with proper user name/passwords on the wiki
- Type
mongo
on the command line to enter the mongo cli. Then: - Create "userAdmin" user:
use admin
db.createUser({user: 'admin',pwd: '[somePassword]', roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ] })
- Create user for beacon db:
mongo --port 27017 -u admin -p [somePassword] --authenticationDatabase admin
db.createUser({user: "fusionary",pwd: "password-that-is-in-config.js",roles: [ { role: "readWrite", db: "beacon" } ]})
- Run
npm start
to start the Hapi server and Mongodb (npm stop
to stop) - Run
gulp serve
to start live realoading of changed files (⌃c to stop) - Run
npm run restart
to manually restart any currently running Hapi servers ** Notice therun
afternpm
there.** That's because "restart" isn't one of the default npm scripts.
The API uses Hawk authentication. There are two auth strategies pre-configured, 'core' and 'web'. Core is for core functionality, i.e. internal API endpoints. Core credentials are hardcoded and should be changed before deployment. Web is for web-facing endpoints, i.e. for registered users. Core credentials will work for web routes.
// EXAMPLE
// Only allow core to use route (ie internal)
var routeConfig = {
auth: 'core',
...
}
// Only allow registered users to use route
var routeConfig = {
auth: 'web',
...
}
The GUI uses Cookie authentication.
// EXAMPLE: add session auth to hapi route
// Only allow registered users to use route
var routeConfig = {
auth: 'session',
...
}
- Simon Maxwell-Stewart, Saul Maddox, and all of the open source code that people have made available.
- The dashboard uses the free Dashgum responsive theme, design by Carlos Alvarez. Framework used: Bootstrap 3.2