Iterate over RAML resources and generate a middleware router.
npm install osprey-resources --save
var express = require('express');
var resources = require('osprey-resources');
var app = express();
app.use(resources(
[{
relativeUri: '/users',
methods: [{
method: 'post',
body: {
'application/json': {
schema: '...'
}
}
}]
}],
function (method, path) {
return function (req, res, next) {
res.end('hello, world!')
}
}
));
The resources function accepts two arguments. The array of resources from RAML and a function that will generate the route for that path. Return null
if the route should not be used.
MIT license