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.
22 lines
828 B
22 lines
828 B
const models = require('../models'); |
|
import * as api from '../../client/src/api'; |
|
import { EndpointError, EndpointHandler, catchUnhandledErrors } from './types'; |
|
|
|
export const CreateArtistEndpointHandler: EndpointHandler = async (req: any, res: any) => { |
|
if (!api.checkCreateArtistRequest(req)) { |
|
const e: EndpointError = { |
|
internalMessage: 'Invalid CreateArtist request: ' + JSON.stringify(req.body), |
|
httpStatus: 400 |
|
}; |
|
throw e; |
|
} |
|
const reqObject: api.CreateArtistRequest = req.body; |
|
await models.Artist.create(reqObject) |
|
.then((artist: any) => { |
|
const responseObject: api.CreateArtistResponse = { |
|
id: artist.id |
|
}; |
|
res.status(200).send(responseObject); |
|
}) |
|
.catch(catchUnhandledErrors); |
|
} |