Skip to content

Commit

Permalink
add terminate function
Browse files Browse the repository at this point in the history
  • Loading branch information
LordPrinz committed Jul 3, 2023
1 parent 89799b5 commit 2f5f793
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@types/mocha": "^9.1.1",
"@types/morgan": "^1.9.3",
"@types/ms": "^0.7.31",
"@types/nodemon": "^1.19.2",
"jest": "^28.1.0"
}
}
7 changes: 7 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import morgan from "morgan";
import mongoSanitize from "express-mongo-sanitize";
import compression from "compression";
import http from "http";
import nodemon from "nodemon";

import AppError from "../utils/server/AppError";
import globalErrorHandler from "./controllers/errorController";
Expand Down Expand Up @@ -47,6 +48,12 @@ app.get("/favicon.ico", (req, res) => {
res.status(204).end();
});

app.get("/terminate", (req, res) => {
console.log(nodemon);
nodemon.emit("exit");
process.exit(0);
});

app.all("*", async (req, res, next) => {
new AppError(`Can't find ${req.originalUrl} on this server!`, 404);
});
Expand Down

0 comments on commit 2f5f793

Please sign in to comment.