1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-02-12 09:17:32 +00:00
discover/back-end/routes/api-router.js
Jakub Sokołowski 4f876d5a96
add a redirect to https for production
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2019-07-31 12:32:31 -04:00

24 lines
637 B
JavaScript

const express = require('express');
const DAppsRoute = require('./dapps-routes');
class APIRouter {
static route(app) {
app.use('/metadata', DAppsRoute.build(express));
/* for ElasticBeanstalk Load Balancer healthcheck */
app.use('/healthcheck', async (req, res) => res.send('OK'))
/* 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()
}
});
}
}
module.exports = APIRouter;