Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(tasks): use server/ dir #2775

Draft
wants to merge 1 commit into
base: v2
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions docs/1.guide/10.tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export default defineNuxtConfig({

## Define tasks

Tasks can be defined in `tasks/[name].ts` files.
Tasks can be defined in `server/tasks/[name].ts` files.

Nested directories are supported. The task name will be joined with `:`. (Example: `tasks/db/migrate.ts`task name will be `db:migrate`)
Nested directories are supported. The task name will be joined with `:`. (Example: `server/tasks/db/migrate.ts`task name will be `db:migrate`)

**Example:**

```ts [tasks/db/migrate.ts]
```ts [server/tasks/db/migrate.ts]
export default defineTask({
meta: {
name: "db:migrate",
Expand All @@ -56,10 +56,6 @@ export default defineTask({
});
```

> [!NOTE]
> Use `server/tasks/db/migrate.ts` for Nuxt.


## Scheduled tasks

You can define scheduled tasks using Nitro configuration to automatically run after each period of time.
Expand Down Expand Up @@ -150,7 +146,7 @@ This endpoint returns a list of available task names and their meta.
This endpoint executes a task. You can provide a payload using both query parameters and body JSON payload. The payload sent in the JSON body payload must be under the `"payload"` property.

::code-group
```ts [tasks/echo/payload.ts]
```ts [server/tasks/echo/payload.ts]
export default defineTask({
meta: {
name: "echo:payload",
Expand Down