-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathuser.js
29 lines (27 loc) · 1.01 KB
/
user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict";
var JSONAPISerializer = require("jsonapi-serializer").Serializer;
function UserSerializer(user) {
this.serialize = function () {
return new JSONAPISerializer("user", {
keyForAttribute: "underscore_case",
attributes: ["firstName", "lastName", "login", "email", "role", "iftttCode", "iftttTrigger_identity", "pushSubscription", "location", "subscription", "unsubscription", "unsubscription_token", "passwordLastUpdated", "reminderMail", "changePasswordMail", "subscription_date", "update_date", "permissions", "gravatar", "token"],
topLevelLinks : {
parent : sprintf("%s/v%s/users", baseUrl_https, version),
meta: {
count: user.totalcount,
pageSelf: user.pageSelf,
pageFirst: user.pageFirst,
pageNext: user.pageNext,
pagePrev: user.pagePrev,
pageLast: user.pageLast,
},
},
dataLinks : {
self : function(user) {
return sprintf("%s/v%s/users/%s", baseUrl_https, version, user.id);
},
},
}).serialize(user);
};
}
module.exports = UserSerializer;