Permalink
Browse files

hapi 0.6.0

  • Loading branch information...
hueniverse committed Aug 20, 2012
1 parent 42cb6d2 commit 4b8e5904ccbb0ca6607b103bdbd9be5ba079e62c
Showing with 363 additions and 349 deletions.
  1. +3 −3 api/batch.js
  2. +9 −9 api/details.js
  3. +7 −7 api/email.js
  4. +12 −9 api/index.js
  5. +12 −12 api/invite.js
  6. +17 −17 api/last.js
  7. +3 −3 api/package.json
  8. +58 −58 api/project.js
  9. +56 −54 api/session.js
  10. +22 −22 api/storage.js
  11. +12 −12 api/stream.js
  12. +8 −8 api/suggestions.js
  13. +29 −29 api/task.js
  14. +106 −106 api/user.js
  15. +9 −0 package.json
View
@@ -26,7 +26,7 @@ exports.type = {
// Batch processing
-exports.post = function (request, reply) {
+exports.post = function (request) {
var requests = [];
var results = [];
@@ -95,7 +95,7 @@ exports.post = function (request, reply) {
}
else {
- reply(Hapi.Error.badRequest(error));
+ request.reply(Hapi.Error.badRequest(error));
}
}
@@ -105,7 +105,7 @@ exports.post = function (request, reply) {
// Return results
- reply(results);
+ request.reply(results);
});
}
View
@@ -26,7 +26,7 @@ exports.type = {
// Task details
-exports.get = function (request, reply) {
+exports.get = function (request) {
exports.load(request.params.id, request.userId, false, function (details, err, task, project) {
@@ -72,20 +72,20 @@ exports.get = function (request, reply) {
details.thread[i].user = usersMap[details.thread[i].user] || { id: details.thread[i].user };
}
- reply(details);
+ request.reply(details);
});
}
else {
- reply(err);
+ request.reply(err);
}
});
};
// Add task detail
-exports.post = function (request, reply) {
+exports.post = function (request) {
var now = Hapi.Utils.getTimestamp();
@@ -111,7 +111,7 @@ exports.post = function (request, reply) {
}
else {
- reply(err);
+ request.reply(err);
}
});
}
@@ -130,19 +130,19 @@ exports.post = function (request, reply) {
}
else {
- reply(err);
+ request.reply(err);
}
});
}
}
else {
- reply(err);
+ request.reply(err);
}
}
else {
- reply(err);
+ request.reply(err);
}
});
@@ -155,7 +155,7 @@ exports.post = function (request, reply) {
}
Stream.update({ object: 'details', project: task.project, task: task._id }, request);
- reply({ status: 'ok' });
+ request.reply({ status: 'ok' });
}
};
View
@@ -274,7 +274,7 @@ exports.sendReminder = function (user, callback) {
'Use this link to sign into ' + Config.product.name + ': \n\n' +
' ' + Config.host.uri('web') + '/t/' + ticket;
- Hapi.Utils.email(user.emails[0].address, subject, text);
+ Hapi.Email.send(user.emails[0].address, subject, text);
callback(null);
}
else {
@@ -306,7 +306,7 @@ exports.sendValidation = function (user, address, callback) {
'Use this link to verify your email address: \n\n' +
' ' + Config.host.uri('web') + '/t/' + ticket;
- Hapi.Utils.email(address, subject, text);
+ Hapi.Email.send(address, subject, text);
callback(null);
}
else {
@@ -349,7 +349,7 @@ exports.sendWelcome = function (user, callback) {
text += 'Use this link to verify your email address: \n\n';
text += ' ' + Config.host.uri('web') + '/t/' + ticket + '\n\n';
- Hapi.Utils.email(address, subject, text);
+ Hapi.Email.send(address, subject, text);
callback(null);
}
else {
@@ -367,7 +367,7 @@ exports.sendWelcome = function (user, callback) {
text += 'Use this link to sign-into ' + Config.product.name + ': \n\n';
text += ' ' + Config.host.uri('web') + '/\n\n';
- Hapi.Utils.email(address, subject, text);
+ Hapi.Email.send(address, subject, text);
callback(null);
}
else {
@@ -382,7 +382,7 @@ exports.sendWelcome = function (user, callback) {
text += 'Since you have not yet linked a Facebook, Twitter, or Yahoo! account, you will need to use this link to sign back into ' + Config.product.name + ': \n\n';
text += ' ' + Config.host.uri('web') + '/t/' + ticket + '\n\n';
- Hapi.Utils.email(address, subject, text);
+ Hapi.Email.send(address, subject, text);
callback(null);
}
else {
@@ -428,7 +428,7 @@ exports.projectInvite = function (users, pids, project, message, inviter) {
link = 'Use this link to join: \n\n' +
' ' + Config.host.uri('web') + '/view/#project=' + project._id;
- Hapi.Utils.email(users[i].emails[0].address,
+ Hapi.Email.send(users[i].emails[0].address,
subject,
'Hi ' + (users[i].name || users[i].username || users[i].emails[0].address) + ',\n\n' + text + link);
}
@@ -447,7 +447,7 @@ exports.projectInvite = function (users, pids, project, message, inviter) {
link = 'Use this link to join: \n\n' +
' ' + Config.host.uri('web') + '/i/' + invite;
- Hapi.Utils.email(pid.email, subject, 'Hi ' + (pid.display || pid.email) + ',\n\n' + text + link, null, function (err) {
+ Hapi.Email.send(pid.email, subject, 'Hi ' + (pid.display || pid.email) + ',\n\n' + text + link, null, function (err) {
if (err === null) {
View
@@ -23,27 +23,30 @@ var internals = {};
// Post handler extension middleware
-internals.onPostHandler = function (req, res, next) {
+internals.onPostHandler = function (request, next) {
- if (res.hapi.result) {
+ if (request.response &&
+ request.response.result) {
+
+ var result = request.response.result;
// Sanitize database fields
- if (res.hapi.result._id) {
+ if (result._id) {
- res.hapi.result.id = res.hapi.result._id;
- delete res.hapi.result._id;
+ result.id = result._id;
+ delete result._id;
}
- if (res.hapi.result instanceof Object) {
+ if (result instanceof Object) {
- for (var i in res.hapi.result) {
+ for (var i in result) {
- if (res.hapi.result.hasOwnProperty(i)) {
+ if (result.hasOwnProperty(i)) {
if (i[0] === '_') {
- delete res.hapi.result[i];
+ delete result[i];
}
}
}
View
@@ -14,7 +14,7 @@ var Stream = require('./stream');
// Check invitation code
-exports.get = function (request, reply) {
+exports.get = function (request) {
// Check invitation code type
@@ -71,17 +71,17 @@ exports.get = function (request, reply) {
about.inviter = inviter.display;
}
- reply(about);
+ request.reply(about);
});
}
else {
- reply(Hapi.Error.badRequest('Invalid invitation code'));
+ request.reply(Hapi.Error.badRequest('Invalid invitation code'));
}
}
else {
- reply(err);
+ request.reply(err);
}
});
}
@@ -93,11 +93,11 @@ exports.get = function (request, reply) {
if (err === null) {
- reply(invite);
+ request.reply(invite);
}
else {
- reply(err);
+ request.reply(err);
}
});
}
@@ -106,7 +106,7 @@ exports.get = function (request, reply) {
// Claim a project invitation
-exports.claim = function (request, reply) {
+exports.claim = function (request) {
var inviteRegex = /^project:([^:]+):([^:]+):([^:]+)$/;
var parts = inviteRegex.exec(request.params.id);
@@ -154,28 +154,28 @@ exports.claim = function (request, reply) {
if (err === null) {
Stream.update({ object: 'project', project: projectId }, request);
- reply({ status: 'ok', project: projectId });
+ request.reply({ status: 'ok', project: projectId });
}
else {
- reply(err);
+ request.reply(err);
}
});
}
else {
- reply(Hapi.Error.badRequest('Invalid invitation code'));
+ request.reply(Hapi.Error.badRequest('Invalid invitation code'));
}
}
else {
- reply(err);
+ request.reply(err);
}
});
}
else {
- reply(Hapi.Error.badRequest('Invalid invitation format'));
+ request.reply(Hapi.Error.badRequest('Invalid invitation format'));
}
};
Oops, something went wrong.

0 comments on commit 4b8e590

Please sign in to comment.