How to write Express.js middleware with TypeScript
Hands-OnYou can extend your Express.js server easily with custom middleware. All you have to do is to write a function that accepts three parameters (req
, res
, next
).
You can extend your Express.js server easily with custom middleware. All you have to do is to write a function that accepts three parameters (req
, res
, next
).
Setting up a TypeScript project with Node.js takes only a few minutes. Here is how to do it the fastest way by just using npm
and yarn
.
Extending the EventEmitter
class from Node.js might cause error TS2307. Here is how to fix it.
TypeScript 3.8 introduces a new functionality which is called top-level await. It allows developers to use the await
keyword without a surrounding async
function at the top level of a module.
There are many libraries to build CLI tools for Node.js like optimist, minimist, yargs, Caporal.js and commander to name just a few. In the following article Benny gives you an overview of his favorites.
Continue reading →