Remove redis and add healthcheck endpoint
This commit is contained in:
@@ -31,6 +31,19 @@ app.use(express.json())
|
||||
app.set('view engine', 'ejs')
|
||||
app.use(express.static('views/public'))
|
||||
|
||||
// Health check endpoint
|
||||
app.get(['/health', '/healthz', '/api/health'], (req, res) => {
|
||||
const mongoose = require('mongoose')
|
||||
const isDbConnected = mongoose.connection.readyState === 1
|
||||
res.status(isDbConnected ? 200 : 503).json({
|
||||
status: isDbConnected ? 'healthy' : 'unhealthy',
|
||||
uptime: process.uptime(),
|
||||
timestamp: new Date().toISOString(),
|
||||
service: 'belonging-manager-api',
|
||||
database: isDbConnected ? 'connected' : 'disconnected',
|
||||
})
|
||||
})
|
||||
|
||||
app.use('/api', routerEndpoints)
|
||||
|
||||
const { registerEventHandlers } = require('./events/index')
|
||||
|
||||
Reference in New Issue
Block a user