aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@eficode.com>2018-07-12 12:48:43 +0300
committerJan Tuomi <jan.tuomi@eficode.com>2018-07-12 12:48:43 +0300
commit665c9c37df41a5ec6672a2947172ff903a563f66 (patch)
tree1478a354c7196ef665f30f14b82cf7841fd51f49
parent6700bb48e52a2f7873e700d94270c96c300c1969 (diff)
Add a frontpage template
-rw-r--r--frontpage.html29
-rw-r--r--index.js9
2 files changed, 36 insertions, 2 deletions
diff --git a/frontpage.html b/frontpage.html
new file mode 100644
index 0000000..8f69a19
--- /dev/null
+++ b/frontpage.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Welcome to faaslift!</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <style>
+ body {
+ margin: 40px auto;
+ max-width: 650px;
+ line-height: 1.6;
+ font-size: 18px;
+ color: #444;
+ padding: 0 20px;
+ font-family: Helvetica, sans-serif;
+ }
+ h1,h2,h3 {
+ line-height: 1.2;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Welcome to <strong>faaslift!</strong></h1>
+ <p>
+ 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>
+ <small>Styles partially borrowed from <a href="http://bettermotherfuckingwebsite.com/">bettermotherfuckingwebsite.com</a>.</small>
+ </body>
+</html> \ No newline at end of file
diff --git a/index.js b/index.js
index 8d5123d..6804fbe 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,6 @@
require('dotenv').config();
const chalk = require('chalk');
+const path = require('path');
if (!process.env.MONGO_URL) {
throw new Error('No MONGO_URL set in .env!');
@@ -11,8 +12,12 @@ const express = require('express');
const app = express();
const requireFromString = require('require-from-string');
-app.all('*', async (req, res) => {
- const path = req.path.split('/')[1];
+app.get('/', function(req, res) {
+ res.sendFile(path.join(__dirname + '/frontpage.html'));
+});
+
+app.all('/:path*', async (req, res) => {
+ const path = req.params.path.split('/')[0];
if (!path || path.length === 0) {
res.status(400);
res.send('Empty endpoint.');