var db = require('./dbInterface'); | |
exports = function(server, options, done) { | |
server.method('getResource', function(resourceId, next) { | |
db.find({ | |
id: resourceId | |
}, function(err, data) { | |
if(err) { | |
return next(err); | |
} | |
next(null, data); | |
}); | |
}, { | |
// uses the default cache client on the server, unless name is specified. | |
cache: { | |
// expires in 60 seconds | |
expiresIn: 60000, | |
// try to refresh after 30 seconds | |
staleIn: 30000, | |
// if refresh takes longer than 10 seconds, return cached value to client, refresh cached value in the background | |
staleTimeout: 10000 | |
} | |
}); | |
done(); | |
}; | |
exports.attributes = { | |
name: 'add two numbers server method' | |
}; |