27 lines
641 B
JavaScript
27 lines
641 B
JavaScript
import { Router } from 'express';
|
|
|
|
import { query } from '../db/pool.js';
|
|
import { asyncHandler } from '../utils/asyncHandler.js';
|
|
|
|
const router = Router();
|
|
|
|
router.get(
|
|
'/',
|
|
asyncHandler(async (_req, res) => {
|
|
/*
|
|
* The health endpoint checks the database on purpose instead of only proving
|
|
* that Express can answer HTTP. In this project, the server is not useful if
|
|
* MariaDB is unavailable, so health must include that dependency.
|
|
*/
|
|
await query('SELECT 1 AS ok');
|
|
|
|
res.json({
|
|
status: 'ok',
|
|
service: 'check-list-poc-api',
|
|
database: 'connected'
|
|
});
|
|
})
|
|
);
|
|
|
|
export default router;
|