Skip to content

Instantly share code, notes, and snippets.

@supercede
Created January 14, 2021 16:31
Show Gist options
  • Save supercede/062541936b1e7bde4544cbfcb8d6df93 to your computer and use it in GitHub Desktop.
Save supercede/062541936b1e7bde4544cbfcb8d6df93 to your computer and use it in GitHub Desktop.
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