add api status check

This commit is contained in:
Bilal Catic
2019-05-24 10:14:41 +02:00
parent ac6a738749
commit c0788d7a43
4 changed files with 41 additions and 16 deletions

View File

@@ -1,20 +1,20 @@
'use strict';
const express = require("express");
const routes = require('./routes');
const path = require('path');
const routes = require('./routes');
const app = express();
const port = process.env.PORT || 5000;
app.use('/api', routes);
//Static file declaration
app.use(express.static(path.join(__dirname, 'client/build')));
//production mode
if(process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, 'client/build')));
//
app.get('*', (req, res) => {
res.sendfile(path.join(__dirname = 'client/build/index.html'));
});
@@ -22,9 +22,7 @@ if(process.env.NODE_ENV === 'production') {
//build mode
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname+'/client/public/index.html'));
res.sendFile(path.join(__dirname + '/client/public/index.html'));
});
app.use('/api', routes);
app.listen(port, () => console.log(`App running on port ${port}!`));