'use strict';

const broadcastsIndexRoute = require('./broadcasts/index');
const broadcastsSingleRoute = require('./broadcasts/single');
const mongooseRoutes = require('./mongoose');
const v2MessagesRoute = require('./messages');

// middleware
const authenticateMiddleware = require('../../lib/middleware/authenticate');
const parseMessageMetadataMiddleware = require('../../lib/middleware/messages/metadata-parse');

module.exports = function init(app) {
  app.get('/', (req, res) => res.send('hi'));
  app.get('/favicon.ico', (req, res) => res.sendStatus(204));

  // authenticate all requests
  app.use(authenticateMiddleware());

  // v1
  // Restified routes.
  app.use(mongooseRoutes);
  // v2
  app.use('/api/v2/broadcasts/:broadcastId',
    broadcastsSingleRoute);
  app.use('/api/v2/broadcasts',
    broadcastsIndexRoute);
  app.use('/api/v2/messages',
    /**
     * parses Metadata like requestId and retryCount
     * TODO: We should split parsing X-Request-Id, X-Blink-Retry-Count, and X-Failure-Injection-Test
     * to a different middleware. That mw should intercept ALL requests, not just /messages.
     */
    parseMessageMetadataMiddleware(),
    v2MessagesRoute);
};

@@ -238,16 +238,94 @@
 dleware%0A
+const enforceHttpsMiddleware = require('../../lib/middleware/enforce-https');%0A
 const au
@@ -528,16 +528,94 @@
 (app) %7B%0A
+  // Enforce https%0A  app.use(enforceHttpsMiddleware(app.locals.forceHttps));%0A%0A
   app.ge

add enforce-https middleware to routes/index