mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
52b6668955
- remove lodash from bower - move all resources to /mirage instead of /app/mirage - update endpoints to use ORM - general cleanup
28 lines
743 B
JavaScript
28 lines
743 B
JavaScript
import BaseSerializer from './application';
|
|
import {RestSerializer} from 'ember-cli-mirage';
|
|
|
|
export default BaseSerializer.extend({
|
|
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};
|
|
}
|
|
|
|
let roles = BaseSerializer.prototype.serialize.call(this, object.roles, request);
|
|
let [role] = roles.roles;
|
|
|
|
if (role) {
|
|
user.roles = [role];
|
|
}
|
|
|
|
return {users: [user]};
|
|
}
|
|
});
|