Skip to main content
Node.js Code Reorder Medium +20 XP

Middleware Chain

Arrange Express middleware in the correct order.

Click lines in the correct order

Available lines5 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: app.use(express.json()); app.use(cors()); app.use(authMiddleware); app.get('/data', controller); app.listen(3000);

Global middleware (json, cors) first, then auth, then routes, then start listening.

Hint: Global middleware runs before routes; listen() comes last.

What this challenge tests

Code Reorder in Node.js: express, middleware.

Related challenges