🩵 Fusion du code local avec le dépôt Gitea
All checks were successful
the-tip-top-backend/pipeline/head This commit looks good
All checks were successful
the-tip-top-backend/pipeline/head This commit looks good
This commit is contained in:
parent
6125dcb1f8
commit
0382efc87c
|
|
@ -1,47 +0,0 @@
|
|||
import express from "express";
|
||||
import pkg from "pg";
|
||||
import cors from "cors";
|
||||
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 || "postgres",
|
||||
password: process.env.DB_PASS || "postgres",
|
||||
database: process.env.DB_NAME || "thetiptop",
|
||||
port: 5432,
|
||||
});
|
||||
|
||||
// Route test principale
|
||||
app.get("/", (req, res) => {
|
||||
res.json({ message: "The Tip Top API is running 🚀" });
|
||||
});
|
||||
|
||||
// Route de test DB
|
||||
app.get("/db-check", async (req, res) => {
|
||||
try {
|
||||
const result = await pool.query("SELECT NOW()");
|
||||
res.json({ message: "✅ Connexion PostgreSQL OK", time: result.rows[0].now });
|
||||
} catch (err) {
|
||||
console.error("Erreur DB:", err.message);
|
||||
res.status(500).json({ error: "❌ Connexion à la base échouée" });
|
||||
}
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 4000;
|
||||
app.listen(PORT, "0.0.0.0", () => {
|
||||
console.log(`🚀 Backend The Tip Top lancé sur le port ${PORT}`);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
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}`));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user