├── Procfile ├── public ├── lang-logo.png ├── stylesheets │ └── main.css └── node.svg ├── README.md ├── .gitignore ├── app.json ├── views ├── partials │ ├── header.ejs │ └── nav.ejs └── pages │ └── index.ejs ├── index.js ├── package.json ├── config.json └── test.js /Procfile: -------------------------------------------------------------------------------- 1 | web: node index.js 2 | -------------------------------------------------------------------------------- /public/lang-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abbasikov/pimax-hardware-config/HEAD/public/lang-logo.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pimax Hardware Config 2 | 3 | This application defines the configuration for the pimax-hardware 4 | 5 | ## Running Locally -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node build artifacts 2 | node_modules 3 | npm-debug.log 4 | 5 | # Local development 6 | *.env 7 | *.dev 8 | .DS_Store 9 | 10 | # Docker 11 | Dockerfile 12 | docker-compose.yml 13 | 14 | .DS_STORE 15 | .idea 16 | .idea/vcs.xml -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Start on Heroku: Node.js", 3 | "description": "A barebones Node.js app using Express 4", 4 | "repository": "https://github.com/heroku/node-js-getting-started", 5 | "logo": "https://cdn.rawgit.com/heroku/node-js-getting-started/master/public/node.svg", 6 | "keywords": ["node", "express", "heroku"], 7 | "image": "heroku/nodejs" 8 | } 9 | -------------------------------------------------------------------------------- /views/partials/header.ejs: -------------------------------------------------------------------------------- 1 | Node.js Getting Started on Heroku 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /views/pages/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <% include ../partials/header.ejs %> 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

Hardware Configuration App for Pi Max Hardware

13 |

This is a sample Node application deployed to Heroku. It's a reasonably simple app - but a good foundation for understanding how to get the most out of the Heroku platform.

14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const config = require('./config'); 4 | 5 | app.set('port', (process.env.PORT || 5000)); 6 | 7 | app.use(express.static(__dirname + '/public')); 8 | 9 | // views is directory for all template files 10 | app.set('views', __dirname + '/views'); 11 | app.set('view engine', 'ejs'); 12 | 13 | app.get('/', function(request, response) { 14 | response.render('pages/index'); 15 | }); 16 | 17 | app.get('/config', function(request, response) { 18 | response.json(config); 19 | }); 20 | 21 | app.listen(app.get('port'), function() { 22 | console.log('Node app is running on port', app.get('port')); 23 | }); 24 | 25 | 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-js-getting-started", 3 | "version": "0.3.0", 4 | "description": "A sample Node.js app using Express 4", 5 | "engines": { 6 | "node": "8.9.1" 7 | }, 8 | "main": "index.js", 9 | "scripts": { 10 | "start": "node index.js", 11 | "test": "node test.js" 12 | }, 13 | "dependencies": { 14 | "ejs": "^2.5.6", 15 | "express": "^4.15.2" 16 | }, 17 | "devDependencies": { 18 | "request": "^2.81.0", 19 | "tape": "^4.7.0" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/heroku/node-js-getting-started" 24 | }, 25 | "keywords": [ 26 | "node", 27 | "heroku", 28 | "express" 29 | ], 30 | "license": "MIT" 31 | } 32 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "config":{ 3 | "host":"https://demo5100262.mockable.io", 4 | "serviceCallTimeoutInSecs":4, 5 | "sensors":{ 6 | "temperature":{ 7 | "pushDataToServer":1, 8 | "pushIntervalInSeconds":3, 9 | "uri":"/sensors/temperature" 10 | }, 11 | "humidity":{ 12 | "pushDataToServer":1, 13 | "pushIntervalInSeconds":2, 14 | "uri":"/sensors/humidity" 15 | }, 16 | "smoke":{ 17 | "pushDataToServer":1, 18 | "pushIntervalInSeconds":2, 19 | "uri":"/sensors/smoke" 20 | }, 21 | "airPressure":{ 22 | "pushDataToServer":1, 23 | "pushIntervalInSeconds":2, 24 | "uri":"/sensors/airpressure" 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /public/stylesheets/main.css: -------------------------------------------------------------------------------- 1 | .jumbotron { 2 | background: #532F8C; 3 | color: white; 4 | padding-bottom: 80px; } 5 | .jumbotron .btn-primary { 6 | background: #845ac7; 7 | border-color: #845ac7; } 8 | .jumbotron .btn-primary:hover { 9 | background: #7646c1; } 10 | .jumbotron p { 11 | color: #d9ccee; 12 | max-width: 75%; 13 | margin: 1em auto 2em; } 14 | .navbar + .jumbotron { 15 | margin-top: -20px; } 16 | .jumbotron .lang-logo { 17 | display: block; 18 | background: #B01302; 19 | border-radius: 50%; 20 | overflow: hidden; 21 | width: 100px; 22 | height: 100px; 23 | margin: auto; 24 | border: 2px solid white; } 25 | .jumbotron .lang-logo img { 26 | max-width: 100%; } 27 | 28 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process'); 2 | const request = require('request'); 3 | const test = require('tape'); 4 | 5 | // Start the app 6 | const env = Object.assign({}, process.env, {PORT: 5000}); 7 | const child = spawn('node', ['index.js'], {env}); 8 | 9 | test('responds to requests', (t) => { 10 | t.plan(4); 11 | 12 | // Wait until the server is ready 13 | child.stdout.on('data', _ => { 14 | // Make a request to our app 15 | request('http://127.0.0.1:5000', (error, response, body) => { 16 | // stop the server 17 | child.kill(); 18 | 19 | // No error 20 | t.false(error); 21 | // Successful response 22 | t.equal(response.statusCode, 200); 23 | // Assert content checks 24 | t.notEqual(body.indexOf("Node.js Getting Started on Heroku"), -1); 25 | t.notEqual(body.indexOf("Getting Started with Node on Heroku"), -1); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /public/node.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /views/partials/nav.ejs: -------------------------------------------------------------------------------- 1 | 34 | --------------------------------------------------------------------------------