chore(backend): bootstrap Express + TypeScript + Prisma

This commit is contained in:
SaidSoighiri94
2026-06-04 13:31:32 +02:00
parent 544e3edc04
commit bb93245fa4
7 changed files with 217 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import express from 'express';
import cors from 'cors';
import { env } from './config/env';
import { connectDatabase, disconnectDatabase } from './db/prisma';
const app = express();
// Middlewares globaux
app.use(cors());
app.use(express.json());
// Route de test
app.get('/health', (_req, res) => {
res.json({ status: 'ok', app: 'EME API' });
});
async function bootstrap(): Promise<void> {
await connectDatabase();
const server = app.listen(env.port, () => {
console.log(`[EME API] Serveur demarre sur http://localhost:${env.port}`);
});
process.on('SIGINT', async () => {
await disconnectDatabase();
server.close(() => process.exit(0));
});
}
bootstrap().catch((error: unknown) => {
console.error('[EME API] Echec du demarrage', error);
process.exit(1);
});