Created
          April 29, 2014 01:16 
        
      - 
      
- 
        Save jakecraige/11388505 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | badRequest = (err, reply)-> | |
| reply Boom.badRequest(err) | |
| exports.search = {} | |
| exports.search.validate = | |
| query: | |
| categoryId: Joi.number().integer().required() | |
| subcategoryId: Joi.number().integer().required() | |
| startTime: Joi.string().required() | |
| zipCode: Joi.string().required() | |
| exports.search.handler = (req, reply)-> | |
| errorText = "We are having trouble searching right now. Please try again later." | |
| try | |
| search = new Search | |
| categoryId: req.query.categoryId | |
| subcategoryId: req.query.subcategoryId | |
| zipCode: req.query.zipCode | |
| startTime: req.query.startTime | |
| catch err | |
| badRequest(errorText, reply) | |
| search.search (err, results)-> | |
| if err then badRequest(errorText, reply) | |
| reply(results) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment