api
api copied to clipboard
[Suggestion] The `/update` API should ideally respond after the icon has been updated.
Hi, I want the response after Update complete, can you make this happen? thanks.
Or we can control this behavior by a parameter of the /update API.
You can add a custom end point for that.
Current behavior is intentional because:
- Update is not instant. This is because on live servers update is triggered by GitHub actions when icon sets are updated, which is triggered by push to GitHub repo. Often there are multiple commits, which would trigger action in short time span, so 1 minute delay is used to make sure all commits are pushed before update. Also I've ran into situation when pulling repo too quickly after update returns old data instead of latest commit (probably this github bug has been fixed now), delay fixes that.
- Protection for update end point is basic, its just one parameter. If response is instant and identical regardless of parameters, visitor does not know if parameter is correct. Since update could be resource intensive, you don't want someone to guess your keyword and spam update end point.
To change behavior or to add a custom end point, see src/http/responses/update.ts
Function triggerIconSetsUpdate() triggers actual update and it accepts a callback as parameter, which is called when done with boolean parameter that contains status. So you can use that to send custom response based on status.
Make sure there are no concurrent triggerIconSetsUpdate() runs. It might cause high memory usage when multiple identical operation are executed.
Ok, thanks!
If I just want to update my custom icons which are in the icons folder. Is there a way to do this? without updating the new version of iconify-sets in GitHub.
This should be doable, but requires some refactoring.
I'll get back to you on this and bug report a bit later this week.
Wow, thanks a lot!!! 😆
Added code for that.
Each importer has unique index, same as order of importers in src/config/icon-sets.ts. If you have not modified it, importer for icons directory will have index of 1.
To trigger update only for that importer, replace triggerIconSetsUpdate() in src/http/responses/update.ts with triggerIconSetsUpdate(1)