mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
c4c48d4104
refs https://github.com/TryGhost/Admin/pull/2209 - `miragejs` has been extracted to a framework-independent library, the re-exports of `miragejs` elements in `ember-cli-mirage` have been deprecated making our test logs very noisy - added `miragejs` as a top-level dependency - updated all relevant imports to pull from `miragejs` instead of `ember-cli-mirage`
31 lines
756 B
JavaScript
31 lines
756 B
JavaScript
import BaseSerializer from './application';
|
|
import {RestSerializer} from 'miragejs';
|
|
|
|
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.call(this, object, request);
|
|
}
|
|
|
|
let {user} = RestSerializer.prototype.serialize.call(this, object, request);
|
|
|
|
if (object.postCount) {
|
|
let posts = object.posts.models.length;
|
|
|
|
user.count = {posts};
|
|
}
|
|
|
|
return {users: [user]};
|
|
}
|
|
});
|