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.
23 lines
803 B
23 lines
803 B
const models = require('../models'); |
|
import * as api from '../../client/src/api'; |
|
import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; |
|
|
|
export const QuerySongsEndpointHandler: EndpointHandler = async (req: any, res: any) => { |
|
if (!api.checkQuerySongsRequest(req)) { |
|
const e: EndpointError = { |
|
internalMessage: 'Invalid QuerySongs request: ' + JSON.stringify(req.body), |
|
httpStatus: 400 |
|
}; |
|
throw e; |
|
} |
|
await models.Song.findAll() |
|
.then((songs: any[]) => { |
|
const response: api.QuerySongsResponse = { |
|
ids: songs.map((song: any) => { |
|
return song.id; |
|
}) |
|
}; |
|
res.send(response); |
|
}) |
|
.catch(catchUnhandledErrors); |
|
} |