aboutsummaryrefslogtreecommitdiffstats
path: root/index.js
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@eficode.com>2018-07-13 12:25:26 +0300
committerJan Tuomi <jan.tuomi@eficode.com>2018-07-13 12:25:26 +0300
commita69b3b644a9275e43a3832ed9cf3ccfbda336189 (patch)
tree3675207b5e0f31c6dadc8fd01f0e7195ac7fc349 /index.js
parentbd993ccdf8aa2cadc3722d2d169386a7b24661c7 (diff)
Add a list of endpoints to the landing page
Diffstat (limited to 'index.js')
-rw-r--r--index.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/index.js b/index.js
index 2d8f5ba..69ece12 100644
--- a/index.js
+++ b/index.js
@@ -10,12 +10,19 @@ const db = require('monk')(process.env.MONGO_URL);
const express = require('express');
const app = express();
+app.set('view engine', 'ejs');
+app.set('views', path.join(__dirname, 'views'));
+
const requireFromString = require('require-from-string');
const models = require('./models')(db);
const {installPackagesFromDatabase} = require('./npm')(models);
-app.get('/', (req, res) => {
- res.sendFile(path.join(__dirname, '/frontpage.html'));
+app.get('/', async (req, res) => {
+ const endpointObjects = await models.endpoints.find({});
+ const endpoints = endpointObjects.map(e => e.name);
+ res.render('frontpage', {
+ endpoints
+ });
});
app.all('/:path*', async (req, res) => {