Initial commit: Sistema de Gestión Hospitalaria

This commit is contained in:
Santiago Lavaise
2026-04-12 20:52:43 -03:00
commit 78577ec922
93 changed files with 24674 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import express from 'express';
import cors from 'cors';
import { getValue, setValue } from './db.js';
const app = express();
app.use(cors());
app.use(express.json({ limit: '5mb' }));
const PORT = process.env.PORT || 4001;
const STORAGE_KEY = 'hospital-data-v1';
app.get('/api/state', async (req, res) => {
try {
const v = await getValue(STORAGE_KEY);
if (!v) return res.json(null);
res.json(JSON.parse(v));
} catch (err) {
console.error(err);
res.status(500).json({ error: 'failed to read state' });
}
});
app.put('/api/state', async (req, res) => {
try {
const body = req.body;
await setValue(STORAGE_KEY, JSON.stringify(body));
res.json({ ok: true });
} catch (err) {
console.error(err);
res.status(500).json({ error: 'failed to save state' });
}
});
app.listen(PORT, () => {
console.log(`API server listening on http://localhost:${PORT}`);
});