BackendStack21 / restana

Restana is a lightweight and fast Node.js framework for building RESTful APIs.
MIT License
467 stars 27 forks source link

Issue parsing POST body #22

Closed KiranRamashetty closed 5 years ago

KiranRamashetty commented 5 years ago

When i am trying to use bodyParser.json() I keep getting an error

2/18/2019 2:23:47 PM error: TypeError: stream.on is not a function

Code

   const server = require('restana/libs/turbo-http')
   const service = require('restana')({
         server: server,
        defaultRoute: defaultHandler
   })

  service.use(bodyParser.urlencoded({
        extended: true
    }));
    service.use(bodyParser.json());
jkyberneees commented 5 years ago

Hi @KiranRamashetty, the reason of your issue is that turbo-http is still not 100% API compatible with node.js HTTP interfaces.

Could you please setup your app like this:

const service = require('restana')({
     defaultRoute: defaultHandler
})

Default restana server is actually quite performant, no big difference compared to turbo-http.

Thanks.