node-olinapps
npm install olinapps
In the top of your file:
var olinapps = ;
In your express app, right after your app.configure
:
/** * Authentication */ app;appall'/logout' olinappslogout;appall'/*' olinappsmiddleware;appall'/api/*' olinappsloginRequiredJSON; // (optional) login required, no redirect, returns 401appall'/*' olinappsloginRequired;
Remove the loginRequired
line if logging in is optional. Then in any route:
app
Yields:
id: 'timothy.ryan' created: 1354933883 domain: 'students.olin.edu' username: 'timothy.ryan' email: 'timothy.ryan@students.olin.edu'
Directory & Mailing Lists
You can request information from the Olin Directory or Mailing List APIs.
app.get('/me', function (req, res) {
olinapps.directory.me(req, function (err, json) {
res.json(json);
});
});
app.get('/people', function (req, res) {
olinapps.directory.people(req, function (err, json) {
res.json(json);
});
});
app.get('/list', function (req, res) {
olinapps.lists.search(req, 'helpme', 'ride to eliot', function (err, messages) {
res.json(messages);
});
});
API
Session:
olinapps.user(req);
olinapps.sessionid(req);
Middleware:
olinapps.login
olinapps.logout
olinapps.middleware
olinapps.loginRequired
olinapps.loginRequiredJSON
APIs:
olinapps.directory.me(req, callback)
olinapps.directory.people(req, callback)
olinapps.lists.search(req, list_name, keywords, callback)
Example
See the source for quotes.olinapps.com for an example.