1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-02-14 18:26:39 +00:00
discover/back-end/routes/api-router.js

24 lines
637 B
JavaScript
Raw Normal View History

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));
/* 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()
}
});
2019-06-03 21:01:42 +03:00
}
}
module.exports = APIRouter;