Create the following endpoint in your Express application using the Sequelize ORM. Test out your endpoint using Postman.
PATCH /tracks/:id
This endpoint should update a track by the id
parameter. This endpoint should have the following validations:
- the name can't be empty
- milliseconds must be numeric
- unit price must be numeric
If the update passes validation, respond with a 200 status code and the updated track in the response body.
If the update fails validation, return a JSON response in the following format, where each object contains the attribute that failed validation and a user friendly error message.
{
"errors": [
{
"attribute": "name",
"message": "..."
}
]
}
If the track isn't found, return an empty response with a 404 status code.
For your Track
model, alias the column names to their camelCased version. For example, the column UnitPrice
should be unitPrice
on your model. Also, alias your primary key TrackId
to just id
.
Submission
- Deploy your app to Heroku. Verify that your app has been deployed and it works on Heroku.
- Send an email to me and the TA with the GitHub URL and the Heroku URL. Please use the subject line ITP 405 Lab Submission - Node 2: ORM.