docs: fixes and changes based on latest updates (#7322)
* docs: changes based on DX changes * remove fields no longer needed * remove unnecessary parameters * fixes to authenticate middleware usage * add highlight to migrations config * change configuration to http * added missing remote link docs * fix name in sidebar * added notification module docs + updated file module docs * add vale exceptions * fix vale errors * added docs on custom cli scripts
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
---
|
||||
slug: /references/notification-provider-module
|
||||
---
|
||||
|
||||
import { TypeList } from "docs-ui"
|
||||
|
||||
# How to Create a Notification Provider Module
|
||||
|
||||
In this document, you’ll learn how to create a notification provider module and the methods you must implement in it.
|
||||
|
||||
---
|
||||
|
||||
## 1. Create Module Directory
|
||||
|
||||
Start by creating a new directory for your module. For example, `src/modules/my-notification`.
|
||||
|
||||
---
|
||||
|
||||
## 2. Create the Notification Provider Service
|
||||
|
||||
Create the file `src/modules/my-notification/service.ts` that holds the implementation of the notification service.
|
||||
|
||||
The Notification Provider Module's main service must extend the `AbstractNotificationProviderService` class imported from `@medusajs/utils`:
|
||||
|
||||
```ts title="src/modules/my-notification/service.ts"
|
||||
import {
|
||||
AbstractNotificationProviderService
|
||||
} from "@medusajs/utils"
|
||||
|
||||
class MyNotificationProviderService extends AbstractNotificationProviderService {
|
||||
// TODO add methods
|
||||
}
|
||||
|
||||
export default MyNotificationProviderService
|
||||
```
|
||||
|
||||
### constructor
|
||||
|
||||
### send
|
||||
|
||||
#### Parameters
|
||||
|
||||
<TypeList types={[{"name":"notification","type":"`ProviderSendNotificationDTO`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="send"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<ProviderSendNotificationResultsDTO>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ProviderSendNotificationResultsDTO","type":"`ProviderSendNotificationResultsDTO`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} sectionTitle="send"/>
|
||||
|
||||
---
|
||||
|
||||
## 3. Create Module Definition File
|
||||
|
||||
Create the file `src/modules/my-notification/index.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/my-notification/index.ts"
|
||||
import MyNotificationProviderService from "./service"
|
||||
|
||||
export default {
|
||||
service: MyNotificationProviderService,
|
||||
}
|
||||
```
|
||||
|
||||
This exports the module's definition, indicating that the `MyNotificationProviderService` is the main service of the module.
|
||||
|
||||
---
|
||||
|
||||
## 4. Use Module
|
||||
|
||||
To use your Notification Provider Module, add it to the `providers` array of the Notification Module:
|
||||
|
||||
<Note>
|
||||
|
||||
The Notification Module accepts one provider per channel.
|
||||
|
||||
</Note>
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const { Modules } = require("@medusajs/modules-sdk")
|
||||
|
||||
// ...
|
||||
|
||||
const modules = {
|
||||
// ...
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "./dist/modules/my-notification",
|
||||
options: {
|
||||
config: {
|
||||
"my-notification": {
|
||||
channels: ["email"],
|
||||
// provider options...
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user