README
@vidglo/lambda-http
Utilities to generate AWS lambda responses
Usage
// These imports are equivalent:
const {
response, statusCode, body, header, headers
} = require('@vidglo/lambda-http');
const response = require('@vidglo/lambda-http/response';)
const statusCode = require('@vidglo/lambda-http/statusCode';)
const body = require('@vidglo/lambda-http/body';)
const header = require('@vidglo/lambda-http/header';)
const headers = require('@vidglo/lambda-http/headers';)
// And:
const { ok } = require('@vidglo/lambda-http/responses');
const ok = require('@vidglo/lambda-http/responses/ok');
// The following are equivalent:
{ statusCode: 200 };
response(statusCode(200));
statusCode(200);
response(ok());
ok();
// As are the following:
{
statusCode: 200,
headers: {
'x-my-header': 'some-header-value'
}
};
response(
statusCode(200), {
headers: { 'x-my-header': 'some-header-value' }
}
);
response(
statusCode(200),
headers({ 'x-my-header': 'some-header-value' })
);
response(
ok(),
headers(header('x-my-header', 'some-header-value'))
);
ok(
headers(header('x-my-header')('some-header-value'))
);
// As are the following:
{
statusCode: 200,
headers: {
'x-my-header': 'some-header-value'
},
body: JSON.stringify({
foo: 'bar'
})
};
response(
statusCode(200), {
headers: { 'x-my-header': 'some-header-value' }
}, {
body: JSON.stringify({ foo: 'bar' })
}
);
response(
statusCode(200),
headers({ 'x-my-header': 'some-header-value' }),
body({ foo: 'bar' })
);
response(
ok(),
headers(header('x-my-header', 'some-header-value')),
body({ foo: 'bar' })
);
ok(
headers(header('x-my-header')('some-header-value')),
body({ foo: 'bar' })
);
API
body([bodyObject])
const body = require('@vidglo/lambda-http/body');
const { body } = require('@vidglo/lambda-http');
Arguments
[bodyObject] (*): Any argument that can be passed to JSON.stringify()
. This is generally a POJO.
Returns
(Object): Returns an object with the single key body
, referencing a value of JSON.stringify(bodyObject)
.
Example
body({ hello: 'world' });
// => { body: '{"hello":"world"}' }
response([objects])
const response = require('@vidglo/lambda-http/response');
const { response } = require('@vidglo/lambda-http');
Arguments
[objects] (...Object): A variadic arguments list of objects to merge.
Returns
(Object): Returns an object with all arguments merged. Essentially an immutable Object.assign()
.
Example
response(statusCode(200));
// => { statusCode: 200 };
statusCode(code)
const statusCode = require('@vidglo/lambda-http/statusCode');
const { statusCode } = require('@vidglo/lambda-http');
Arguments
status code (number): The HTTP status code of the response.
Returns
(Object): Returns an object with a single key of statusCode
referencing the passed value.
Example
statusCode(200);
// => { statusCode: 200 };
headers([headers])
const headers = require('@vidglo/lambda-http/headers');
const { headers } = require('@vidglo/lambda-http');
Arguments
[headers] (...Object): A variadic arguments list of objects to collect.
Returns
(Object): Returns an object with a single key of headers
refencing a single object with all arguments merged together.
Example
headers({ 'x-my-header': some-header-value }, { another: 'header' });
// => {
// headers: {
// 'x-my-header': some-header-value,
// another: 'header'
// }
// };
header(header, value)
const header = require('@vidglo/lambda-http/header');
const { header } = require('@vidglo/lambda-http');
Note
If called with one argument, this function will return another function that accepts the missing second parameter.
Arguments
key (string): A key to bind the value to. value (*): A value to bind against the key.
Returns
(Object): Returns an object with a single key of [key]
referencing the passed value.
Example
header('x-my-header', 'some-header-value');
// => { 'x-my-header': 'some-header-value' };
header('x-my-header')('some-header-value');
// => { 'x-my-header': 'some-header-value' };
Responses
const responses = require('@vidglo/lambda-http/responses');
A module of helper methods that each return a response with the associated HTTP status code. Each method can be called with a variadic arguments list of objects that will be merged into a single output object.
ok([objects])
const { ok } = require('@vidglo/lambda-http/responses');
const ok = require('@vidglo/lambda-http/responses/ok');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 200
, with all arguments merged into the returned object.
Example
ok();
// => { statusCode: 200 };
ok(body({ hello: 'world' }));
// => { statusCode: 200, body: '{"hello":"world"}' };
created([objects])
const { created } = require('@vidglo/lambda-http/responses');
const created = require('@vidglo/lambda-http/responses/created');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 201
, with all arguments merged into the returned object.
Example
created();
// => { statusCode: 201 };
created(body({ hello: 'world' }));
// => { statusCode: 201, body: '{"hello":"world"}' };
accepted([objects])
const { accepted } = require('@vidglo/lambda-http/responses');
const accepted = require('@vidglo/lambda-http/responses/accepted');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 202
, with all arguments merged into the returned object.
Example
accepted();
// => { statusCode: 202 };
accepted(body({ hello: 'world' }));
// => { statusCode: 202, body: '{"hello":"world"}' };
nonAuthoritativeInformation([objects])
const { nonAuthoritativeInformation } = require('@vidglo/lambda-http/responses');
const nonAuthoritativeInformation = require('@vidglo/lambda-http/responses/nonAuthoritativeInformation');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 203
, with all arguments merged into the returned object.
Example
nonAuthoritativeInformation();
// => { statusCode: 203 };
nonAuthoritativeInformation(body({ hello: 'world' }));
// => { statusCode: 203, body: '{"hello":"world"}' };
noContent([objects])
const { noContent } = require('@vidglo/lambda-http/responses');
const noContent = require('@vidglo/lambda-http/responses/noContent');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 204
, with all arguments merged into the returned object.
Example
noContent();
// => { statusCode: 204 };
noContent(body({ hello: 'world' }));
// => { statusCode: 204, body: '{"hello":"world"}' };
resetContent([objects])
const { resetContent } = require('@vidglo/lambda-http/responses');
const resetContent = require('@vidglo/lambda-http/responses/resetContent');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 205
, with all arguments merged into the returned object.
Example
resetContent();
// => { statusCode: 205 };
resetContent(body({ hello: 'world' }));
// => { statusCode: 205, body: '{"hello":"world"}' };
partialContent([objects])
const { partialContent } = require('@vidglo/lambda-http/responses');
const partialContent = require('@vidglo/lambda-http/responses/partialContent');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 206
, with all arguments merged into the returned object.
Example
partialContent();
// => { statusCode: 206 };
partialContent(body({ hello: 'world' }));
// => { statusCode: 206, body: '{"hello":"world"}' };
multipleChoice([objects])
const { multipleChoice } = require('@vidglo/lambda-http/responses');
const multipleChoice = require('@vidglo/lambda-http/responses/multipleChoice');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 300
, with all arguments merged into the returned object.
Example
multipleChoice();
// => { statusCode: 300 };
multipleChoice(body({ hello: 'world' }));
// => { statusCode: 300, body: '{"hello":"world"}' };
movedPermanently([objects])
const { movedPermanently } = require('@vidglo/lambda-http/responses');
const movedPermanently = require('@vidglo/lambda-http/responses/movedPermanently');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 301
, with all arguments merged into the returned object.
Example
movedPermanently();
// => { statusCode: 301 };
movedPermanently(body({ hello: 'world' }));
// => { statusCode: 301, body: '{"hello":"world"}' };
found([objects])
const { found } = require('@vidglo/lambda-http/responses');
const found = require('@vidglo/lambda-http/responses/found');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 302
, with all arguments merged into the returned object.
Example
found();
// => { statusCode: 302 };
found(body({ hello: 'world' }));
// => { statusCode: 302, body: '{"hello":"world"}' };
seeOther([objects])
const { seeOther } = require('@vidglo/lambda-http/responses');
const seeOther = require('@vidglo/lambda-http/responses/seeOther');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 303
, with all arguments merged into the returned object.
Example
seeOther();
// => { statusCode: 303 };
seeOther(body({ hello: 'world' }));
// => { statusCode: 303, body: '{"hello":"world"}' };
notModified([objects])
const { notModified } = require('@vidglo/lambda-http/responses');
const notModified = require('@vidglo/lambda-http/responses/notModified');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 304
, with all arguments merged into the returned object.
Example
notModified();
// => { statusCode: 304 };
notModified(body({ hello: 'world' }));
// => { statusCode: 304, body: '{"hello":"world"}' };
useProxy([objects])
const { useProxy } = require('@vidglo/lambda-http/responses');
const useProxy = require('@vidglo/lambda-http/responses/useProxy');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 305
, with all arguments merged into the returned object.
Example
useProxy();
// => { statusCode: 305 };
useProxy(body({ hello: 'world' }));
// => { statusCode: 305, body: '{"hello":"world"}' };
temporaryRedirect([objects])
const { temporaryRedirect } = require('@vidglo/lambda-http/responses');
const temporaryRedirect = require('@vidglo/lambda-http/responses/temporaryRedirect');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 307
, with all arguments merged into the returned object.
Example
temporaryRedirect();
// => { statusCode: 307 };
temporaryRedirect(body({ hello: 'world' }));
// => { statusCode: 307, body: '{"hello":"world"}' };
permanentRedirect([objects])
const { permanentRedirect } = require('@vidglo/lambda-http/responses');
const permanentRedirect = require('@vidglo/lambda-http/responses/permanentRedirect');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 308
, with all arguments merged into the returned object.
Example
permanentRedirect();
// => { statusCode: 308 };
permanentRedirect(body({ hello: 'world' }));
// => { statusCode: 308, body: '{"hello":"world"}' };
badRequest([objects])
const { badRequest } = require('@vidglo/lambda-http/responses');
const badRequest = require('@vidglo/lambda-http/responses/badRequest');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 400
, with all arguments merged into the returned object.
Example
badRequest();
// => { statusCode: 400 };
badRequest(body({ hello: 'world' }));
// => { statusCode: 400, body: '{"hello":"world"}' };
unauthorized([objects])
const { unauthorized } = require('@vidglo/lambda-http/responses');
const unauthorized = require('@vidglo/lambda-http/responses/unauthorized');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 401
, with all arguments merged into the returned object.
Example
unauthorized();
// => { statusCode: 401 };
unauthorized(body({ hello: 'world' }));
// => { statusCode: 401, body: '{"hello":"world"}' };
paymentRequired([objects])
const { paymentRequired } = require('@vidglo/lambda-http/responses');
const paymentRequired = require('@vidglo/lambda-http/responses/paymentRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 402
, with all arguments merged into the returned object.
Example
paymentRequired();
// => { statusCode: 402 };
paymentRequired(body({ hello: 'world' }));
// => { statusCode: 402, body: '{"hello":"world"}' };
forbidden([objects])
const { forbidden } = require('@vidglo/lambda-http/responses');
const forbidden = require('@vidglo/lambda-http/responses/forbidden');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 403
, with all arguments merged into the returned object.
Example
forbidden();
// => { statusCode: 403 };
forbidden(body({ hello: 'world' }));
// => { statusCode: 403, body: '{"hello":"world"}' };
notFound([objects])
const { notFound } = require('@vidglo/lambda-http/responses');
const notFound = require('@vidglo/lambda-http/responses/notFound');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 404
, with all arguments merged into the returned object.
Example
notFound();
// => { statusCode: 404 };
notFound(body({ hello: 'world' }));
// => { statusCode: 404, body: '{"hello":"world"}' };
methodNotAllowed([objects])
const { methodNotAllowed } = require('@vidglo/lambda-http/responses');
const methodNotAllowed = require('@vidglo/lambda-http/responses/methodNotAllowed');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 405
, with all arguments merged into the returned object.
Example
methodNotAllowed();
// => { statusCode: 405 };
methodNotAllowed(body({ hello: 'world' }));
// => { statusCode: 405, body: '{"hello":"world"}' };
notAcceptable([objects])
const { notAcceptable } = require('@vidglo/lambda-http/responses');
const notAcceptable = require('@vidglo/lambda-http/responses/notAcceptable');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 406
, with all arguments merged into the returned object.
Example
notAcceptable();
// => { statusCode: 406 };
notAcceptable(body({ hello: 'world' }));
// => { statusCode: 406, body: '{"hello":"world"}' };
proxyAuthenticationRequired([objects])
const { proxyAuthenticationRequired } = require('@vidglo/lambda-http/responses');
const proxyAuthenticationRequired = require('@vidglo/lambda-http/responses/proxyAuthenticationRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 407
, with all arguments merged into the returned object.
Example
proxyAuthenticationRequired();
// => { statusCode: 407 };
proxyAuthenticationRequired(body({ hello: 'world' }));
// => { statusCode: 407, body: '{"hello":"world"}' };
requestTimeout([objects])
const { requestTimeout } = require('@vidglo/lambda-http/responses');
const requestTimeout = require('@vidglo/lambda-http/responses/requestTimeout');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 408
, with all arguments merged into the returned object.
Example
requestTimeout();
// => { statusCode: 408 };
requestTimeout(body({ hello: 'world' }));
// => { statusCode: 408, body: '{"hello":"world"}' };
conflict([objects])
const { conflict } = require('@vidglo/lambda-http/responses');
const conflict = require('@vidglo/lambda-http/responses/conflict');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 409
, with all arguments merged into the returned object.
Example
conflict();
// => { statusCode: 409 };
conflict(body({ hello: 'world' }));
// => { statusCode: 409, body: '{"hello":"world"}' };
gone([objects])
const { gone } = require('@vidglo/lambda-http/responses');
const gone = require('@vidglo/lambda-http/responses/gone');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 410
, with all arguments merged into the returned object.
Example
gone();
// => { statusCode: 410 };
gone(body({ hello: 'world' }));
// => { statusCode: 410, body: '{"hello":"world"}' };
lengthRequired([objects])
const { lengthRequired } = require('@vidglo/lambda-http/responses');
const lengthRequired = require('@vidglo/lambda-http/responses/lengthRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 411
, with all arguments merged into the returned object.
Example
lengthRequired();
// => { statusCode: 411 };
lengthRequired(body({ hello: 'world' }));
// => { statusCode: 411, body: '{"hello":"world"}' };
preconditionFailed([objects])
const { preconditionFailed } = require('@vidglo/lambda-http/responses');
const preconditionFailed = require('@vidglo/lambda-http/responses/preconditionFailed');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 412
, with all arguments merged into the returned object.
Example
preconditionFailed();
// => { statusCode: 412 };
preconditionFailed(body({ hello: 'world' }));
// => { statusCode: 412, body: '{"hello":"world"}' };
payloadTooLarge([objects])
const { payloadTooLarge } = require('@vidglo/lambda-http/responses');
const payloadTooLarge = require('@vidglo/lambda-http/responses/payloadTooLarge');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 413
, with all arguments merged into the returned object.
Example
payloadTooLarge();
// => { statusCode: 413 };
payloadTooLarge(body({ hello: 'world' }));
// => { statusCode: 413, body: '{"hello":"world"}' };
uriTooLong([objects])
const { uriTooLong } = require('@vidglo/lambda-http/responses');
const uriTooLong = require('@vidglo/lambda-http/responses/uriTooLong');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 414
, with all arguments merged into the returned object.
Example
uriTooLong();
// => { statusCode: 414 };
uriTooLong(body({ hello: 'world' }));
// => { statusCode: 414, body: '{"hello":"world"}' };
unsupportedMediaType([objects])
const { unsupportedMediaType } = require('@vidglo/lambda-http/responses');
const unsupportedMediaType = require('@vidglo/lambda-http/responses/unsupportedMediaType');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 415
, with all arguments merged into the returned object.
Example
unsupportedMediaType();
// => { statusCode: 415 };
unsupportedMediaType(body({ hello: 'world' }));
// => { statusCode: 415, body: '{"hello":"world"}' };
requestedRangeNotSatisfiable([objects])
const { requestedRangeNotSatisfiable } = require('@vidglo/lambda-http/responses');
const requestedRangeNotSatisfiable = require('@vidglo/lambda-http/responses/requestedRangeNotSatisfiable');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 416
, with all arguments merged into the returned object.
Example
requestedRangeNotSatisfiable();
// => { statusCode: 416 };
requestedRangeNotSatisfiable(body({ hello: 'world' }));
// => { statusCode: 416, body: '{"hello":"world"}' };
expectationFailed([objects])
const { expectationFailed } = require('@vidglo/lambda-http/responses');
const expectationFailed = require('@vidglo/lambda-http/responses/expectationFailed');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 417
, with all arguments merged into the returned object.
Example
expectationFailed();
// => { statusCode: 417 };
expectationFailed(body({ hello: 'world' }));
// => { statusCode: 417, body: '{"hello":"world"}' };
imATeapot([objects])
const { imATeapot } = require('@vidglo/lambda-http/responses');
const imATeapot = require('@vidglo/lambda-http/responses/imATeapot');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 418
, with all arguments merged into the returned object.
Example
imATeapot();
// => { statusCode: 418 };
imATeapot(body({ hello: 'world' }));
// => { statusCode: 418, body: '{"hello":"world"}' };
misdirectedRequest([objects])
const { misdirectedRequest } = require('@vidglo/lambda-http/responses');
const misdirectedRequest = require('@vidglo/lambda-http/responses/misdirectedRequest');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 421
, with all arguments merged into the returned object.
Example
misdirectedRequest();
// => { statusCode: 421 };
misdirectedRequest(body({ hello: 'world' }));
// => { statusCode: 421, body: '{"hello":"world"}' };
unprocessableEntity([objects])
const { unprocessableEntity } = require('@vidglo/lambda-http/responses');
const unprocessableEntity = require('@vidglo/lambda-http/responses/unprocessableEntity');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 422
, with all arguments merged into the returned object.
Example
unprocessableEntity();
// => { statusCode: 422 };
unprocessableEntity(body({ hello: 'world' }));
// => { statusCode: 422, body: '{"hello":"world"}' };
locked([objects])
const { locked } = require('@vidglo/lambda-http/responses');
const locked = require('@vidglo/lambda-http/responses/locked');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 423
, with all arguments merged into the returned object.
Example
locked();
// => { statusCode: 423 };
locked(body({ hello: 'world' }));
// => { statusCode: 423, body: '{"hello":"world"}' };
failedDependency([objects])
const { failedDependency } = require('@vidglo/lambda-http/responses');
const failedDependency = require('@vidglo/lambda-http/responses/failedDependency');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 424
, with all arguments merged into the returned object.
Example
failedDependency();
// => { statusCode: 424 };
failedDependency(body({ hello: 'world' }));
// => { statusCode: 424, body: '{"hello":"world"}' };
tooEarly([objects])
const { tooEarly } = require('@vidglo/lambda-http/responses');
const tooEarly = require('@vidglo/lambda-http/responses/tooEarly');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 425
, with all arguments merged into the returned object.
Example
tooEarly();
// => { statusCode: 425 };
tooEarly(body({ hello: 'world' }));
// => { statusCode: 425, body: '{"hello":"world"}' };
upgradeRequired([objects])
const { upgradeRequired } = require('@vidglo/lambda-http/responses');
const upgradeRequired = require('@vidglo/lambda-http/responses/upgradeRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 426
, with all arguments merged into the returned object.
Example
upgradeRequired();
// => { statusCode: 426 };
upgradeRequired(body({ hello: 'world' }));
// => { statusCode: 426, body: '{"hello":"world"}' };
preconditionRequired([objects])
const { preconditionRequired } = require('@vidglo/lambda-http/responses');
const preconditionRequired = require('@vidglo/lambda-http/responses/preconditionRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 428
, with all arguments merged into the returned object.
Example
preconditionRequired();
// => { statusCode: 428 };
preconditionRequired(body({ hello: 'world' }));
// => { statusCode: 428, body: '{"hello":"world"}' };
tooManyRequests([objects])
const { tooManyRequests } = require('@vidglo/lambda-http/responses');
const tooManyRequests = require('@vidglo/lambda-http/responses/tooManyRequests');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 429
, with all arguments merged into the returned object.
Example
tooManyRequests();
// => { statusCode: 429 };
tooManyRequests(body({ hello: 'world' }));
// => { statusCode: 429, body: '{"hello":"world"}' };
requestHeaderFieldsTooLarge([objects])
const { requestHeaderFieldsTooLarge } = require('@vidglo/lambda-http/responses');
const requestHeaderFieldsTooLarge = require('@vidglo/lambda-http/responses/requestHeaderFieldsTooLarge');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 431
, with all arguments merged into the returned object.
Example
requestHeaderFieldsTooLarge();
// => { statusCode: 431 };
requestHeaderFieldsTooLarge(body({ hello: 'world' }));
// => { statusCode: 431, body: '{"hello":"world"}' };
unavailableForLegalReasons([objects])
const { unavailableForLegalReasons } = require('@vidglo/lambda-http/responses');
const unavailableForLegalReasons = require('@vidglo/lambda-http/responses/unavailableForLegalReasons');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 451
, with all arguments merged into the returned object.
Example
unavailableForLegalReasons();
// => { statusCode: 451 };
unavailableForLegalReasons(body({ hello: 'world' }));
// => { statusCode: 451, body: '{"hello":"world"}' };
internalServerError([objects])
const { internalServerError } = require('@vidglo/lambda-http/responses');
const internalServerError = require('@vidglo/lambda-http/responses/internalServerError');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 500
, with all arguments merged into the returned object.
Example
internalServerError();
// => { statusCode: 500 };
internalServerError(body({ hello: 'world' }));
// => { statusCode: 500, body: '{"hello":"world"}' };
notImplemented([objects])
const { notImplemented } = require('@vidglo/lambda-http/responses');
const notImplemented = require('@vidglo/lambda-http/responses/notImplemented');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 501
, with all arguments merged into the returned object.
Example
notImplemented();
// => { statusCode: 501 };
notImplemented(body({ hello: 'world' }));
// => { statusCode: 501, body: '{"hello":"world"}' };
badGateway([objects])
const { badGateway } = require('@vidglo/lambda-http/responses');
const badGateway = require('@vidglo/lambda-http/responses/badGateway');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 502
, with all arguments merged into the returned object.
Example
badGateway();
// => { statusCode: 502 };
badGateway(body({ hello: 'world' }));
// => { statusCode: 502, body: '{"hello":"world"}' };
serviceUnavailable([objects])
const { serviceUnavailable } = require('@vidglo/lambda-http/responses');
const serviceUnavailable = require('@vidglo/lambda-http/responses/serviceUnavailable');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 503
, with all arguments merged into the returned object.
Example
serviceUnavailable();
// => { statusCode: 503 };
serviceUnavailable(body({ hello: 'world' }));
// => { statusCode: 503, body: '{"hello":"world"}' };
gatewayTimeout([objects])
const { gatewayTimeout } = require('@vidglo/lambda-http/responses');
const gatewayTimeout = require('@vidglo/lambda-http/responses/gatewayTimeout');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 504
, with all arguments merged into the returned object.
Example
gatewayTimeout();
// => { statusCode: 504 };
gatewayTimeout(body({ hello: 'world' }));
// => { statusCode: 504, body: '{"hello":"world"}' };
httpVersionNotSupported([objects])
const { httpVersionNotSupported } = require('@vidglo/lambda-http/responses');
const httpVersionNotSupported = require('@vidglo/lambda-http/responses/httpVersionNotSupported');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 505
, with all arguments merged into the returned object.
Example
httpVersionNotSupported();
// => { statusCode: 505 };
httpVersionNotSupported(body({ hello: 'world' }));
// => { statusCode: 505, body: '{"hello":"world"}' };
variantAlsoNegotiates([objects])
const { variantAlsoNegotiates } = require('@vidglo/lambda-http/responses');
const variantAlsoNegotiates = require('@vidglo/lambda-http/responses/variantAlsoNegotiates');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 506
, with all arguments merged into the returned object.
Example
variantAlsoNegotiates();
// => { statusCode: 506 };
variantAlsoNegotiates(body({ hello: 'world' }));
// => { statusCode: 506, body: '{"hello":"world"}' };
insufficientStorage([objects])
const { insufficientStorage } = require('@vidglo/lambda-http/responses');
const insufficientStorage = require('@vidglo/lambda-http/responses/insufficientStorage');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 507
, with all arguments merged into the returned object.
Example
insufficientStorage();
// => { statusCode: 507 };
insufficientStorage(body({ hello: 'world' }));
// => { statusCode: 507, body: '{"hello":"world"}' };
loopDetected([objects])
const { loopDetected } = require('@vidglo/lambda-http/responses');
const loopDetected = require('@vidglo/lambda-http/responses/loopDetected');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 508
, with all arguments merged into the returned object.
Example
loopDetected();
// => { statusCode: 508 };
loopDetected(body({ hello: 'world' }));
// => { statusCode: 508, body: '{"hello":"world"}' };
notExtended([objects])
const { notExtended } = require('@vidglo/lambda-http/responses');
const notExtended = require('@vidglo/lambda-http/responses/notExtended');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 510
, with all arguments merged into the returned object.
Example
notExtended();
// => { statusCode: 510 };
notExtended(body({ hello: 'world' }));
// => { statusCode: 510, body: '{"hello":"world"}' };
networkAuthenticationRequired([objects])
const { networkAuthenticationRequired } = require('@vidglo/lambda-http/responses');
const networkAuthenticationRequired = require('@vidglo/lambda-http/responses/networkAuthenticationRequired');
Arguments
[objects] (*): A variadic arguments list objects to merge into the returned object.
Returns
(Object): Returns an object with a key:value pair of statusCode: 511
, with all arguments merged into the returned object.
Example
networkAuthenticationRequired();
// => { statusCode: 511 };
networkAuthenticationRequired(body({ hello: 'world' }));
// => { statusCode: 511, body: '{"hello":"world"}' };