diff --git a/src/api/index.ts b/src/api/index.ts index 113d8990..8daeda13 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -7,9 +7,19 @@ import { initArchives } from "./archives"; import { connect } from "../data/db"; import path from "path"; import { TokenError } from "passport-oauth2"; +import { PluginError } from "knub"; require("dotenv").config({ path: path.resolve(__dirname, "..", "..", "api.env") }); +function errorHandler(err) { + // tslint:disable:no-console + console.error(err.stack || err); + process.exit(1); + // tslint:enable:no-console +} + +process.on("unhandledRejection", errorHandler); + console.log("Connecting to database..."); connect().then(() => { const app = express();