Skip to content

Commit f67a4fb

Browse files
Manually adding changes from PR 66 (re-org of the codebase caused a merge conflict and the changes were easier to add manually)
1 parent 12bbfa7 commit f67a4fb

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/app.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import magicRouter from "./routes/magic.mjs";
1515
import healthRouter from "./routes/health.mjs";
1616
import batchBakeRouter from "./routes/batchBake.mjs";
1717

18+
const isProduction = process.env.NODE_ENV === "production";
19+
1820
const app = express();
1921
app.disable("x-powered-by");
2022

@@ -23,7 +25,7 @@ app.use(cors({
2325
origin: "*"
2426
}));
2527

26-
if (process.env.NODE_ENV === "production") {
28+
if (isProduction) {
2729
app.use(helmet({ crossOriginResourcePolicy: { policy: "cross-origin" } }));
2830
app.use(logger({
2931
level: "error",

src/routes/bake.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import { bake, Dish } from "cyberchef";
77
*/
88
router.post("/", async function bakePost(req, res, next) {
99
try {
10-
if (!req.body.input) {
11-
throw new TypeError("'input' property is required in request body");
12-
}
13-
14-
if (!req.body.recipe) {
15-
throw new TypeError("'recipe' property is required in request body");
10+
const noRecipeOrInput = !req.body.input || !req.body.recipe;
11+
if (noRecipeOrInput) {
12+
throw new TypeError(`'${!req.body.input ? "input" : "recipe"}' property is required in request body`);
1613
}
1714

1815
const dish = await bake(req.body.input, req.body.recipe);

0 commit comments

Comments
 (0)