iconify / api

Iconify API script. Search engine for icons, provides icon data on demand for icon components, dynamically generates SVG.
MIT License
96 stars 34 forks source link

[Suggestion] The `/update` API should ideally respond after the icon has been updated. #26

Open BTBMan opened 2 months ago

BTBMan commented 2 months ago

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.

image
cyberalien commented 2 months ago

You can add a custom end point for that.

Current behavior is intentional because:

cyberalien commented 2 months ago

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.

BTBMan commented 2 months ago

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.

cyberalien commented 2 months ago

This should be doable, but requires some refactoring.

I'll get back to you on this and bug report a bit later this week.

BTBMan commented 2 months ago

Wow, thanks a lot!!! 😆

cyberalien commented 2 months ago

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)