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'; }