UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit a76c541d authored by Douglas Lagemann's avatar Douglas Lagemann
Browse files

Merge branch 'BULL-3251_db_migration' into 'main'

BULL-3251: Add in stubbed health check

See merge request !3
parents 48ebc87e 45502736
No related branches found
No related tags found
1 merge request!3BULL-3251: Add in stubbed health check
const express = require('express');
const { jwtDecode } = require('jwt-decode');
const { runMigrations, getDbVersion } = require('./data/dataLayer');
const { runMigrations, getDbVersion, healthCheck } = require('./data/dataLayer');
const app = express();
const port = 8000;
const apiVersion = "0.0.1";
......@@ -17,6 +17,22 @@ app.get('/api', async (req, res) => {
res.send('Hello World! at specific path /api');
});
// Perform a health check by ensuring the data layer is healthy.
app.get('/api/health', async (req, res) => {
const dbHealth = await healthCheck();
if (dbHealth) {
res.status(dbHealth.status).json({
status: dbHealth.status,
message: dbHealth.message
});
} else {
res.status(500).json({
status: 500,
message: "Internal Server Error"
});
}
});
// Return the user's current JWT. Useful to ensure this is integrated properly in the Party Bus infrastructure.
app.get('/api/me', async (req, res) => {
try {
......
......@@ -8,6 +8,16 @@
exports.runMigrations = async () => {
}
/**
* Stub to check connectivity to database.
*/
exports.healthCheck = async () => {
return {
status: 200,
message: "Health check succeeded, but no database is deployed"
}
}
/**
* Stub to return the version number stored in the database.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment