feat: stabilize API startup and lifecycle management

- Refactor server initialization to separate concerns and improve error handling.
- Implement centralized environment validation using Zod.
- Introduce database, Redis, and queue lifecycle management.
- Add health check endpoints for liveness and readiness.
- Enhance error handling middleware for better response structure.
- Implement rate limiting for API endpoints.
- Add request ID middleware for traceability.
- Create Sequelize CLI configuration and baseline migration for schema management.
- Establish CI workflow with Gitea for testing and syntax checks.
- Document foundational changes and migration strategy in PHASE_0_FOUNDATION_STABILIZATION.md.
- Add Docker Compose configuration for local development and testing.
- Implement unit and integration tests for critical functionality.
This commit is contained in:
Sathira Sri Sathara
2026-09-03 13:33:26 +05:30
parent 624fce31c5
commit 267e80e2ec
40 changed files with 1682 additions and 261 deletions
+9 -4
View File
@@ -23,10 +23,12 @@ const transporter = nodemailer.createTransport({
auth: mailConfig.auth,
});
transporter.verify((err) => {
if (err) console.error("Mail server connection failed", err);
else console.log("Mail server ready");
});
if (process.env.NODE_ENV !== "test" && process.env.ENABLE_MAIL === "true") {
transporter.verify((err) => {
if (err) console.error("Mail server connection failed", { message: err.message });
else console.log("Mail server ready");
});
}
// Utility to load template and replace placeholders
const loadTemplate = (templateName, variables = {}) => {
@@ -42,6 +44,9 @@ const loadTemplate = (templateName, variables = {}) => {
};
const send = async ({ to, subject, templateName, templateVars = {}, text }) => {
if (process.env.ENABLE_MAIL !== "true") {
throw new Error("Email functionality is not enabled");
}
const html = templateName ? loadTemplate(templateName, templateVars) : undefined;
const mailOptions = {