Moved the run method to the top

This commit is contained in:
Mathias Wagner 2023-01-15 01:52:54 +01:00
parent 6f67028afb
commit 3ac0de90b6
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -20,13 +20,13 @@ app.use("/v1/", v1Router);
// Configure mongoose
mongoose.set("strictQuery", false);
// Start the backend
const run = () =>
app.listen(port, () => console.log(`LicenseAPI ${isDevelopment ? "development" : "production"} server started under port ${port}`));
// Connect to database
mongoose.connect(MONGOOSE_STRING, (error: CallbackError) => {
if (error) throw new Error(`Could not connect to database: ${error.message}`);
console.log(`Successfully connected to the database @${MONGOOSE_STRING.split("://")[1].split("/")[0]}`);
run();
});
// Start the backend
const run = () =>
app.listen(port, () => console.log(`LicenseAPI ${isDevelopment ? "development" : "production"} server started under port ${port}`));
});