diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-12 12:48:43 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-12 12:48:43 +0300 |
| commit | 665c9c37df41a5ec6672a2947172ff903a563f66 (patch) | |
| tree | 1478a354c7196ef665f30f14b82cf7841fd51f49 /index.js | |
| parent | 6700bb48e52a2f7873e700d94270c96c300c1969 (diff) | |
Add a frontpage template
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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.'); |
