Taha Saif
Deploy Ecom Hub API backend (Express + Drizzle + Clerk + R2)
74bfb65
Raw History Blame Contribute Delete
786 Bytes
import app from "./app";
import { logger } from "./lib/logger";
import { bootstrapAdmin } from "./lib/bootstrapAdmin";
const rawPort = process.env["PORT"];
if (!rawPort) {
throw new Error(
"PORT environment variable is required but was not provided.",
);
}
const port = Number(rawPort);
if (Number.isNaN(port) || port <= 0) {
throw new Error(`Invalid PORT value: "${rawPort}"`);
}
bootstrapAdmin().then(() => {
app.listen(port, (err) => {
if (err) {
logger.error({ err }, "Error listening on port");
process.exit(1);
}
logger.info({ port }, "Server listening");
});
}).catch(error => {
logger.error({ message: error instanceof Error ? error.message : 'Unknown setup failure' }, 'Admin authentication startup failed');
process.exit(1);
});