- https://info.ba.imgtec.org/display/IM/WEB+API+specification
- https://info.ba.imgtec.org/pages/viewpage.action?spaceKey=IM&title=Sesame+-+Creator+garage+door+opener+controller
- https://tools.ietf.org/html/rfc6750
- HATEOAS
- Heroku
- mLab
There are two ways to use the Webapp:
- Cloud Deployment
- Locally
This guide explains the process of cloud deploying the Webapp to Heroku and mLab, using their free tiers. However the performance can be improved using a payed service, or if you prefer different hosting services: AWS, Google Cloud, etc.
- Clone the project from git repository
- Rename file config.js.sample into config.js located in project root directory
- Create a Developer Console account
- Generate a set of API Keys
- Insert the API Keys into the config.js file
You can receive email and/or sms notifications about door issues. For that you need create applets on IFTTT service.
- Create an account on IFTTT service.
- Connect your account with "Maker channel" service. Select the service from list, click "connect" button and follow instructions.
- Once connected you can create your applet. From top menu select "my applets" and click "new applet".
- As a trigger select Maker Channel applet.
- As a event use one of two provided by sesame web app:
- doorstuck is used to notify you when door couldn't reach end position
- maintenance is used to notify you when door needs maintenance
- As a action service choose anything you want. Eg you can use email service to get notifications via email or sms service to get them on your phone.
- Create as many applets you want.
- Go back to web app source code. Edit config.js file end enable ifttt module by setting flag enabled to true.
- Also provide your ifttt key in config.js file. Key can be found under your ifttt acount in your profile -> services -> maker -> settings
- Sign up for an mlab free account
- Create a new database (select Single Node, Sandbox for the free tier)
- Add a user
- Get the database URI (connection string) visible on the dashboard:
mongodb://
<
dbuser>
:<
dbpassword>@<
dbuser>
.mlab.com:<
port>
/<
db_name>
- Complete the connection string with your account details. Save the connection string as mongo db configuration: $ heroku config:set MONGOLAB_URI=your_db_uri
- Create an Heroku account
- Install Heroku Command Line Interface (CLI)
- Enter your Heroku credentials: $ heroku login
- Create the application on Heroku: $ heroku create
- Edit config.js file and set HOST to an url to Your heroku app instance.
- Deploy the application on Heroku: $ git push heroku master
- Test the live application: $ heroku open
- Get the project, by ZIP download or git clone
- Install Node.js LTS
- Install the Webapp's dependencies. On projects root directory, execute: $ npm install
- Insert the API Keys into the config.js file, located in your projects root folder.
- Insert your hostname in config.js file. Remember that you need a proxy in order to get notifications from Device Server.
- Install MongoDB
- Use a proxy (e.g. Ngrok) to expose the local application on an https server
- Start the application: $ npm start
Summary:
- $ npm install
- $ npm start
POSTMAN is a REST client useful to test the Webapp.The following button opens the REST API on POSTMAN, designated by POSTMAN Collection.
NOTE: It can be necessary to adjust some variables on POSTMAN environment to run the collection.
Documentation of REST API can be generated right from source code. From root directory of the project call
npm install apidoc
apidoc -i ./api_v1
Generated documentation can be found in doc directory.
Web app uses Json Web Token to authorize incoming request. Each request sent to webapp needs an authorization header. This is
x-access-token : token
Token is based on your app secret from config.js file and can be generated either on above website or using script from inside this project.
Just call:
node ./generateJsonToken.js
and use generated token to sign Your requests.