Add auto-read api/version
This commit is contained in:
parent
db509a61bb
commit
bcc9ffff74
1 changed files with 5 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import dotenv from 'dotenv';
|
||||
import fs from 'fs/promises';
|
||||
import { medicationRouter } from './services/medications/index.js';
|
||||
import { shiftsRouter } from './services/shifts/index.js';
|
||||
import { shiftRunQuery } from './services/shiftConnection.js';
|
||||
|
|
@ -45,9 +46,12 @@ app.get('/api/db-health', async (req, res) => {
|
|||
res.status(500).json({ connected: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/version', async (req, res) => {
|
||||
try {
|
||||
res.json('1.0.9');
|
||||
const packageData = await fs.readFile('./package.json', 'utf8');
|
||||
const pkg = JSON.parse(packageData);
|
||||
res.json(pkg.version);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({ connected: false, error: err.message });
|
||||
|
|
|
|||
Loading…
Reference in a new issue