File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import magicRouter from "./routes/magic.mjs";
1515import healthRouter from "./routes/health.mjs" ;
1616import batchBakeRouter from "./routes/batchBake.mjs" ;
1717
18+ const isProduction = process . env . NODE_ENV === "production" ;
19+
1820const app = express ( ) ;
1921app . 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" ,
Original file line number Diff line number Diff line change @@ -7,12 +7,9 @@ import { bake, Dish } from "cyberchef";
77 */
88router . 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 ) ;
You can’t perform that action at this time.
0 commit comments