Example Web Application with ExpressJS + Ionic¶
Prerequisite¶
- Install nodejs. Can be installed from official nodejs website
- Install Ionic. Run
npm install -g ionic cordova
Steps¶
Setup Backend¶
- Go the Github repo that you have downloaded, e.g.
<your/path/to/maxis-nbiot-hackathon>. - The example project can be found on folder
WebApplication/NodeJS. - Go to the root folder of example project.
- Run command
npm installto install dependencies. - Create a file call .env at root folder of this project and write following content to the file.
AZURE_CONNECTION_STRING=<your azure iot hub connection string>
- Finally, run command
npm startto start the server.
Setup Frontend¶
- At the same folder
WebApplication/NodeJS, go to folder namedfrontend. - Run command
npm installto install dependencies. - Run
ionic serve. Open browser athttp://localhost:8010to see the result. - Run
ionic build --prodto build production files, which can be served by express server itself. If server is running, you can browsehttp://localhost:3000