destjs icon indicating copy to clipboard operation
destjs copied to clipboard

Context Helpers

Open SampaioLeal opened this issue 3 years ago • 1 comments

The framework has to give developer helper functions to manage request context.

Some ideas:

  • A function to set response status
  • A decorator to set success HttpCode - by @yan-almeida

Well, writing this i realized that oak has a good structure and properties in context... The issue will be open until we get some other ideas

SampaioLeal avatar Oct 17 '21 04:10 SampaioLeal

A good practice would be to adopt a decorator to configure the HTTP response.

Something like:

// where the StatusCode receives an enum of http-status
@HttpCode(StatusCode);

Use case:

// overrinding request status
@HttpCode(StatusCode.CREATED);
created (... args) {
  return 'Creating something.'
}

We should return 201 - Created when we get a successful response while creating some resource.

yan-almeida avatar Oct 17 '21 06:10 yan-almeida