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:
Shahed Nasser
2024-05-22 13:37:48 +03:00
committed by GitHub
parent ff5d573887
commit 154673f3d8
55 changed files with 1674 additions and 3791 deletions
@@ -12,16 +12,18 @@ Cross-Origin Resource Sharing (CORS) allows only configured origins to access yo
### CORS Configurations
You configure allowed origins for Store and Admin API Routes using the `store_cors` and `admin_cors` configurations in `medusa-config.js`. Each of these configurations accepts a URL pattern to identify allowed origins.
You configure allowed origins for Store and Admin API Routes using the `storeCors` and `adminCors` properties of the `http` configuration in `medusa-config.js`. Each of these configurations accepts a URL pattern to identify allowed origins.
For example:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
admin_cors: "http://localhost:7001",
store_cors: "http://localhost:8000",
// ...
http: {
adminCors: "http://localhost:7001",
storeCors: "http://localhost:8000",
// ...
}
},
// ...
}
@@ -90,7 +92,7 @@ export const config: MiddlewaresConfig = {
return cors({
origin: parseCorsOrigins(
configModule.projectConfig.store_cors
configModule.projectConfig.http.storeCors
),
credentials: true,
})(req, res, next)
@@ -101,4 +103,4 @@ export const config: MiddlewaresConfig = {
}
```
This retrieves the configurations exported from `medusa-config.js` and applies the `store_cors` to routes starting with `/custom`.
This retrieves the configurations exported from `medusa-config.js` and applies the `storeCors` to routes starting with `/custom`.
@@ -59,21 +59,21 @@ For example:
```ts title="src/api/store/me/custom/route.ts" highlights={[["16", "", "Access the logged-in customer's ID."]]}
import type {
MedusaRequest,
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { ICustomerModuleService } from "@medusajs/types"
export const GET = async (
req: MedusaRequest,
req: AuthenticatedMedusaRequest,
res: MedusaResponse
) => {
const customerService: ICustomerModuleService =
req.scope.resolve(ModuleRegistrationName.CUSTOMER)
const customer = await customerService.retrieve(
req.user.customer_id
req.auth.actor_id
)
// ...
@@ -92,21 +92,21 @@ For example:
```ts title="src/api/admin/custom/route.ts" highlights={[["16", "req.user.userId", "Access the logged-in admin user's ID."]]}
import type {
MedusaRequest,
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IUserModuleService } from "@medusajs/types"
export const GET = async (
req: MedusaRequest,
req: AuthenticatedMedusaRequest,
res: MedusaResponse
) => {
const userService: IUserModuleService = req.scope.resolve(
ModuleRegistrationName.USER
)
const user = await userService.retrieve(req.user.userId)
const user = await userService.retrieve(req.auth.actor_id)
// ...
}
@@ -129,9 +129,7 @@ export const highlights = [
```ts title="src/api/middlewares.ts" highlights={highlights}
// TODO update import
import {
authenticate,
} from "@medusajs/medusa/dist/utils/authenticate-middleware"
import { MiddlewaresConfig, authenticate } from "@medusajs/medusa"
export const config: MiddlewaresConfig = {
routes: [