New
Codemod Registry
Explore community-led codemods to migrate, optimize, and transform your codebase.
Ready to contribute?
Build your own codemod and share it with the community.
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Handle DEP0066: migrate deprecated use of `OutgoingMessage.prototype` `_headers` & `_headerNames` to public HTTP header APIs
The easiest way to run this codemod without installing anything globally:
This is one example from the codemod's test cases. The codemod may handle many more cases.
Build your own codemod and share it with the community.
1 const http = require('http');
2
3 function handler(req, res) {
4 res.setHeader('content-type', 'application/json');
5 res.setHeader('x-custom-header', '42');
6
7 console.log({
8 headers: res._headers,
9 headerNames: res._headerNames,
10 customHeader: res._headers['x-custom-header'],
11 count: Object.keys(res._headers).length,
12 });
13
14 res.end('Hello World');
15 }
16
17 const server = http.createServer(handler);
18
19 server.listen(3000, () => {
20 console.log('Server running on port 3000');
21 });
22