puppetboard/app: Reducing code redundancy for environment retreival and checking
Moving the envs variable out of the functions scope to the global scope,
this enables each function to reference and use these values.
Adding a new function check_env() to standardize the way to ensure that
the request environment exists, if it doesn't then abort with a 404.
This reduces 16 blocks of code and is in line with @daenney's suggestions