This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/health-check/src/index.js

35 lines
989 B
JavaScript
Raw Normal View History

process.env.NODE_ENV = process.env.NODE_ENV || "development";
if (!process.env.PORTAL_URL) {
throw new Error("You need to provide PORTAL_URL environment variable");
}
const express = require("express");
const bodyparser = require("body-parser");
2020-09-18 11:40:14 +00:00
const db = require("./db");
require("./schedule");
2020-07-27 17:03:05 +00:00
const host = process.env.HOSTNAME || "0.0.0.0";
2020-07-30 10:00:58 +00:00
const port = Number(process.env.PORT) || 3100;
const server = express();
server.use(bodyparser.urlencoded({ extended: false }));
server.use(bodyparser.json());
2020-09-18 11:40:14 +00:00
server.use((req, res, next) => {
db.read();
next();
2020-09-18 14:59:46 +00:00
});
2020-09-09 12:25:00 +00:00
server.get("/health-check", require("./api/index"));
2020-09-10 10:15:54 +00:00
server.get("/health-check/critical", require("./api/critical"));
server.get("/health-check/verbose", require("./api/verbose"));
2020-09-09 12:53:05 +00:00
server.get("/health-check/disabled", require("./api/disabled"));
server.listen(port, host, (error) => {
if (error) throw error;
console.info(`Server listening at http://${host}:${port} (NODE_ENV: ${process.env.NODE_ENV})`);
});