Ghost/ghost/admin/mirage/serializers/user.js
Austin Burdine 52b6668955 deps: ember-cli-mirage@0.2.0
- remove lodash from bower
- move all resources to /mirage instead of /app/mirage
- update endpoints to use ORM
- general cleanup
2017-01-13 15:59:37 +00:00

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]};
}
});