docs: add documentation for v1.8 (#3669)

This commit is contained in:
Shahed Nasser
2023-04-03 13:50:59 +02:00
committed by GitHub
parent 0cca13779d
commit c6bfad14d8
123 changed files with 7610 additions and 2697 deletions
+21 -7
View File
@@ -2,7 +2,7 @@
description: 'Learn what Services are in Medusa. Services represent bundled helper methods that you want to use across your commerce application.'
---
import DocCard from '@theme/DocCard';
import DocCardList from '@theme/DocCardList';
import Icons from '@theme/Icon';
# Services
@@ -17,11 +17,15 @@ For example, you can use Medusas `productService` to get the list of products
In the Medusa backend, custom services are TypeScript or JavaScript files located in the `src/services` directory. 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.
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 in the dependency container as the camel-case version of the file name with `Service` appended to the end of the name. Other resources, such as other services or endpoints, will use that name when resolving the service from the dependency container.
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`.
For example, if the file name is `hello.ts`, the service will be registered as `helloService` in the dependency container. 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 youll be referring to it when you want to get access to the service using dependency injection or in routes.
:::note
You can learn more about the dependency container and how it works in the [dependency injection](../fundamentals/dependency-injection.md) documentation.
:::
The service must then be transpiled using the `build` command, which moves them to the `dist` directory, to be used across your commerce application.
@@ -37,7 +41,8 @@ If you're creating a service in a plugin, learn more about the required structur
Developers can create custom services in the Medusa backend, a plugin, or in a Commerce Module.
<DocCard item={{
<DocCardList colSize={6} items={[
{
type: 'link',
href: '/development/services/create-service',
label: 'Create a Service',
@@ -45,5 +50,14 @@ Developers can create custom services in the Medusa backend, a plugin, or in a C
icon: Icons['academic-cap-solid'],
description: 'Learn how to create a service in Medusa.'
}
}}
/>
},
{
type: 'link',
href: '/development/services/extend-service',
label: 'Extend a Service',
customProps: {
icon: Icons['academic-cap-solid'],
description: 'Learn how to extend a core Medusa service.'
}
},
]} />