{"size": 535, "ext": "js", "max_stars_repo_path": "raspberry/index.js", "max_stars_repo_name": "frapontillo/actions-on-google-campobasso", "max_stars_repo_stars_event_min_datetime": "2018-03-26T09:05:42.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-26T09:05:42.000Z", "max_issues_repo_path": "raspberry/index.js", "max_issues_repo_name": "frapontillo/actions-on-google-campobasso", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "raspberry/index.js", "max_forks_repo_name": "frapontillo/actions-on-google-campobasso", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.4482758621, "max_line_length": 59, "alphanum_fraction": 0.5813084112}
'use strict';

const express = require('express');
const app = express();
const Gpio = require('onoff').Gpio;

app.get('/', (req, res) => res.send('Hello World!'));

const getLed = () => {
  return new Gpio(25, 'out');
}

app.post('/led/on', (req, res) => {
  const led = getLed();
  led.writeSync(1);

  res.send('Il LED è acceso');
});

app.post('/led/off', (req, res) => {
  const led = getLed();
  led.writeSync(0);
  led.unexport();

  res.send('Il LED è spento');
});

app.listen(3000, () => console.log('Il server è attivo!'));
