1 | const paths = require("../../config/paths");
|
2 | const path = require("path");
|
3 |
|
4 | module.exports = ({app,express})=>{
|
5 | const serverRendering = app.get('view engine');
|
6 |
|
7 |
|
8 | app.get('/health', function (req, res, next) {
|
9 |
|
10 | return res.status(200).json({statusCode:200});
|
11 | });
|
12 |
|
13 | app.get('*', function (req, res,next) {
|
14 |
|
15 |
|
16 | if(serverRendering){
|
17 |
|
18 | let errors = "";
|
19 |
|
20 | if(req.session && req.session.error){
|
21 | errors = req.session.error;
|
22 | delete req.session.error
|
23 | }
|
24 |
|
25 | return res.render('index', Object.assign({
|
26 | layout:false,
|
27 | errors:errors,
|
28 | },res.locals));
|
29 | }
|
30 |
|
31 |
|
32 | res.sendFile(path.join(paths.appBuild, 'index.html'),{},(err)=>{
|
33 | if (err) {
|
34 | res.sendFile(path.join(paths.appMiddleware,"express","NotFound.html"));
|
35 | }
|
36 | });
|
37 | });
|
38 |
|
39 | return app;
|
40 | } |
\ | No newline at end of file |