Turbo Mode

What it does

Disables URL pattern matching and match with request method only.

How to use
uApp.bootstrap(App, {
  port: 3000,
  turboMode: true
})
Description

When turboMode is set to true, URL pattern matching will be disabled and incoming request will only be matched by their request method.

So this:

@uMethod.get('/users/:userId')
getUser(req: uRequest, res: uResponse): void {
  // You will not be able to use `req.params.userId` in turbo mode
  res.send(req.params.userId) // undefined
}

will be equivalent to:

@uMethod.get()
getUser(req: uRequest, res: uResponse): void {
  res.send('Bob')
}

// You can still use middleware functions
@uMethod.get()
@uMiddleware(ejwt({secret: 'serverSecret'}))
getUser(req: uRequest, res: uResponse): void {
  res.send('Authenticated: ' + req.token)
}

NOTE: URL pattern matching is expensive, by turning on turboMode you will get a performance boost as each incoming request will only be mapped based on their request method, e.g: GET, POST etc. Note that when using turboMode, you can only have a maximum of 1 handler per method. This means you cannot have more than a single instance of uMethod.get in your ENTIRE APP! This is optimal for micro-service APIs where each service typically only handles 1 resource.

results matching ""

    No results matching ""