// 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{}; 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{}; 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; }