spumko/catbox — pull request #59 by jholland918 (2014-03-26 07:32:24+00:00)
Title: Allow undefined values in expires assertion

Using server.route.config.cache.expiresIn = 0 in hapi causes the following error: "Error: Rule must include one of expiresIn or expiresAt but not both {"expiresIn":0}".

The call to Catbox.Policy() here https://github.com/spumko/hapi/blob/master/lib/route.js#L84 passes an undefined expiresAt attribute in hapi's route.js code. My first thought was to check for undefined before calling Catbox.Policy() in route.js but I found that Catbox.Policy is similarly called with both expiresIn and expiresAt in hapi's pack.js so maybe there's some kind of convention that I'm not sure about so I ended up changing the assert instead.

Of course if you trigger the code in pack.js by running "var cache = server.cache('countries', { expiresIn: 0 });" the error is not generated because of the truthy condition (https://github.com/spumko/hapi/blob/master/lib/pack.js#L669) that sets the settings parameter that ends up not setting any attribute which doesn't throw an error and probably behaves as expected when setting expiresIn = 0 anyway.