api: crash on unhandled rejections
This commit is contained in:
parent
6043fd5cd3
commit
a188b0433c
1 changed files with 10 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue