As we want to expose an easy and clean to work with API to our users, we would like to use the service name as the key when a user asks to monitor a specific service and not a random GUID. For that we need to make sure that service names are unique. For simplicity we'll make it unique across all the services in the system and not just per user.
To do that we'll use a the data hooks
feature. Data hooks lets you "tap" into the flow of inserting/deleting/updating/fetching data. Learn more about data hooks here.
- Implement a
beforeInsert
hook on yourservices
table and reject the insert in case of a duplicated service name. To implement a data hook you will need to create adata.js
file under your backend folder
- Add an error message to the lightbox submit button via it's settings.
Is it working? Great let's move on to Step 4 - Creating an API key using events
Take a look at: