Skip to content

Commit

Permalink
Add in missing piece maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed May 2, 2024
1 parent fa06534 commit 170c0eb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mirage/serializers/addon-service-serializer.ts
@@ -1,9 +1,16 @@
import { dasherize } from '@ember/string';
import { underscore } from '@ember/string';
import { JSONAPISerializer, ModelInstance, Request } from 'ember-cli-mirage';

import { addonServiceAPIUrl } from 'ember-osf-web/adapters/addon-service';

export default class AddonServiceSerializer extends JSONAPISerializer {
keyForAttribute(attr: string) {
return underscore(attr);
}

keyForRelationship(relationship: string) {
return underscore(relationship);
}
buildNormalLinks(model: ModelInstance) {
return {
self: `${addonServiceAPIUrl}${model.modelName}/${model.id}/`,
Expand All @@ -18,7 +25,7 @@ export default class AddonServiceSerializer extends JSONAPISerializer {
json.data.relationships = Object
.entries(this.buildRelationships(model))
.reduce((acc, [key, value]) => {
acc[dasherize(key)] = value;
acc[underscore(key)] = value;
return acc;
}, {} as Record<string, unknown>); // better type?

Expand Down

0 comments on commit 170c0eb

Please sign in to comment.