$chiubaca / notes / fleeting / 2022-10-21
  • tinkering around with how medusa plugins work. They effectively let you isolate logic which has a specific purpose whilst still giving you the full hooks and features of the medusa server, the core building blocks we can work with are:

    • the api these custom URL endpoints which can run any arbitrary code when hit
    • the service, the most important aspect which is a class in that you can implement custom business logic in methods. Medusa exposes these methods to all aspects of your plugin including the api and loaders
    • finally, loader from what I understand is a functionality that you can call on a certain lifecycle. such as the startup of the plugin. You can even time to run via a cron job. - https://docs.medusajs.com/advanced/backend/cron-jobs/create/#2-create-cron-job
  • plugins are faff to work with right now, so I’m working around it by developing against a medusa server. the process of extracting this logic out of medusa server and and into a plugin looks straight forward though as extending a medusa server and plugin have the same directory structure. Keeping an eye on the following github issues:

    • https://github.com/medusajs/medusa/issues/2486
    • https://github.com/medusajs/medusa/issues/1859
    • https://github.com/medusajs/medusa/pull/1860
Edit on GitHub āœļø

Hey I'm Alex Chiu šŸ‘‹. These are my notes for literally anything.

I'm using the Zettelkasten method to organise my thoughts here.

My more polished writings are published to my main blog at chiubaca.com

Follow me on: Github / X (Twitter) / Mastodon / LinkedIn