From 6335f166e7c6082c5392ba71f74272f2b4be2429 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 13 Oct 2022 17:40:19 +0300 Subject: [PATCH] docs: changed JavaScript files to TypeScript (#2440) --- docs/content/advanced/backend/entities/overview.md | 2 +- docs/content/advanced/backend/services/overview.md | 4 ++-- docs/content/advanced/backend/subscribers/overview.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content/advanced/backend/entities/overview.md b/docs/content/advanced/backend/entities/overview.md index f07893d921..8b32de6193 100644 --- a/docs/content/advanced/backend/entities/overview.md +++ b/docs/content/advanced/backend/entities/overview.md @@ -6,7 +6,7 @@ In this document, you'll learn what Entities are in Medusa. Entities in medusa represent tables in the database as classes. An example of this would be the `Order` entity which represents the `order` table in the database. Entities provide a uniform way of defining and interacting with data retrieved from the database. -Aside from Medusa’s core entities, you can also create your own entities to use in your Medusa server. Custom entities must reside in the `src/models` directory of your Medusa server. +Aside from Medusa’s core entities, you can also create your own entities to use in your Medusa server. Custom entities are TypeScript or JavaScript files located in the `src/models` directory of your Medusa server. Entities are TypeScript files and they are based on [Typeorm’s Entities](https://typeorm.io/entities) and use Typeorm decorators. diff --git a/docs/content/advanced/backend/services/overview.md b/docs/content/advanced/backend/services/overview.md index 1652b52c70..4fe54a9f25 100644 --- a/docs/content/advanced/backend/services/overview.md +++ b/docs/content/advanced/backend/services/overview.md @@ -8,13 +8,13 @@ Services in Medusa represent bundled helper methods that you want to use across For example, you can use Medusa’s `productService` to get the list of products, as well as perform other functionalities related to products. There’s also an `authService` that provides functionalities like authenticating customers and users. -Custom services reside in the `src/services` directory of your Medusa Server installation. Each service should be a class that extends the `TransactionBaseService` class from the core Medusa package `@medusajs/medusa`. +Custom services are TypeScript or JavaScript files located in the `src/services` directory of your Medusa Server installation. Each service should be a class that extends the `TransactionBaseService` class from the core Medusa package `@medusajs/medusa`. Each file you create in `src/services` should hold one service and export it. The file name is important as it determines the name of the service when you need to use it elsewhere. The name of the service will be registered as the camel-case version of the file name + `Service` at the end of the name. -For example, if the file name is `hello.js`, the service will be registered as `helloService`. If the file name is `hello-world.js`, the service name will be registered as `helloWorldService`. +For example, if the file name is `hello.ts`, the service will be registered as `helloService`. If the file name is `hello-world.ts`, the service name will be registered as `helloWorldService`. The registration name of the service is important, as you’ll be referring to it when you want to get access to the service using dependency injection or in routes. diff --git a/docs/content/advanced/backend/subscribers/overview.md b/docs/content/advanced/backend/subscribers/overview.md index d4ac9daa2f..2fd87d677f 100644 --- a/docs/content/advanced/backend/subscribers/overview.md +++ b/docs/content/advanced/backend/subscribers/overview.md @@ -16,7 +16,7 @@ Subscribers register handlers for an events and allows you to perform an action Natively in Medusa there are subscribers to handle different events. However, you can also create your own custom subscribers. -Custom subscribers reside in your project's `src/subscribers` directory. Files here should export classes, which will be treated as subscribers by Medusa. By convention, the class name should end with `Subscriber` and the file name should be the camel-case version of the class name without `Subscriber`. For example, the `WelcomeSubscriber` class is in the file `src/subscribers/welcome.js`. +Custom subscribers are TypeScript or JavaScript files in your project's `src/subscribers` directory. Files here should export classes, which will be treated as subscribers by Medusa. By convention, the class name should end with `Subscriber` and the file name should be the camel-case version of the class name without `Subscriber`. For example, the `WelcomeSubscriber` class is in the file `src/subscribers/welcome.ts`. Whenever an event is emitted, the subscriber’s registered handler method is executed. The handler method receives as a parameter an object that holds data related to the event. For example, if an order is placed the `order.placed` event will be emitted and all the handlers will receive the order id in the parameter object.