Wrong type for ServerMiddleware
See original GitHub issueDescribe the bug
ServerMiddleware
is defined as an alias of RequestHandler
from express
. However, if you try to use for example the function req.send
, which is available according to the types, it will fail.
To Reproduce
- Create this function as a serverMiddleware:
(req, res) => {
res.send('OK')
}
- Make a request to the server and observe that you get the error “res.send is not a function”.
Expected behavior
The types should not include functions which don’t exist in runtime. I’m not sure what the correct type is though, maybe RequestListener
from http
.
Additional context Versions: nuxt: 2.10.2 @nuxt/typescript-build: 0.3.3 @nuxt/typescript-runtime: 0.2.3
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Error ServerMiddleware should expose a handle nuxt
Here is my code for app.js placed inside api folder · My nuxt.config.js file · How do I expose the websocket server from...
Read more >The serverMiddleware Property - Nuxt
The serverMiddleware property. Define server-side middleware. Type: Array. Items: String or Object or Function. Nuxt internally creates a connect instance ...
Read more >Why You Should Learn Server Middleware with Nuxt.js! A step ...
IMPORTANT:Cllick here For the Best Nuxt Course Ever : http://bit.ly/2LalQkaNuxt.js help you do server-side rendering, but what is the ...
Read more >My take on using Nuxt with an API - Alexander Lichter's blog
There are three common ways to integrate an API with Nuxt. In this blog post, I'll share my personal opinion regarding all of...
Read more >Error handling in NuxtJS - Damir's Corner
Error handling works differently in SSR (server-side rendering) and SPA ... Vue { @Prop({ type: Object, required: true }) readonly error!:
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
The whole function is
NextHandleFunction
Yeah right, I think it should be
NextHandleFunction
fromconnect
instead ofRequestHandler
fromexpress
for sure !