Compare commits
4 Commits
developmen
...
improvemen
Author | SHA1 | Date |
---|---|---|
Will Toozs | 573e0edf5f | |
Will Toozs | d8fc234ad0 | |
Will Toozs | 1016c27085 | |
Will Toozs | 6a568af0ef |
|
@ -247,7 +247,7 @@ export const InvalidURI: ErrorFormat = {
|
||||||
description: "Couldn't parse the specified URI.",
|
description: "Couldn't parse the specified URI.",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const KeyTooLong: ErrorFormat = {
|
export const KeyTooLongError: ErrorFormat = {
|
||||||
code: 400,
|
code: 400,
|
||||||
description: 'Your key is too long.',
|
description: 'Your key is too long.',
|
||||||
};
|
};
|
||||||
|
@ -281,10 +281,10 @@ export const MaxMessageLengthExceeded: ErrorFormat = {
|
||||||
description: 'Your request was too big.',
|
description: 'Your request was too big.',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MaxPostPreDataLengthExceededError: ErrorFormat = {
|
export const MaxPostPreDataLengthExceeded: ErrorFormat = {
|
||||||
code: 400,
|
code: 400,
|
||||||
description:
|
description:
|
||||||
'Your POST request fields preceding the upload file were too large.',
|
'Your POST request fields preceeding the upload file was too large.',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MetadataTooLarge: ErrorFormat = {
|
export const MetadataTooLarge: ErrorFormat = {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import * as http from 'http';
|
||||||
export default function routeDELETE(
|
export default function routeDELETE(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
statsClient?: StatsClient,
|
statsClient?: StatsClient,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import StatsClient from '../../metrics/StatsClient';
|
||||||
export default function routerGET(
|
export default function routerGET(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
statsClient?: StatsClient,
|
statsClient?: StatsClient,
|
||||||
dataRetrievalParams?: any,
|
dataRetrievalParams?: any,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import * as http from 'http';
|
||||||
export default function routeHEAD(
|
export default function routeHEAD(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
statsClient?: StatsClient,
|
statsClient?: StatsClient,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import StatsClient from '../../metrics/StatsClient';
|
||||||
export default function routeOPTIONS(
|
export default function routeOPTIONS(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
statsClient?: StatsClient,
|
statsClient?: StatsClient,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import * as http from 'http';
|
||||||
export default function routePOST(
|
export default function routePOST(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
) {
|
) {
|
||||||
log.debug('routing request', { method: 'routePOST' });
|
log.debug('routing request', { method: 'routePOST' });
|
||||||
|
@ -58,6 +58,10 @@ export default function routePOST(
|
||||||
corsHeaders));
|
corsHeaders));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objectKey === undefined && Object.keys(query).length === 0) {
|
||||||
|
return api.callPostObject!(request, response, log, (err, resHeaders) => routesUtils.responseNoBody(err, resHeaders, response, 204, log));
|
||||||
|
}
|
||||||
|
|
||||||
return routesUtils.responseNoBody(errors.NotImplemented, null, response,
|
return routesUtils.responseNoBody(errors.NotImplemented, null, response,
|
||||||
200, log);
|
200, log);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import StatsClient from '../../metrics/StatsClient';
|
||||||
export default function routePUT(
|
export default function routePUT(
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
response: http.ServerResponse,
|
response: http.ServerResponse,
|
||||||
api: { callApiMethod: routesUtils.CallApiMethod },
|
api: routesUtils.ApiMethods,
|
||||||
log: RequestLogger,
|
log: RequestLogger,
|
||||||
statsClient?: StatsClient,
|
statsClient?: StatsClient,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -10,6 +10,11 @@ import * as constants from '../constants';
|
||||||
import DataWrapper from '../storage/data/DataWrapper';
|
import DataWrapper from '../storage/data/DataWrapper';
|
||||||
import StatsClient from '../metrics/StatsClient';
|
import StatsClient from '../metrics/StatsClient';
|
||||||
|
|
||||||
|
export type ApiMethods = {
|
||||||
|
callApiMethod: CallApiMethod;
|
||||||
|
callPostObject?: CallPostObject;
|
||||||
|
};
|
||||||
|
|
||||||
export type CallApiMethod = (
|
export type CallApiMethod = (
|
||||||
methodName: string,
|
methodName: string,
|
||||||
request: http.IncomingMessage,
|
request: http.IncomingMessage,
|
||||||
|
@ -18,6 +23,14 @@ export type CallApiMethod = (
|
||||||
callback: (err: ArsenalError | null, ...data: any[]) => void,
|
callback: (err: ArsenalError | null, ...data: any[]) => void,
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
|
export type CallPostObject = (
|
||||||
|
request: http.IncomingMessage,
|
||||||
|
response: http.ServerResponse,
|
||||||
|
log: RequestLogger,
|
||||||
|
callback: (err: ArsenalError | null, ...data: any[]) => void,
|
||||||
|
) => void;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setCommonResponseHeaders - Set HTTP response headers
|
* setCommonResponseHeaders - Set HTTP response headers
|
||||||
* @param headers - key and value of new headers to add
|
* @param headers - key and value of new headers to add
|
||||||
|
|
Loading…
Reference in New Issue