checkInsight.js 826 B

12345678910111213141516171819202122232425262728293031323334
  1. const axios = require('axios');
  2. const BASE_URL = process.env.INSIGHT_URL;
  3. console.log('---- check start ----- ', BASE_URL);
  4. axios
  5. .get(`${BASE_URL}/api/v1/asd`)
  6. .then(res => {
  7. console.log(res.data);
  8. if (res.data.statusCode === 200) {
  9. console.log('---- Server OK -----');
  10. } else {
  11. throw new Error('');
  12. }
  13. })
  14. .then(err => {
  15. console.log('---- Server has some error ----');
  16. process.exit();
  17. });
  18. axios
  19. .get(`${BASE_URL}/connect`)
  20. .then(res => {
  21. // if return statusCode mean it's failed. Otherwise it will return html
  22. if (res.data.includes('<html')) {
  23. console.log('---- Client OK -----');
  24. } else {
  25. throw new Error('---- Client has some error ----');
  26. }
  27. })
  28. .catch(err => {
  29. console.log('---- Client has some error ----');
  30. process.exit();
  31. });