Created
January 14, 2021 16:31
-
-
Save supercede/062541936b1e7bde4544cbfcb8d6df93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from "http"; | |
import debug from "debug"; | |
import { config } from "dotenv"; | |
import app from "./app"; | |
config(); | |
const DEBUG = debug("dev"); | |
const PORT = process.env.PORT || 5000; | |
const server = http.createServer(app); | |
process.on("uncaughtException", (error) => { | |
DEBUG(`uncaught exception: ${error.message}`); | |
process.exit(1); | |
}); | |
process.on("unhandledRejection", (err) => { | |
DEBUG(err); | |
DEBUG("Unhandled Rejection:", { | |
name: err.name, | |
message: err.message || err, | |
}); | |
process.exit(1); | |
}); | |
server.listen(PORT, () => { | |
DEBUG( | |
`server running on http://localhost:${PORT} in ${process.env.NODE_ENV} mode` | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment