2019-06-03 21:01:42 +03:00
|
|
|
const express = require('express');
|
|
|
|
|
|
|
|
const DAppsRoute = require('./dapps-routes');
|
|
|
|
|
|
|
|
class APIRouter {
|
|
|
|
static route(app) {
|
|
|
|
app.use('/metadata', DAppsRoute.build(express));
|
2019-07-29 17:02:52 -04:00
|
|
|
|
|
|
|
/* for ElasticBeanstalk Load Balancer healthcheck */
|
|
|
|
app.use('/healthcheck', async (req, res) => res.send('OK'))
|
2019-07-31 10:47:24 -04:00
|
|
|
|
|
|
|
/* redirect if not on https on prod */
|
|
|
|
app.use(async (req, res, next) => {
|
|
|
|
if (req.get('x-forwarded-proto') == 'http') {
|
|
|
|
res.redirect('https://' + req.headers.host + req.url);
|
|
|
|
} else {
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
});
|
2019-06-03 21:01:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-29 17:02:52 -04:00
|
|
|
module.exports = APIRouter;
|