@mcma/api
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -1,12 +0,26 @@ | ||
import { ContextVariableProvider, Resource, ResourceType, McmaTracker } from "@mcma/core"; | ||
import { ContextVariableProvider, McmaTracker, Resource, ResourceType } from "@mcma/core"; | ||
import { DbTableProvider } from "@mcma/data"; | ||
export enum HttpStatusCode { | ||
CONTINUE = 100, | ||
SWITCHING_PROTOCOLS = 101, | ||
PROCESSING = 102, | ||
CHECKPOINT = 103, | ||
OK = 200, | ||
CREATED = 201, | ||
ACCEPTED = 202, | ||
NOT_AUTHORITATIVE = 203, | ||
NON_AUTHORITATIVE_INFORMATION = 203, | ||
NO_CONTENT = 204, | ||
RESET = 205, | ||
PARTIAL = 206, | ||
RESET_CONTENT = 205, | ||
PARTIAL_CONTENT = 206, | ||
MULTI_STATUS = 207, | ||
ALREADY_REPORTED = 208, | ||
IM_USED = 226, | ||
MULTIPLE_CHOICES = 300, | ||
MOVED_PERMANENTLY = 301, | ||
FOUND = 302, | ||
SEE_OTHER = 303, | ||
NOT_MODIFIED = 304, | ||
TEMPORARY_REDIRECT = 307, | ||
PERMANENT_REDIRECT = 308, | ||
BAD_REQUEST = 400, | ||
@@ -19,18 +33,35 @@ UNAUTHORIZED = 401, | ||
NOT_ACCEPTABLE = 406, | ||
PROXY_AUTH = 407, | ||
CLIENT_TIMEOUT = 408, | ||
PROXY_AUTHENTICATION_REQUIRED = 407, | ||
REQUEST_TIMEOUT = 408, | ||
CONFLICT = 409, | ||
GONE = 410, | ||
LENGTH_REQUIRED = 411, | ||
PRECON_FAILED = 412, | ||
ENTITY_TOO_LARGE = 413, | ||
REQ_TOO_LONG = 414, | ||
UNSUPPORTED_TYPE = 415, | ||
PRECONDITION_FAILED = 412, | ||
PAYLOAD_TOO_LARGE = 413, | ||
URI_TOO_LONG = 414, | ||
UNSUPPORTED_MEDIA_TYPE = 415, | ||
REQUESTED_RANGE_NOT_SATISFIABLE = 416, | ||
EXPECTATION_FAILED = 417, | ||
I_AM_A_TEAPOT = 418, | ||
UNPROCESSABLE_ENTITY = 422, | ||
INTERNAL_ERROR = 500, | ||
LOCKED = 423, | ||
FAILED_DEPENDENCY = 424, | ||
TOO_EARLY = 425, | ||
UPGRADE_REQUIRED = 426, | ||
PRECONDITION_REQUIRED = 428, | ||
TOO_MANY_REQUESTS = 429, | ||
REQUEST_HEADER_FIELDS_TOO_LARGE = 431, | ||
UNAVAILABLE_FOR_LEGAL_REASONS = 451, | ||
INTERNAL_SERVER_ERROR = 500, | ||
NOT_IMPLEMENTED = 501, | ||
BAD_GATEWAY = 502, | ||
UNAVAILABLE = 503, | ||
SERVICE_UNAVAILABLE = 503, | ||
GATEWAY_TIMEOUT = 504, | ||
VERSION = 50 | ||
HTTP_VERSION_NOT_SUPPORTED = 505, | ||
VARIANT_ALSO_NEGOTIATES = 506, | ||
INSUFFICIENT_STORAGE = 507, | ||
LOOP_DETECTED = 508, | ||
BANDWIDTH_LIMIT_EXCEEDED = 509, | ||
NOT_EXTENDED = 510, | ||
NETWORK_AUTHENTICATION_REQUIRED = 511, | ||
} | ||
@@ -121,5 +152,5 @@ | ||
onStarted(handleOnStarted: ((requestContext: McmaApiRequestContext) => Promise<boolean>)): DefaultRouteBuilder<T>; | ||
onStarted(handleOnStarted: (requestContext: McmaApiRequestContext) => Promise<boolean>): DefaultRouteBuilder<T>; | ||
onCompleted(handleOnCompleted: ((requestContext: McmaApiRequestContext, resource: Resource) => Promise<T>)): DefaultRouteBuilder<T>; | ||
onCompleted(handleOnCompleted: (requestContext: McmaApiRequestContext, resource: Resource) => Promise<T>): DefaultRouteBuilder<T>; | ||
@@ -147,2 +178,3 @@ build(): McmaApiRoute; | ||
constructor(dbTableProvider: DbTableProvider<T>, resourceType: ResourceType<T>, root?: string); | ||
addAll(): DefaultRouteCollectionBuilder<T>; | ||
@@ -149,0 +181,0 @@ route(selectRoute: (defaultRoutes: DefaultRoutes<T>) => DefaultRouteBuilder<T>): DefaultRouteConfigurator<T>; |
@@ -1,9 +0,23 @@ | ||
const HttpStatusCode = { | ||
const HttpStatusCode = Object.freeze({ | ||
CONTINUE: 100, | ||
SWITCHING_PROTOCOLS: 101, | ||
PROCESSING: 102, | ||
CHECKPOINT: 103, | ||
OK: 200, | ||
CREATED: 201, | ||
ACCEPTED: 202, | ||
NOT_AUTHORITATIVE: 203, | ||
NON_AUTHORITATIVE_INFORMATION: 203, | ||
NO_CONTENT: 204, | ||
RESET: 205, | ||
PARTIAL: 206, | ||
RESET_CONTENT: 205, | ||
PARTIAL_CONTENT: 206, | ||
MULTI_STATUS: 207, | ||
ALREADY_REPORTED: 208, | ||
IM_USED: 226, | ||
MULTIPLE_CHOICES: 300, | ||
MOVED_PERMANENTLY: 301, | ||
FOUND: 302, | ||
SEE_OTHER: 303, | ||
NOT_MODIFIED: 304, | ||
TEMPORARY_REDIRECT: 307, | ||
PERMANENT_REDIRECT: 308, | ||
BAD_REQUEST: 400, | ||
@@ -16,22 +30,47 @@ UNAUTHORIZED: 401, | ||
NOT_ACCEPTABLE: 406, | ||
PROXY_AUTH: 407, | ||
CLIENT_TIMEOUT: 408, | ||
PROXY_AUTHENTICATION_REQUIRED: 407, | ||
REQUEST_TIMEOUT: 408, | ||
CONFLICT: 409, | ||
GONE: 410, | ||
LENGTH_REQUIRED: 411, | ||
PRECON_FAILED: 412, | ||
ENTITY_TOO_LARGE: 413, | ||
REQ_TOO_LONG: 414, | ||
UNSUPPORTED_TYPE: 415, | ||
PRECONDITION_FAILED: 412, | ||
PAYLOAD_TOO_LARGE: 413, | ||
URI_TOO_LONG: 414, | ||
UNSUPPORTED_MEDIA_TYPE: 415, | ||
REQUESTED_RANGE_NOT_SATISFIABLE: 416, | ||
EXPECTATION_FAILED: 417, | ||
I_AM_A_TEAPOT: 418, | ||
UNPROCESSABLE_ENTITY: 422, | ||
INTERNAL_ERROR: 500, | ||
LOCKED: 423, | ||
FAILED_DEPENDENCY: 424, | ||
TOO_EARLY: 425, | ||
UPGRADE_REQUIRED: 426, | ||
PRECONDITION_REQUIRED: 428, | ||
TOO_MANY_REQUESTS: 429, | ||
REQUEST_HEADER_FIELDS_TOO_LARGE: 431, | ||
UNAVAILABLE_FOR_LEGAL_REASONS: 451, | ||
INTERNAL_SERVER_ERROR: 500, | ||
NOT_IMPLEMENTED: 501, | ||
BAD_GATEWAY: 502, | ||
UNAVAILABLE: 503, | ||
SERVICE_UNAVAILABLE: 503, | ||
GATEWAY_TIMEOUT: 504, | ||
VERSION: 505, | ||
}; | ||
HTTP_VERSION_NOT_SUPPORTED: 505, | ||
VARIANT_ALSO_NEGOTIATES: 506, | ||
INSUFFICIENT_STORAGE: 507, | ||
LOOP_DETECTED: 508, | ||
BANDWIDTH_LIMIT_EXCEEDED: 509, | ||
NOT_EXTENDED: 510, | ||
NETWORK_AUTHENTICATION_REQUIRED: 511, | ||
}); | ||
const getStatusError = (statusCode) => { | ||
switch (statusCode) { | ||
case HttpStatusCode.CONTINUE: | ||
return "Continue"; | ||
case HttpStatusCode.SWITCHING_PROTOCOLS: | ||
return "Switching Protocols"; | ||
case HttpStatusCode.PROCESSING: | ||
return "Processing"; | ||
case HttpStatusCode.CHECKPOINT: | ||
return "Checkpoint"; | ||
case HttpStatusCode.OK: | ||
@@ -43,10 +82,30 @@ return "OK"; | ||
return "Accepted"; | ||
case HttpStatusCode.NOT_AUTHORITATIVE: | ||
case HttpStatusCode.NON_AUTHORITATIVE_INFORMATION: | ||
return "Non-Authoritative Information"; | ||
case HttpStatusCode.NO_CONTENT: | ||
return "No Content"; | ||
case HttpStatusCode.RESET: | ||
case HttpStatusCode.RESET_CONTENT: | ||
return "Reset Content"; | ||
case HttpStatusCode.PARTIAL: | ||
case HttpStatusCode.PARTIAL_CONTENT: | ||
return "Partial Content"; | ||
case HttpStatusCode.MULTI_STATUS: | ||
return "Multi-Status"; | ||
case HttpStatusCode.ALREADY_REPORTED: | ||
return "Already Reported"; | ||
case HttpStatusCode.IM_USED: | ||
return "IM Used"; | ||
case HttpStatusCode.MULTIPLE_CHOICES: | ||
return "Multiple Choices"; | ||
case HttpStatusCode.MOVED_PERMANENTLY: | ||
return "Moved Permanently"; | ||
case HttpStatusCode.FOUND: | ||
return "Found"; | ||
case HttpStatusCode.SEE_OTHER: | ||
return "See Other"; | ||
case HttpStatusCode.NOT_MODIFIED: | ||
return "Not Modified"; | ||
case HttpStatusCode.TEMPORARY_REDIRECT: | ||
return "Temporary Redirect"; | ||
case HttpStatusCode.PERMANENT_REDIRECT: | ||
return "Permanent Redirect"; | ||
case HttpStatusCode.BAD_REQUEST: | ||
@@ -66,5 +125,5 @@ return "Bad Request"; | ||
return "Not Acceptable"; | ||
case HttpStatusCode.PROXY_AUTH: | ||
case HttpStatusCode.PROXY_AUTHENTICATION_REQUIRED: | ||
return "Proxy Authentication Required "; | ||
case HttpStatusCode.CLIENT_TIMEOUT: | ||
case HttpStatusCode.REQUEST_TIMEOUT: | ||
return "Request Timeout"; | ||
@@ -77,13 +136,35 @@ case HttpStatusCode.CONFLICT: | ||
return "Length Required"; | ||
case HttpStatusCode.PRECON_FAILED: | ||
case HttpStatusCode.PRECONDITION_FAILED: | ||
return "Precondition Failed"; | ||
case HttpStatusCode.ENTITY_TOO_LARGE: | ||
case HttpStatusCode.PAYLOAD_TOO_LARGE: | ||
return "Payload Too Large"; | ||
case HttpStatusCode.REQ_TOO_LONG: | ||
case HttpStatusCode.URI_TOO_LONG: | ||
return "URI Too Long"; | ||
case HttpStatusCode.UNSUPPORTED_TYPE: | ||
case HttpStatusCode.UNSUPPORTED_MEDIA_TYPE: | ||
return "Unsupported Media Type"; | ||
case HttpStatusCode.REQUESTED_RANGE_NOT_SATISFIABLE: | ||
return "Requested Range Not Satisfiable"; | ||
case HttpStatusCode.EXPECTATION_FAILED: | ||
return "Expectation Failed"; | ||
case HttpStatusCode.I_AM_A_TEAPOT: | ||
return "I'm a teapot"; | ||
case HttpStatusCode.UNPROCESSABLE_ENTITY: | ||
return "Unprocessable Entity"; | ||
case HttpStatusCode.INTERNAL_ERROR: | ||
case HttpStatusCode.LOCKED: | ||
return "Locked"; | ||
case HttpStatusCode.FAILED_DEPENDENCY: | ||
return "Failed Dependency"; | ||
case HttpStatusCode.TOO_EARLY: | ||
return "Too Early"; | ||
case HttpStatusCode.UPGRADE_REQUIRED: | ||
return "Upgrade Required"; | ||
case HttpStatusCode.PRECONDITION_REQUIRED: | ||
return "Precondition Required"; | ||
case HttpStatusCode.TOO_MANY_REQUESTS: | ||
return "Too Many Requests"; | ||
case HttpStatusCode.REQUEST_HEADER_FIELDS_TOO_LARGE: | ||
return "Request Header Fields Too Large"; | ||
case HttpStatusCode.UNAVAILABLE_FOR_LEGAL_REASONS: | ||
return "Unavailable For Legal Reasons"; | ||
case HttpStatusCode.INTERNAL_SERVER_ERROR: | ||
return "Internal Server Error"; | ||
@@ -94,8 +175,21 @@ case HttpStatusCode.NOT_IMPLEMENTED: | ||
return "Bad Gateway"; | ||
case HttpStatusCode.UNAVAILABLE: | ||
case HttpStatusCode.SERVICE_UNAVAILABLE: | ||
return "Service Unavailable"; | ||
case HttpStatusCode.GATEWAY_TIMEOUT: | ||
return "Gateway Timeout"; | ||
case HttpStatusCode.VERSION: | ||
case HttpStatusCode.HTTP_VERSION_NOT_SUPPORTED: | ||
return "HTTP Version Not Supported"; | ||
case HttpStatusCode.VARIANT_ALSO_NEGOTIATES: | ||
return "Variant Also Negotiates"; | ||
case HttpStatusCode.INSUFFICIENT_STORAGE: | ||
return "Insufficient Storage"; | ||
case HttpStatusCode.LOOP_DETECTED: | ||
return "Loop Detected"; | ||
case HttpStatusCode.BANDWIDTH_LIMIT_EXCEEDED: | ||
return "Bandwidth Limit Exceeded"; | ||
case HttpStatusCode.NOT_EXTENDED: | ||
return "Not Extended"; | ||
case HttpStatusCode.NETWORK_AUTHENTICATION_REQUIRED: | ||
return "Network Authentication Required"; | ||
} | ||
@@ -102,0 +196,0 @@ |
@@ -94,8 +94,10 @@ //"use strict"; | ||
for (const prop in request.headers) { | ||
if (prop.toLowerCase() === "access-control-request-method") { | ||
corsMethod = request.headers[prop]; | ||
if (request.headers.hasOwnProperty(prop)) { | ||
if (prop.toLowerCase() === "access-control-request-method") { | ||
corsMethod = request.headers[prop]; | ||
} | ||
if (prop.toLowerCase() === "access-control-request-headers") { | ||
corsHeaders = request.headers[prop]; | ||
} | ||
} | ||
if (prop.toLowerCase() === "access-control-request-headers") { | ||
corsHeaders = request.headers[prop]; | ||
} | ||
} | ||
@@ -128,3 +130,3 @@ | ||
response.statusCode = HttpStatusCode.INTERNAL_ERROR; | ||
response.statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR; | ||
response.headers = getDefaultResponseHeaders(); | ||
@@ -131,0 +133,0 @@ response.body = new McmaApiError(response.statusCode, error.message, request.path); |
{ | ||
"name": "@mcma/api", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Node module for building APIs based on the EBU MCMA framework", | ||
@@ -34,12 +34,12 @@ "engines": { | ||
"peerDependencies": { | ||
"@mcma/client": "0.7.0", | ||
"@mcma/core": "0.7.0", | ||
"@mcma/data": "0.7.0" | ||
"@mcma/client": "0.7.1", | ||
"@mcma/core": "0.7.1", | ||
"@mcma/data": "0.7.1" | ||
}, | ||
"devDependencies": { | ||
"@mcma/client": "0.7.0", | ||
"@mcma/core": "0.7.0", | ||
"@mcma/data": "0.7.0", | ||
"@mcma/client": "0.7.1", | ||
"@mcma/core": "0.7.1", | ||
"@mcma/data": "0.7.1", | ||
"jasmine": "^3.2.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37131
926