diff --git a/server.js b/server.js index b5f2bbe..97b16bb 100644 --- a/server.js +++ b/server.js @@ -22,6 +22,7 @@ const pool = new Pool({ database: process.env.PGDATABASE || "postgres", user: process.env.PGUSER || "postgres", password: process.env.PGPASSWORD || "", + ssl: process.env.PGSSLMODE === "require" ? { rejectUnauthorized: false } : false, }); const app = express(); @@ -96,8 +97,12 @@ app.post("/", async (req, res) => { }); // --- Старт --- -initDB().then(() => { - app.listen(PORT, () => { - console.log(`Node.js CRUD v${VERSION} — http://0.0.0.0:${PORT}`); - }); +// Сервер стартует всегда, даже если PG недоступен. +// initDB — асинхронно, ошибка логируется но не роняет под. +initDB() + .then(() => console.log("DB ready")) + .catch((err) => console.error("DB init failed:", err.message)); + +app.listen(PORT, () => { + console.log(`Node.js CRUD v${VERSION} — http://0.0.0.0:${PORT}`); });