From 07e65f5aba3853496609764c808d470f19b94512 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 25 Sep 2023 19:03:00 +0300 Subject: [PATCH] docs: Improve Loaders documentation (#5205) --- .../content/development/loaders/create.md | 4 +-- .../content/development/loaders/overview.mdx | 29 +------------------ www/apps/docs/docusaurus.config.js | 3 +- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/www/apps/docs/content/development/loaders/create.md b/www/apps/docs/content/development/loaders/create.md index 5102e86e30..a8fa251151 100644 --- a/www/apps/docs/content/development/loaders/create.md +++ b/www/apps/docs/content/development/loaders/create.md @@ -39,12 +39,12 @@ When the loader is defined in a module, it receives the following parameters: For example, this loader function resolves the `ProductService` and logs in the console the count of products in the Medusa backend: ```ts title=src/loaders/my-loader.ts -import { ProductService } from "@medusajs/medusa" +import { ProductService, ConfigModule } from "@medusajs/medusa" import { AwilixContainer } from "awilix" export default async ( container: AwilixContainer, - config: Record + config: ConfigModule ): Promise => { console.info("Starting loader...") const productService = container.resolve( diff --git a/www/apps/docs/content/development/loaders/overview.mdx b/www/apps/docs/content/development/loaders/overview.mdx index f93d0ac001..1f4249358a 100644 --- a/www/apps/docs/content/development/loaders/overview.mdx +++ b/www/apps/docs/content/development/loaders/overview.mdx @@ -23,34 +23,7 @@ Another example is the Algolia plugin, which uses a loader to update the index s Loaders can be used to access the dependency container and register custom resources in it. -Loaders can also be used to create [scheduled jobs](../scheduled-jobs/overview.mdx) that run at a specified interval of time. For example: - -```ts -const publishJob = async (container, options) => { - const jobSchedulerService = - container.resolve("jobSchedulerService") - jobSchedulerService.create( - "publish-products", - {}, - "0 0 * * *", - async () => { - // job to execute - const productService = container.resolve("productService") - const draftProducts = await productService.list({ - status: "draft", - }) - - for (const product of draftProducts) { - await productService.update(product.id, { - status: "published", - }) - } - } - ) -} - -export default publishJob -``` +Loaders can also be used to create [scheduled jobs](../scheduled-jobs/overview.mdx) that run at a specified interval of time. --- diff --git a/www/apps/docs/docusaurus.config.js b/www/apps/docs/docusaurus.config.js index 0b275dbb7b..0aeac47d27 100644 --- a/www/apps/docs/docusaurus.config.js +++ b/www/apps/docs/docusaurus.config.js @@ -237,7 +237,8 @@ const config = { { docs: { sidebarPath: require.resolve("./sidebars.js"), - editUrl: "https://github.com/medusajs/medusa/edit/develop/www/docs", + editUrl: + "https://github.com/medusajs/medusa/edit/develop/www/apps/docs", path: "content", routeBasePath: "/", remarkPlugins: [