{"size": 1077, "ext": "js", "max_stars_repo_path": "app.js", "max_stars_repo_name": "maltez/odessajs_kuber", "max_stars_repo_stars_event_min_datetime": "2020-08-20T05:28:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-20T05:28:32.000Z", "max_issues_repo_path": "app.js", "max_issues_repo_name": "maltez/odessajs_kuber", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app.js", "max_forks_repo_name": "maltez/odessajs_kuber", "max_forks_repo_forks_event_min_datetime": "2020-08-20T05:28:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-20T21:49:49.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 18.8947368421, "max_line_length": 52, "alphanum_fraction": 0.539461467}
const app = require('express')();
const morgan = require('morgan')('combined');
const { createServer } = require('http');

const PORT = process.env.PORT;
const HOST = process.env.HOST;
let isReady = false; 


app.use(morgan);

app.get('/health', (req, res) => {
    res.statusCode = 200;
    res.json({
        status: 'Helathy',
        message: 'Healthty host'
    })
});

app.get('/ready', (req, res) => {
    res.statusCode = isReady ? 200 : 404
    res.json({
        status: isReady ? 'Ready' : " Not Ready"
    });
});

app.get('/ping', (req, res) => {
    res.statusCode = 200;
    res.json({
        status: 'OK',
        message: 'Pong'
    });
});

process.on('SIGINT', () => {
    console.log('Bye!!!!');
    process.exit(0);
});

process.on("exit", () => {
    console.log('Kill me');
})

process.on('SIGTERM', () => {
    console.log('Just do it');
    process.exit(0);
});


const server = createServer(app);

server.listen(PORT, HOST, () => {
    console.log(`Server listen on ${HOST}:${PORT}`);
    setTimeout(() => {
        isReady = true;
    }, 20000);
});