zappyzep/backend/src/api/index.ts

21 lines
583 B
TypeScript
Raw Normal View History

import { connect } from "../data/db";
import path from "path";
import { setIsAPI } from "../globals";
2019-05-26 00:13:42 +03:00
require("dotenv").config({ path: path.resolve(process.cwd(), "api.env") });
2019-08-04 15:45:35 +03:00
function errorHandler(err) {
2019-08-22 01:22:26 +03:00
console.error(err.stack || err); // tslint:disable-line:no-console
2019-08-04 15:45:35 +03:00
process.exit(1);
}
process.on("unhandledRejection", errorHandler);
setIsAPI(true);
// Connect to the database before loading the rest of the code (that depend on the database connection)
2019-08-22 01:22:26 +03:00
console.log("Connecting to database..."); // tslint:disable-line
2019-05-26 00:13:42 +03:00
connect().then(() => {
import("./start");
2019-05-26 00:13:42 +03:00
});