Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render application shell as static file
There's no longer a need for using an EJS template, since nothing crucial needs to be populated server-side.
- Loading branch information
Showing
4 changed files
with
11 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
import * as express from 'express'; | ||
import { Response } from 'express'; | ||
import PromiseRouter from 'express-promise-router'; | ||
import * as path from 'path'; | ||
|
||
const router = PromiseRouter(); | ||
|
||
/** | ||
* The homepage is an HTML shell that loads the client-side | ||
* application, which in turn decides which screen to display. | ||
* | ||
* The relative path to the HTML file is only valid for the JS version | ||
* of this file within the build directory. | ||
*/ | ||
router.get('/', async (req: express.Request, res: express.Response) => { | ||
const config = req.app.locals.config; | ||
|
||
let title = 'Notifier'; | ||
if (req.app.get('env') !== 'production') { | ||
title += ' ' + req.app.get('env'); | ||
} | ||
|
||
res.render('index', { | ||
base_href: config.get('NOTIFIER_BASE_URL'), | ||
title, | ||
}); | ||
router.get('/', async (_, res: Response) => { | ||
res.sendFile(path.resolve('public/index.html')); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters