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.
62 lines
1.8 KiB
62 lines
1.8 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. |
|
|
|
// Retrieve a list of songs. Basic artist information is included. |
|
export const ListSongsEndpoint = '/song/list'; |
|
export interface ListSongsRequest {} |
|
export interface ListSongsResponseItem { |
|
title: String; |
|
id: Number; |
|
artistName: String; |
|
artistId: Number; |
|
} |
|
export interface ListSongsResponse extends Array<ListSongsResponseItem>{}; |
|
export function checkListSongsRequest(req:any): boolean { |
|
return true; |
|
} |
|
|
|
// Retrieve a list of artists. |
|
export const ListArtistsEndpoint = '/artist/list'; |
|
export interface ListArtistsRequest {} |
|
export interface ListArtistsResponseItem { |
|
name: String; |
|
id: Number; |
|
} |
|
export interface ListArtistsResponse extends Array<ListArtistsResponseItem>{}; |
|
export function checkListArtistsRequest(req:any): boolean { |
|
return true; |
|
} |
|
|
|
// Create a new song. |
|
export const CreateSongEndpoint = '/song/create'; |
|
export interface CreateSongRequest { |
|
title: String; |
|
artistId: Number; |
|
} |
|
export interface CreateSongResponse { |
|
id: Number; |
|
} |
|
export function checkCreateSongRequest(req:any): boolean { |
|
return "body" in req && |
|
"title" in req.body && |
|
"artistId" in req.body; |
|
} |
|
|
|
// Create a new artist. |
|
export const CreateArtistEndpoint = '/artist/create'; |
|
export interface CreateArtistRequest { |
|
name: String; |
|
} |
|
export interface CreateArtistResponse { |
|
id: Number; |
|
} |
|
export function checkCreateArtistRequest(req:any): boolean { |
|
return "body" in req && |
|
"name" in req.body; |
|
} |