Allows for loading resources from a filesystem structure matching the URI
Load express routes (and params) automatically from a directory, where the path to each file corresponds to it's URL.
npm install express-resourceful
var express = require'express';var resourceful = require'express-resourceful';var app = require'express';resourcefulapp 'resources'; // runs synchronously
|path to resource||url|
Each exported method that corresponds to an HTTP method will be added to the router/app.
exportsurl = '/foo'; // *OPTIONAL* can be used to override the default url// GET handler...;// POST handler...;
A single exported function can be used as a param handler. (where the param name is determined by the filename)
// param handler;
Will scan the given
dir (sychronously) for resource files and mount them to
app. (which can either be a plain express app or an
prefix will be prepended onto the generated paths.
Any files found in the
_params directory will be treated as param handlers.
NOTE: Resource files beginning with a
: (ie: route params) will be mounted
after static routes, to prevent a route like
/users/new from being preempted