@passioncloud/http
v1.0.2
Published
Create http request handler and http response objects.
Readme
http
Create http request handler and http response objects.
Quick start
You can use the library to create an http response object like so:
const { HttpResponseBuilder } = require('../index.js');
const response = HttpResponseBuilder.Ok().build();This will create below response object:
HttpResponse {
statusCode: 200,
headers: { 'content-type': 'application/json' },
body: {}
}You can also add headers and a body to your response object like so:
const response = HttpResponseBuilder.Ok()
.addHeader('authorization': 'basic ABC')
.setBody({ success: true })
.build();