Skip to content

Instantly share code, notes, and snippets.

@justin-endler
justin-endler / routes.js
Created October 17, 2014 14:14
How to bail on an Express route based on some criteria
// Premise:
// Your app interacts with some data resource.
// There is a route registered per resource type.
// After requesting a resource of a certain type, it's possible for the data to be of another type.
// E.g. You're requesting a category from an API but you are served a member of that category
// instead because there is only one member in the category.
// this route catches all incoming category requests
app.get(
'/category/:category_id',
@justin-endler
justin-endler / write.snippet
Last active August 29, 2015 14:02
Write File snippet
<snippet>
<content><![CDATA[
(function(n,c){require('fs').writeFile('/somePath/'+n+'.html',c);})('${1:c}',${1}); // @test
]]></content>
<tabTrigger>write</tabTrigger>
<description>fs.writeFile()</description>
<scope>source.js</scope>
</snippet>