You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
573 B

function isString(val){
return (typeof val) === 'string';
}
export function checkStringParam(param, min, max){
return isString(param) && (param.length >= min) && (param.length <= max);
}
export function errorOut(reply, msg, code){
reply.code(code || 400);
reply.send(msg || 'Bad request.');
}
export function ipAddress(request){
return request.ip;
}
export function localeFromHeader(input){
//not sure what to do with this yet.
//https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
return checkStringParam(input, 1, 64) ? input : 'en';
}