5abc4e0d9b
closes TryGhost/Ghost#9433 - remove unnecessary bower deps - update mirage usage - fix tests
31 lines
759 B
JavaScript
31 lines
759 B
JavaScript
import BaseSerializer from './application';
|
|
import {RestSerializer} from 'ember-cli-mirage';
|
|
|
|
export default BaseSerializer.extend({
|
|
embed: true,
|
|
|
|
include(request) {
|
|
if (request.queryParams.include && request.queryParams.include.indexOf('roles') >= 0) {
|
|
return ['roles'];
|
|
}
|
|
|
|
return [];
|
|
},
|
|
|
|
serialize(object, request) {
|
|
if (this.isCollection(object)) {
|
|
return BaseSerializer.prototype.serialize.apply(this, arguments);
|
|
}
|
|
|
|
let {user} = RestSerializer.prototype.serialize.call(this, object, request);
|
|
|
|
if (object.postCount) {
|
|
let posts = object.posts.models.length;
|
|
|
|
user.count = {posts};
|
|
}
|
|
|
|
return {users: [user]};
|
|
}
|
|
});
|