sqs-producer
Version:
Enqueues messages onto a given SQS queue
31 lines (30 loc) • 956 B
JavaScript
/**
* Checks if the value is a string
* @param value - The value to check
*/
export function isString(value) {
return typeof value === "string" || value instanceof String;
}
/**
* Checks if the value is an object
* @param value - The value to check
*/
export function isObject(value) {
return value && typeof value === "object" && value instanceof Object;
}
export function isDelaySecondsValid(delaySeconds) {
return typeof delaySeconds === "number" && delaySeconds >= 0 && delaySeconds <= 900;
}
/**
* Checks if a MessageAttribute is valid
* @param messageAttribute - The MessageAttribute to check
*/
export function isMessageAttributeValid(messageAttribute) {
if (!messageAttribute.DataType) {
throw new Error("A MessageAttribute must have a DataType key");
}
if (!isString(messageAttribute.DataType)) {
throw new Error("The DataType key of a MessageAttribute must be a String");
}
return true;
}