question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong type for ServerMiddleware

See original GitHub issue

Describe 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

  1. Create this function as a serverMiddleware:
    (req, res) => {
      res.send('OK')
    }
  1. 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Dec 2, 2019

The whole function is NextHandleFunction

0reactions
kevinmarreccommented, Dec 2, 2019

Yeah right, I think it should be NextHandleFunction from connect instead of RequestHandler from express for sure !

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found