const express = require('express');
const nunjucks = require('nunjucks');

const nextBusArrivals = require('./api/nextBusArrivals');

const app = express();

app.set('port', process.env.PORT || 4444);

// setup template engine
nunjucks.configure('./', {
    autoescape: true,
    express: app
});

app.set('view engine', 'nunjucks');

// routes
app.get('/', (req, res) => {
  // hard-coded for sanity testing
  nextBusArrivals('MTA NYCT_B63', 308209)
    .then((arrivals) => {
      res.render('index.html', {arrivals});
    });
});

app.listen(app.get('port'), () => {
  console.log(`listening on port ${app.get('port')}`)
})

const express = require('express');
const nunjucks = require('nunjucks');

const nextBusArrivals = require('./api/nextBusArrivals');

const app = express();

app.set('port', process.env.PORT || 4444);

// setup template engine
nunjucks.configure('./', {
    autoescape: true,
    express: app
});

app.set('view engine', 'nunjucks');

// routes
app.get('/', (req, res) => {
  nextBusArrivals(req.query.route, req.query.stop)
    .then((arrivals) => {
      res.render('index.html', {arrivals});
    });
});

app.listen(app.get('port'), () => {
  console.log(`listening on port ${app.get('port')}`)
})

Replace hardcoded API call with parameterized call
Replace hardcoded API call with parameterized call

Previous API call had a preset route and stop the server could retrieve
information for. This commit replaces that preset call with a generic
one that parses the URL string for user-supplied stop and route
arguments.

An example call could be:
"/?route=MTA NYCT_B63&stop=308209"
