Fix type information to allow express middlewares
See original GitHub issueIf you use an express-middleware (such as session or passport), one gets the following typescript error:
Type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not comparable to type 'EventHandler<any>'.
Example-code:
import session from 'express-session'
import passport from 'passport'
import { createApp } from 'h3'
const app = createApp()
app.use(session())
app.use(passport.initialize())
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Express cors middleware
allowedHeaders : Configures the Access-Control-Allow-Headers CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: ...
Read more >How to extend the Express Request object in TypeScript
Let's learn how to extend the Request type in TypeScript to make its instances store custom data you can use at the controller...
Read more >javascript - Passing variables to the next middleware using ...
This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
Read more >How To Use And Write Express Middleware
Middleware in Express is one of the easiest ways to create DRY and well written code which is why it is crucial to...
Read more >Middleware in Express.js
Middleware functions execute some code that can have side effects on the app, and usually add information to the request or response objects....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Middleware made for express, depend on specific auegmentations coming from express app itself (.json(), .cookie(), etc)
In order to use express middleware with h3, you need to first create an express app:
@NozomuIkuta please have look at this ts Playground. The
app.use
calls are showing ts errors.