You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.7 KiB
104 lines
2.7 KiB
// TODO: this file is located in the client src folder because |
|
// otherwise, Create React App will refuse to compile it. |
|
// Putting it in the server folder or in its own folder makes more sense. |
|
|
|
// This file represents the API interface for Mudbase's back-end. |
|
// Each endpoint is described by its endpoint address, |
|
// a request structure, a response structure and |
|
// a checking function which determines request validity. |
|
|
|
// Query for songs. |
|
export const QuerySongsEndpoint = '/song/query'; |
|
export interface QuerySongsRequest {} |
|
export interface QuerySongsResponse { |
|
ids: Number[] |
|
} |
|
export function checkQuerySongsRequest(req:any): boolean { |
|
return true; |
|
} |
|
|
|
// Get song details. |
|
export const SongDetailsEndpoint = '/song/details'; |
|
export interface SongDetailsRequest { |
|
id: Number |
|
} |
|
export interface SongDetailsResponse { |
|
title: String, |
|
artistIds: Number[], |
|
albumIds: Number[], |
|
} |
|
export function checkSongDetailsRequest(req:any): boolean { |
|
return "id" in req; |
|
} |
|
|
|
// Query for artists. |
|
export const QueryArtistsEndpoint = '/artist/query'; |
|
export interface QueryArtistsRequest {} |
|
export interface QueryArtistsResponse { |
|
ids: Number[] |
|
} |
|
export function checkQueryArtistsRequest(req:any): boolean { |
|
return true; |
|
} |
|
|
|
// Get artist details. |
|
export const ArtistDetailsEndpoint = '/artist/details'; |
|
export interface ArtistDetailsRequest { |
|
id: Number |
|
} |
|
export interface ArtistDetailsResponse { |
|
name: String |
|
} |
|
export function checkArtistDetailsRequest(req:any): boolean { |
|
return "id" in req; |
|
} |
|
|
|
// Create a new song. |
|
export const CreateSongEndpoint = '/song/create'; |
|
export interface CreateSongRequest { |
|
title: String; |
|
artistIds?: Number[]; |
|
albumIds?: Number[]; |
|
} |
|
export interface CreateSongResponse { |
|
id: Number; |
|
} |
|
export function checkCreateSongRequest(req:any): boolean { |
|
return "body" in req && |
|
"title" in req.body; |
|
} |
|
|
|
// Modify an existing song. |
|
export const ModifySongEndpoint = '/song/modify'; |
|
export interface ModifySongRequest extends CreateSongRequest { |
|
id: Number; |
|
} |
|
export interface ModifySongResponse {} |
|
export function checkModifySongRequest(req:any): boolean { |
|
return true; |
|
} |
|
|
|
// Create a new artist. |
|
export const CreateArtistEndpoint = '/artist/create'; |
|
export interface CreateArtistRequest { |
|
name: String; |
|
songIds?: Number[]; |
|
albumIds?: Number[]; |
|
} |
|
export interface CreateArtistResponse { |
|
id: Number; |
|
} |
|
export function checkCreateArtistRequest(req:any): boolean { |
|
return "body" in req && |
|
"name" in req.body; |
|
} |
|
|
|
// Modify an existing artist. |
|
export const ModifyArtistEndpoint = '/artist/modify'; |
|
export interface ModifyArtistRequest extends CreateArtistRequest { |
|
id: Number; |
|
} |
|
export interface ModifyArtistResponse {} |
|
export function checkModifyArtistRequest(req:any): boolean { |
|
return true; |
|
} |