|
|
|
@ -3,29 +3,29 @@ import { EndpointError, EndpointHandler, handleErrorsInEndpoint } from '../endpo |
|
|
|
|
import Knex from 'knex'; |
|
|
|
|
import asJson from '../lib/asJson'; |
|
|
|
|
|
|
|
|
|
export function toApiTag(dbObj: any): api.Tag { |
|
|
|
|
return <api.Tag>{ |
|
|
|
|
export function toApiTag(dbObj: any): api.TagWithDetailsWithId { |
|
|
|
|
return <api.TagWithDetailsWithId>{ |
|
|
|
|
mbApi_typename: "tag", |
|
|
|
|
tagId: dbObj['tags.id'], |
|
|
|
|
id: dbObj['tags.id'], |
|
|
|
|
name: dbObj['tags.name'], |
|
|
|
|
parentId: dbObj['tags.parentId'], |
|
|
|
|
parent: dbObj.parent ? toApiTag(dbObj.parent) : undefined, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function toApiArtist(dbObj: any): api.Artist { |
|
|
|
|
return <api.Artist>{ |
|
|
|
|
export function toApiArtist(dbObj: any): api.ArtistWithId { |
|
|
|
|
return <api.ArtistWithId>{ |
|
|
|
|
mbApi_typename: "artist", |
|
|
|
|
artistId: dbObj['artists.id'], |
|
|
|
|
id: dbObj['artists.id'], |
|
|
|
|
name: dbObj['artists.name'], |
|
|
|
|
storeLinks: asJson(dbObj['artists.storeLinks']), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function toApiTrack(dbObj: any, artists: any[], tags: any[], albums: any[]): api.Track { |
|
|
|
|
return <api.Track>{ |
|
|
|
|
export function toApiTrack(dbObj: any, artists: any[], tags: any[], albums: any[]): api.TrackWithDetailsWithId { |
|
|
|
|
return <api.TrackWithDetailsWithId>{ |
|
|
|
|
mbApi_typename: "track", |
|
|
|
|
trackId: dbObj['tracks.id'], |
|
|
|
|
id: dbObj['tracks.id'], |
|
|
|
|
name: dbObj['tracks.name'], |
|
|
|
|
storeLinks: asJson(dbObj['tracks.storeLinks']), |
|
|
|
|
artists: artists.map((artist: any) => { |
|
|
|
@ -38,10 +38,10 @@ export function toApiTrack(dbObj: any, artists: any[], tags: any[], albums: any[ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function toApiAlbum(dbObj: any): api.Album { |
|
|
|
|
return <api.Album>{ |
|
|
|
|
export function toApiAlbum(dbObj: any): api.AlbumWithId { |
|
|
|
|
return <api.AlbumWithId>{ |
|
|
|
|
mbApi_typename: "album", |
|
|
|
|
albumId: dbObj['albums.id'], |
|
|
|
|
id: dbObj['albums.id'], |
|
|
|
|
name: dbObj['albums.name'], |
|
|
|
|
storeLinks: asJson(dbObj['albums.storeLinks']), |
|
|
|
|
}; |
|
|
|
|