diff options
| -rw-r--r-- | index.js | 11 | ||||
| -rw-r--r-- | package-lock.json | 7 | ||||
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | views/frontpage.ejs (renamed from frontpage.html) | 11 |
4 files changed, 28 insertions, 4 deletions
@@ -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) => { diff --git a/package-lock.json b/package-lock.json index 1fa5547..23c1389 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "faaslift", - "version": "1.0.5", + "version": "1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1001,6 +1001,11 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "ejs": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", + "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==" + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", diff --git a/package.json b/package.json index e11c0ce..0c9d4eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "faaslift", - "version": "1.0.7", + "version": "1.0.8", "description": "", "main": "index.js", "scripts": { @@ -13,6 +13,7 @@ "dependencies": { "chalk": "^2.4.1", "dotenv": "^6.0.0", + "ejs": "^2.6.1", "express": "^4.16.3", "intercept-stdout": "^0.1.2", "monk": "^6.0.6", diff --git a/frontpage.html b/views/frontpage.ejs index 8f69a19..4e76a99 100644 --- a/frontpage.html +++ b/views/frontpage.ejs @@ -24,6 +24,17 @@ Get started by creating a new endpoint with the command line tool. Check out the instructions from the <a href="https://github.com/jantuomi/faaslift/blob/master/README.md">README</a>. </p> + <h3>Currently active endpoints</h3> + <% if (!locals.endpoints || locals.endpoints.length === 0) { %> + <i>No endpoints active</i> + <% } %> + <ul> + <% (locals.endpoints || []).forEach(function (endpoint) { %> + <li> + <a href="/<%= endpoint %>"><%= endpoint %></a> + </li> + <% }); %> + </ul> <small>Styles partially borrowed from <a href="http://bettermotherfuckingwebsite.com/">bettermotherfuckingwebsite.com</a>.</small> </body> </html>
\ No newline at end of file |
