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.
24 lines
573 B
24 lines
573 B
|
4 years ago
|
|
||
|
|
function isString(val){
|
||
|
4 years ago
|
return (typeof val) === 'string';
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
export function checkStringParam(param, min, max){
|
||
|
4 years ago
|
return isString(param) && (param.length >= min) && (param.length <= max);
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
export function errorOut(reply, msg, code){
|
||
|
|
reply.code(code || 400);
|
||
|
4 years ago
|
reply.send(msg || 'Bad request.');
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
4 years ago
|
export function ipAddress(request){
|
||
|
4 years ago
|
return request.ip;
|
||
|
|
}
|
||
|
|
|
||
|
4 years ago
|
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';
|
||
|
|
}
|