add api status check
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
<link rel="shortcut icon" href="favicon.ico" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<!--
|
<!--
|
||||||
manifest.json provides metadata used when your web app is installed on a
|
manifest.json provides metadata used when your web app is installed on a
|
||||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
-->
|
-->
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="manifest.json" />
|
||||||
<!--
|
<!--
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
|||||||
@@ -1,9 +1,36 @@
|
|||||||
import React from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
export default function Home () {
|
class Home extends Component {
|
||||||
return (
|
state = {
|
||||||
<div>
|
apiStatus: 'loading',
|
||||||
<h3>Sima Space - CRM Integration</h3>
|
};
|
||||||
</div>
|
|
||||||
);
|
componentDidMount() {
|
||||||
|
fetch('/api')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(result => {
|
||||||
|
console.log(result);
|
||||||
|
if (result.status === 1) {
|
||||||
|
this.setState({apiStatus: 'working'});
|
||||||
|
} else {
|
||||||
|
this.setState({apiStatus: 'NOT WORKING !'});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.setState({apiStatus: `ERROR : ${err}`});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const {apiStatus} = this.state;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3>CRM Integration</h3>
|
||||||
|
<hr/>
|
||||||
|
<h5>Integration API Status : {apiStatus}</h5>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Home;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const apiStatusCheck = (req, res) => {
|
const apiStatusCheck = (req, res) => {
|
||||||
res.send({status: 1});
|
res.json({status: 1});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
10
server.js
10
server.js
@@ -1,20 +1,20 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const routes = require('./routes');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const routes = require('./routes');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = process.env.PORT || 5000;
|
const port = process.env.PORT || 5000;
|
||||||
|
|
||||||
|
|
||||||
|
app.use('/api', routes);
|
||||||
|
|
||||||
//Static file declaration
|
//Static file declaration
|
||||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||||
|
|
||||||
//production mode
|
//production mode
|
||||||
if(process.env.NODE_ENV === 'production') {
|
if(process.env.NODE_ENV === 'production') {
|
||||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
|
||||||
//
|
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
res.sendfile(path.join(__dirname = 'client/build/index.html'));
|
res.sendfile(path.join(__dirname = 'client/build/index.html'));
|
||||||
});
|
});
|
||||||
@@ -22,9 +22,7 @@ if(process.env.NODE_ENV === 'production') {
|
|||||||
|
|
||||||
//build mode
|
//build mode
|
||||||
app.get('*', (req, res) => {
|
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}!`));
|
app.listen(port, () => console.log(`App running on port ${port}!`));
|
||||||
|
|||||||
Reference in New Issue
Block a user