curriculum icon indicating copy to clipboard operation
curriculum copied to clipboard

Node Controllers: Remove express-async-handler content

Open MaoShizhong opened this issue 4 months ago • 0 comments

Because

Express v5 has been the npm current for a while i.e. what will be installed with npm install express, and rejected Promise support for async middleware is now built-in: https://expressjs.com/en/guide/migrating-5.html#rejected-promises. express-async-handler is no longer needed.

I've tested this and can confirm the exact same behaviour built in:

Crashes server in v4, catches and calls next(err) in v5:

app.get('/', async () => {
    throw new Error('catch me!');
};

Required in v4 to catch and call next(err) in v4:

const asyncHandler = require('express-async-handler');

app.get('/', asyncHandler(async () => {
    throw new Error('catch me!');
});

This PR

  • Removes content on express-async-handler
  • Rewords relevant sentences

Issue

N/A

Additional Information

Pull Request Requirements

  • [x] I have thoroughly read and understand The Odin Project curriculum contributing guide
  • [x] The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • [x] The Because section summarizes the reason for this PR
  • [x] The This PR section has a bullet point list describing the changes in this PR
  • [x] If this PR addresses an open issue, it is linked in the Issue section
  • [x] If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • [x] If any lesson files are included in this PR, they follow the Layout Style Guide

MaoShizhong avatar May 27 '25 15:05 MaoShizhong