Skip to content

Commit 541bff8

Browse files
authored
docs: changes for new releases + fixes (medusajs#12945)
* docs: changes for new releases + fixes * remove container option
1 parent 3028425 commit 541bff8

File tree

10 files changed

+175
-65
lines changed

10 files changed

+175
-65
lines changed

www/apps/book/app/learn/configurations/medusa-config/page.mdx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,87 @@ module.exports = defineConfig({
7070

7171
The `projectConfig` object contains essential configurations related to the Medusa application, such as database and CORS configurations.
7272

73+
### cookieOptions
74+
75+
<Note>
76+
77+
This option is available since Medusa [v2.8.5](https://github.com/medusajs/medusa/releases/tag/v2.8.5).
78+
79+
</Note>
80+
81+
The `projectConfig.cookieOptions` configuration defines cookie options to be passed to `express-session` when creating the session cookie. This configuration is useful when simulating a production environment locally, where you may need to set options like `secure` or `sameSite`.
82+
83+
#### Example
84+
85+
```ts title="medusa-config.ts"
86+
module.exports = defineConfig({
87+
projectConfig: {
88+
cookieOptions: {
89+
sameSite: "lax",
90+
},
91+
// ...
92+
},
93+
// ...
94+
})
95+
```
96+
97+
#### Properties
98+
99+
Aside from the following options, you can pass any property that the [express-session's cookie option accepts](https://www.npmjs.com/package/express-session).
100+
101+
<TypeList
102+
types={[
103+
{
104+
name: "secure",
105+
type: "`boolean`",
106+
description: `Whether the cookie should only be sent over HTTPS. This is useful in production environments where you want to ensure that cookies are only sent over secure connections.`,
107+
defaultValue: `false in development, true in production`
108+
},
109+
{
110+
name: "sameSite",
111+
type: "`lax` | `strict` | `none`",
112+
description: `Controls the SameSite attribute of the cookie.`,
113+
defaultValue: `"none" in production. In development, this attribute is not set.`
114+
},
115+
{
116+
name: "maxAge",
117+
type: "`number`",
118+
description: "The maximum age of the cookie in milliseconds set in the `Set-Cookie` header.",
119+
defaultValue: "Either the `sessionOptions.ttl` option, or `10` hours."
120+
},
121+
{
122+
name: "httpOnly",
123+
type: "`boolean`",
124+
description: "Whether to set the `HttpOnly Set-Cookie` attribute.",
125+
defaultValue: `true`
126+
},
127+
{
128+
name: "priority",
129+
type: "`low` \| `medium` \| `high`",
130+
description: "The value of the [Priority Set-Cookie attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1)",
131+
defaultValue: `medium`
132+
},
133+
{
134+
name: "domain",
135+
type: "`string`",
136+
description: "The value of the `Domain Set-Cookie` attribute. By default, no domain is set, and most clients will consider the cookie to apply to the current domain only."
137+
},
138+
{
139+
name: "path",
140+
type: "`string`",
141+
description: "The value of the `Path Set-Cookie` attribute",
142+
defaultValue: `/`
143+
},
144+
{
145+
name: "signed",
146+
type: "`boolean`",
147+
description: "Whether to sign the cookie.",
148+
defaultValue: `true`
149+
}
150+
]}
151+
openedLevel={1}
152+
/>
153+
73154
### databaseDriverOptions
74155

75156
The `projectConfig.databaseDriverOptions` configuration is an object of additional options used to configure the PostgreSQL connection. For example, you can support TLS/SSL connection using this configuration's `ssl` property.

www/apps/book/app/learn/fundamentals/api-routes/retrieve-custom-links/page.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The API routes that restrict the fields and relations you can retrieve are:
4545

4646
### How to Override Allowed Fields and Relations
4747

48-
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by adding a [middleware](../middlewares/page.mdx) to those routes.
48+
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by applying a [global middleware](../middlewares/page.mdx) to those routes.
4949

5050
For example, to allow retrieving the `b2b_company` of a customer using the [Get Customer Admin API Route](!api!/admin#customers_getcustomersid), create the file `src/api/middlewares.ts` with the following content:
5151

@@ -66,10 +66,9 @@ export default defineMiddlewares({
6666
routes: [
6767
{
6868
matcher: "/store/customers/me",
69-
method: "GET",
7069
middlewares: [
7170
(req, res, next) => {
72-
req.allowed?.push("b2b_company")
71+
(req.allowed ??= []).push("b2b_company")
7372
next()
7473
},
7574
],
@@ -90,3 +89,9 @@ curl 'http://localhost:9000/admin/customers/{id}?fields=*b2b_company' \
9089
```
9190

9291
In this example, you retrieve the `b2b_company` relation of the customer using the `fields` query parameter.
92+
93+
<Note title="Important">
94+
95+
This approach only works using a global middleware. It doesn't work in a route middleware.
96+
97+
</Note>

www/apps/book/app/learn/fundamentals/workflows/long-running-workflow/page.mdx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ export const setStepSuccessStep = createStep(
151151
workflowId: "hello-world",
152152
},
153153
stepResponse: new StepResponse("Done!"),
154-
options: {
155-
container,
156-
},
157154
})
158155
}
159156
)
@@ -203,20 +200,6 @@ The `setStepSuccess` method of the workflow engine's main service accepts as a p
203200
description: "Set the response of the step. This is similar to the response you return in a step's definition, but since the `async` step doesn't have a response, you set its response when changing its status.",
204201
optional: false
205202
},
206-
{
207-
name: "options",
208-
type: "`Record<string, any>`",
209-
description: "Options to pass to the step.",
210-
optional: true,
211-
children: [
212-
{
213-
name: "container",
214-
type: "`MedusaContainer`",
215-
description: "An instance of the Medusa Container",
216-
optional: true
217-
}
218-
]
219-
}
220203
]}
221204
/>
222205

@@ -269,9 +252,6 @@ export const setStepFailureStep = createStep(
269252
workflowId: "hello-world",
270253
},
271254
stepResponse: new StepResponse("Failed!"),
272-
options: {
273-
container,
274-
},
275255
})
276256
}
277257
)

www/apps/book/generated/edit-dates.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const generatedEditDates = {
3030
"app/learn/fundamentals/workflows/conditions/page.mdx": "2025-01-27T08:45:19.027Z",
3131
"app/learn/fundamentals/modules/module-link-directions/page.mdx": "2024-07-24T09:16:01+02:00",
3232
"app/learn/fundamentals/admin/page.mdx": "2025-04-18T10:28:47.328Z",
33-
"app/learn/fundamentals/workflows/long-running-workflow/page.mdx": "2025-03-28T07:02:34.467Z",
33+
"app/learn/fundamentals/workflows/long-running-workflow/page.mdx": "2025-07-14T10:32:21.640Z",
3434
"app/learn/fundamentals/workflows/constructor-constraints/page.mdx": "2025-04-24T13:18:24.184Z",
3535
"app/learn/fundamentals/data-models/write-migration/page.mdx": "2025-03-24T06:41:48.915Z",
3636
"app/learn/fundamentals/data-models/manage-relationships/page.mdx": "2025-04-25T14:16:41.124Z",
@@ -112,13 +112,13 @@ export const generatedEditDates = {
112112
"app/learn/resources/contribution-guidelines/admin-translations/page.mdx": "2025-02-11T16:57:46.726Z",
113113
"app/learn/resources/contribution-guidelines/docs/page.mdx": "2025-05-26T15:55:02.974Z",
114114
"app/learn/resources/usage/page.mdx": "2025-02-26T13:35:34.824Z",
115-
"app/learn/configurations/medusa-config/page.mdx": "2025-06-10T13:18:26.064Z",
115+
"app/learn/configurations/medusa-config/page.mdx": "2025-07-14T09:28:54.302Z",
116116
"app/learn/configurations/ts-aliases/page.mdx": "2025-02-11T16:57:46.683Z",
117117
"app/learn/production/worker-mode/page.mdx": "2025-03-11T15:21:50.906Z",
118118
"app/learn/fundamentals/module-links/read-only/page.mdx": "2025-05-13T15:04:12.107Z",
119119
"app/learn/fundamentals/data-models/properties/page.mdx": "2025-03-18T07:57:17.826Z",
120120
"app/learn/fundamentals/framework/page.mdx": "2025-06-26T14:26:22.120Z",
121-
"app/learn/fundamentals/api-routes/retrieve-custom-links/page.mdx": "2025-04-25T14:26:25.000Z",
121+
"app/learn/fundamentals/api-routes/retrieve-custom-links/page.mdx": "2025-07-14T10:24:32.582Z",
122122
"app/learn/fundamentals/workflows/errors/page.mdx": "2025-04-25T14:26:25.000Z",
123123
"app/learn/fundamentals/api-routes/override/page.mdx": "2025-05-09T08:01:24.493Z",
124124
"app/learn/fundamentals/module-links/index/page.mdx": "2025-05-23T07:57:58.958Z",

www/apps/book/public/llms-full.txt

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@ module.exports = defineConfig({
140140

141141
The `projectConfig` object contains essential configurations related to the Medusa application, such as database and CORS configurations.
142142

143+
### cookieOptions
144+
145+
This option is available since Medusa [v2.8.5](https://github.com/medusajs/medusa/releases/tag/v2.8.5).
146+
147+
The `projectConfig.cookieOptions` configuration defines cookie options to be passed to `express-session` when creating the session cookie. This configuration is useful when simulating a production environment locally, where you may need to set options like `secure` or `sameSite`.
148+
149+
#### Example
150+
151+
```ts title="medusa-config.ts"
152+
module.exports = defineConfig({
153+
projectConfig: {
154+
cookieOptions: {
155+
sameSite: "lax",
156+
},
157+
// ...
158+
},
159+
// ...
160+
})
161+
```
162+
163+
#### Properties
164+
165+
Aside from the following options, you can pass any property that the [express-session's cookie option accepts](https://www.npmjs.com/package/express-session).
166+
167+
- secure: (\`boolean\`)
168+
- sameSite: (\`lax\` | \`strict\` | \`none\`)
169+
- maxAge: (\`number\`) The maximum age of the cookie in milliseconds set in the \`Set-Cookie\` header.
170+
- httpOnly: (\`boolean\`) Whether to set the \`HttpOnly Set-Cookie\` attribute.
171+
- priority: (\`low\` | \`medium\` | \`high\`) The value of the \[Priority Set-Cookie attribute]\(https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1)
172+
- domain: (\`string\`) The value of the \`Domain Set-Cookie\` attribute. By default, no domain is set, and most clients will consider the cookie to apply to the current domain only.
173+
- path: (\`string\`) The value of the \`Path Set-Cookie\` attribute
174+
- signed: (\`boolean\`) Whether to sign the cookie.
175+
143176
### databaseDriverOptions
144177

145178
The `projectConfig.databaseDriverOptions` configuration is an object of additional options used to configure the PostgreSQL connection. For example, you can support TLS/SSL connection using this configuration's `ssl` property.
@@ -677,7 +710,7 @@ The value for this configuration can be one of the following:
677710
```ts title="medusa-config.ts"
678711
module.exports = defineConfig({
679712
projectConfig: {
680-
workerMode: process.env.WORKER_MODE || "shared",
713+
workerMode: process.env.WORKER_MODE as "shared" | "worker" | "server" || "shared",
681714
// ...
682715
},
683716
// ...
@@ -7619,7 +7652,7 @@ The API routes that restrict the fields and relations you can retrieve are:
76197652

76207653
### How to Override Allowed Fields and Relations
76217654

7622-
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by adding a [middleware](https://docs.medusajs.com/learn/fundamentals/api-routes/middlewares/index.html.md) to those routes.
7655+
For these routes, you need to override the allowed fields and relations to be retrieved. You can do this by applying a [global middleware](https://docs.medusajs.com/learn/fundamentals/api-routes/middlewares/index.html.md) to those routes.
76237656

76247657
For example, to allow retrieving the `b2b_company` of a customer using the [Get Customer Admin API Route](https://docs.medusajs.com/api/admin#customers_getcustomersid), create the file `src/api/middlewares.ts` with the following content:
76257658

@@ -7632,10 +7665,9 @@ export default defineMiddlewares({
76327665
routes: [
76337666
{
76347667
matcher: "/store/customers/me",
7635-
method: "GET",
76367668
middlewares: [
76377669
(req, res, next) => {
7638-
req.allowed?.push("b2b_company")
7670+
(req.allowed ??= []).push("b2b_company")
76397671
next()
76407672
},
76417673
],
@@ -7657,6 +7689,8 @@ curl 'http://localhost:9000/admin/customers/{id}?fields=*b2b_company' \
76577689

76587690
In this example, you retrieve the `b2b_company` relation of the customer using the `fields` query parameter.
76597691

7692+
This approach only works using a global middleware. It doesn't work in a route middleware.
7693+
76607694

76617695
# Request Body and Query Parameter Validation
76627696

@@ -17308,9 +17342,6 @@ export const setStepSuccessStep = createStep(
1730817342
workflowId: "hello-world",
1730917343
},
1731017344
stepResponse: new StepResponse("Done!"),
17311-
options: {
17312-
container,
17313-
},
1731417345
})
1731517346
}
1731617347
)
@@ -17330,9 +17361,6 @@ The `setStepSuccess` method of the workflow engine's main service accepts as a p
1733017361

1733117362
- workflowId: (\`string\`) The ID of the workflow. This is the first parameter passed to \`createWorkflow\` when creating the workflow.
1733217363
- stepResponse: (\`StepResponse\`) Set the response of the step. This is similar to the response you return in a step's definition, but since the \`async\` step doesn't have a response, you set its response when changing its status.
17333-
- options: (\`Record\<string, any>\`) Options to pass to the step.
17334-
17335-
- container: (\`MedusaContainer\`) An instance of the Medusa Container
1733617364

1733717365
### Change Step Status to Failed
1733817366

@@ -17374,9 +17402,6 @@ export const setStepFailureStep = createStep(
1737417402
workflowId: "hello-world",
1737517403
},
1737617404
stepResponse: new StepResponse("Failed!"),
17377-
options: {
17378-
container,
17379-
},
1738017405
})
1738117406
}
1738217407
)
@@ -83992,6 +84017,7 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
8399284017
return !customer.email
8399384018
}
8399484019
).then(() => {
84020+
// @ts-ignore
8399584021
const { data } = useQueryGraphStep({
8399684022
entity: "customer",
8399784023
fields: ["email"],
@@ -89892,14 +89918,14 @@ To implement the step, create the file `src/workflows/restaurant/steps/create-re
8989289918
```ts title="src/workflows/restaurant/steps/create-restaurant.ts" highlights={createRestaurantHighlight} collapsibleLines="1-7" expandMoreLabel="Show Imports"
8989389919
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
8989489920
import {
89895-
CreateRestaurantDTO,
89921+
CreateRestaurant,
8989689922
} from "../../../modules/restaurant/types/mutations"
8989789923
import { RESTAURANT_MODULE } from "../../../modules/restaurant"
8989889924
import RestaurantModuleService from "../../../modules/restaurant/service"
8989989925

8990089926
export const createRestaurantStep = createStep(
8990189927
"create-restaurant-step",
89902-
async function (data: CreateRestaurantDTO, { container }) {
89928+
async function (data: CreateRestaurant, { container }) {
8990389929
const restaurantModuleService: RestaurantModuleService = container.resolve(
8990489930
RESTAURANT_MODULE
8990589931
)
@@ -89971,15 +89997,15 @@ Then, create the file `src/api/restaurants/route.ts` with the following content:
8997189997
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
8997289998
import { MedusaError } from "@medusajs/framework/utils"
8997389999
import {
89974-
CreateRestaurantDTO,
90000+
CreateRestaurant,
8997590001
} from "../../modules/restaurant/types/mutations"
8997690002
import {
8997790003
createRestaurantWorkflow,
8997890004
} from "../../workflows/restaurant/workflows/create-restaurant"
8997990005
import { restaurantSchema } from "./validation-schemas"
8998090006

8998190007
export async function POST(req: MedusaRequest, res: MedusaResponse) {
89982-
const validatedBody = restaurantSchema.parse(req.body) as CreateRestaurantDTO
90008+
const validatedBody = restaurantSchema.parse(req.body) as CreateRestaurant
8998390009

8998490010
if (!validatedBody) {
8998590011
return MedusaError.Types.INVALID_DATA
@@ -91663,9 +91689,6 @@ export const setStepSuccessStep = createStep(
9166391689
workflowId: handleDeliveryWorkflowId,
9166491690
},
9166591691
stepResponse: new StepResponse(updatedDelivery, updatedDelivery.id),
91666-
options: {
91667-
container,
91668-
},
9166991692
})
9167091693
}
9167191694
)
@@ -91710,9 +91733,6 @@ export const setStepFailedStep = createStep(
9171091733
workflowId: handleDeliveryWorkflowId,
9171191734
},
9171291735
stepResponse: new StepResponse(updatedDelivery, updatedDelivery.id),
91713-
options: {
91714-
container,
91715-
},
9171691736
})
9171791737
}
9171891738
)

0 commit comments

Comments
 (0)