32 lines
871 B
Groff
Executable File
32 lines
871 B
Groff
Executable File
sudo docker exec -it the-tip-top-backend netstat -tlnp | grep 4000
|
|
import express from "express";
|
|
import pkg from "pg";
|
|
import cors from "cors";
|
|
import dotenv from "dotenv";
|
|
|
|
dotenv.config();
|
|
const { Pool } = pkg;
|
|
const app = express();
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
// Connexion PostgreSQL
|
|
const pool = new Pool({
|
|
host: process.env.DB_HOST || "the-tip-top-db",
|
|
user: process.env.DB_USER || "thetiptop",
|
|
password: process.env.DB_PASS || "thepass",
|
|
database: process.env.DB_NAME || "thetiptop",
|
|
port: 5432,
|
|
});
|
|
|
|
// Route test
|
|
app.get("/api", async (req, res) => {
|
|
const result = await pool.query("SELECT NOW()");
|
|
res.json({ message: "API The Tip Top fonctionne ✅", time: result.rows[0].now });
|
|
});
|
|
|
|
const PORT = process.env.PORT || 3001;
|
|
app.listen(PORT, "0.0.0.0", () => console.log(`🚀 Backend The Tip Top lancé sur le port ${PORT}`));
|
|
|