Skip to content

Commit 1720448

Browse files
committed
merge latest v3 changes
2 parents 1b1c728 + b51230f commit 1720448

50 files changed

Lines changed: 4008 additions & 2507 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ Check [release notes](https://github.com/nitrojs/nitro/releases/tag/v2.11.0)
19811981
- Nested fetch calls with incoming headers and context in event context ([learn more](https://github.com/nitrojs/nitro/pull/930))
19821982
- Binary and Raw storage operations support ([learn more](https://github.com/unjs/unstorage/pull/141))
19831983
- [Cloudflare] Exposed `event.context.cf` ([learn more](https://github.com/nitrojs/nitro/pull/927))
1984-
- Built-in session support ([learn more](https://github.com/unjs/h3/pull/315))
1984+
- Built-in session support ([learn more](https://github.com/h3js/h3/pull/315))
19851985

19861986
### 🚀 Enhancements
19871987

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
CODE_OF_CONDUCT.md.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contribution Guide
2+
3+
<!-- https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors -->
4+
5+
> All contributors lead the growth of Nitro - including you!
6+
7+
## Discussions
8+
9+
You can involve in discussions using:
10+
11+
- [Github Discussions](discussions)
12+
- [Nitro Discord](https://discord.nitro.build)
13+
14+
## Contribute to the Code
15+
16+
> [!IMPORTANT]
17+
> Please discuss your ideas with the maintainers before opening a pull request.
18+
19+
### Local Development
20+
21+
- Clone the [`nitrojs/nitro`](https://github.com/nitrojs/nitro) git repository.
22+
- Install the latest LTS version of [Node.js](https://nodejs.org/en/) (v22+).
23+
- Enable [corepack](https://github.com/nodejs/corepack) using `corepack enable` (run `npm i -g corepack` if it's not available).
24+
- Install dependencies using `pnpm install`.
25+
- Build the project in stub mode using `pnpm build --stub`.
26+
- Run the playground with `pnpm nitro dev ./playground` to verify changes.
27+
- Add, modify, and run tests using `pnpm test`.
28+
- Tip: Run `pnpm vitest test/presets/node.test.ts` for quick testing.
29+
30+
## Reporting Issues
31+
32+
You might encounter a bug while using Nitro.
33+
34+
Although we aim to resolve all known issues, new bugs can emerge over time. Your bug report helps us find and fix them faster — even if you're unable to fix the underlying code yourself.
35+
36+
Here’s how to report a bug effectively:
37+
38+
### Ensure It's a Bug
39+
40+
Sometimes what seems like a bug may actually be expected behavior or a missing feature. Make sure you’re reporting an actual bug by creating a minimal nitro project and reducing scope.
41+
42+
### Create a Minimal Reproduction
43+
44+
Please create a minimal reproduction using the Nitro starter templates.
45+
46+
Sometimes, bugs originate from another layer — not Nitro itself. A minimal reproduction helps identify the source and speeds up debugging.
47+
48+
Use one of the following templates to reproduce the issue:
49+
50+
- [Stackblitz Template](https://stackblitz.com/fork/github/nitrojs/nitro-starter)
51+
- [Nitro Starter Repo](https://github.com/nitrojs/nitro-starter)
52+
53+
If your bug involves a higher-level framework like [Nuxt](https://nuxt.com), please report it there. Maintainers will help narrow it down to a Nitro-level issue if needed.
54+
55+
### Search Existing Issues and Discussions
56+
57+
Before creating a new issue, search existing [issues](https://github.com/nitrojs/nitro/issues) and [discussions](https://github.com/nitrojs/nitro/discussions) to see if your bug has already been reported.
58+
59+
If it has already been reported:
60+
- Add a 👍 reaction to the original post (instead of commenting "me too" or "when will it be fixed").
61+
- If you can provide additional context or a better/smaller reproduction, please share it.
62+
63+
> [!NOTE]
64+
> If the issue seems related but different or old or already closed, it's **better to open a new issue**. Maintainers will merge similar issues if needed.
65+

README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<!-- automd:badges -->
44

5-
[![npm version](https://flat.badgen.net/npm/v/nitropack)](https://npmjs.com/package/nitropack)
6-
[![npm downloads](https://flat.badgen.net/npm/dm/nitropack)](https://npmjs.com/package/nitropack)
5+
[![npm version](https://img.shields.io/npm/v/nitro)](https://npmjs.com/package/nitro)
6+
[![npm downloads](https://img.shields.io/npm/dm/nitro)](https://npm.chart.dev/nitro)
77

88
<!-- /automd -->
99

@@ -16,18 +16,7 @@ Check [migration guide](./docs/1.guide/00.migration.md) for migrating from Nitro
1616

1717
## Contribution
1818

19-
<details>
20-
<summary>Local development</summary>
21-
22-
- Clone this repository
23-
- Install the latest LTS version of [Node.js](https://nodejs.org/en/)
24-
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
25-
- Install dependencies using `pnpm install`
26-
- Run tests using `pnpm dev` or `pnpm test`
27-
28-
</details>
29-
30-
<!-- /automd -->
19+
Please check [Contribution guide](CONTRIBUTING.md).
3120

3221
## License
3322

automd.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default {
2+
input: ["README.md", "docs/**/*.md"],
3+
generators: {
4+
compatDate: {
5+
async generate(ctx) {
6+
const { compatibilityChanges } = await import("./lib/meta.mjs");
7+
8+
const table = [
9+
"| Compatibility date | Platform | Description |",
10+
"|------|----------|-------------|",
11+
...compatibilityChanges.map(
12+
(change) =>
13+
`| **≥ ${change.from}** | ${change.platform} | ${change.description} |`
14+
),
15+
];
16+
17+
return {
18+
contents: table.join("\n"),
19+
};
20+
},
21+
},
22+
},
23+
};

docs/.config/automd.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "../../automd.config";

docs/1.guide/0.index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ icon: ph:book-open-duotone
1212
1313
## Intro
1414

15-
Nitro is an open source framework to build web servers using [unjs/h3](https://h3.unjs.io) and lots of built-in features.
15+
Nitro is an open source framework to build web servers using [h3](https://h3.dev/) and lots of built-in features.
1616
Nitro automatically makes your code compatible with any [deployment](/deploy) provider and runtime!
1717

1818
> [!NOTE]

docs/1.guide/1.utils.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ It is because Nitro uses [unjs/unimport](https://github.com/unjs/unimport) to au
1313

1414
## H3 utils
1515

16-
Nitro enables all [h3 utils](https://h3.unjs.io/utils) as auto imports so you can use `defineEventHandler`, `readBody`, etc. without manually importing them.
16+
Nitro enables all [h3 utils](https://h3.dev/utils) as auto imports so you can use `defineEventHandler`, `readBody`, etc. without manually importing them.
1717

18-
::read-more{title="H3 Docs" to="https://h3.unjs.io/utils"}
18+
::read-more{title="H3 Docs" to="https://h3.dev/utils"}
1919
::
2020

2121

docs/1.guide/2.routing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ icon: ri:direction-line
88
99
## Event handlers
1010

11-
An [event handler](https://h3.unjs.io/guide/event-handler) is a function that will be bound to a route and executed when the route is matched by the router for an incoming request.
11+
An [event handler](https://h3.dev/guide/event-handler) is a function that will be bound to a route and executed when the route is matched by the router for an incoming request.
1212

13-
:read-more{to="https://h3.unjs.io/guide/event-handler"}
13+
:read-more{to="https://h3.dev/guide/event-handler"}
1414

1515
## Filesystem routing
1616

17-
Nitro supports file-based routing for your API routes (files are automatically mapped to [h3 routes](https://h3.unjs.io/guide/router)). Defining a route is as simple as creating a file inside the `server/api/` or `server/routes/` directory.
17+
Nitro supports file-based routing for your API routes (files are automatically mapped to [h3 routes](https://h3.dev/guide/router)). Defining a route is as simple as creating a file inside the `server/api/` or `server/routes/` directory.
1818

1919
You can only define one handler per files and you can [append the HTTP method](#specific-request-method) to the filename to define a specific request method.
2020

@@ -64,7 +64,7 @@ export default defineEventHandler(() => {
6464

6565
#### Single param
6666

67-
To define a route with params, use the `[<param>]` syntax where `<param>` is the name of the param. The param will be available in the `event.context.params` object or using the `getRouterParam` utility from [unjs/h3](https://h3.unjs.io).
67+
To define a route with params, use the `[<param>]` syntax where `<param>` is the name of the param. The param will be available in the `event.context.params` object or using the `getRouterParam` utility from [h3](https://h3.dev/).
6868

6969
```ts [server/routes/hello/[name\\].ts]
7070
export default defineEventHandler(event => {
@@ -169,7 +169,7 @@ Nitro route middleware can hook into the request lifecycle.
169169
A middleware can modify the request before it is processed, not after.
170170
::
171171

172-
:read-more{to="https://h3.unjs.io/guide/event-handler#middleware"}
172+
:read-more{to="https://h3.dev/guide/event-handler#middleware"}
173173

174174
Middleware are auto-registered within the `server/middleware/` directory.
175175

@@ -196,7 +196,7 @@ export default defineEventHandler((event) => {
196196
})
197197
```
198198

199-
Middleware in `server/middleware/` directory are automatically registered for all routes. If you want to register a middleware for a specific route, see [Object Syntax Event Handler](https://h3.unjs.io/guide/event-handler#object-syntax).
199+
Middleware in `server/middleware/` directory are automatically registered for all routes. If you want to register a middleware for a specific route, see [Object Syntax Event Handler](https://h3.dev/guide/event-handler#object-syntax).
200200

201201
::note
202202
Returning anything from a middleware will close the request and should be avoided! Any returned value from middleware will be the response and further code will not be executed however **this is not recommended to do!**
@@ -269,7 +269,7 @@ export default defineEventHandler((event) => {
269269

270270
## Error handling
271271

272-
You can use the [utilities available in H3](https://h3.unjs.io/guide/event-handler#error-handling) to handle errors in both routes and middlewares.
272+
You can use the [utilities available in H3](https://h3.dev/guide/event-handler#error-handling) to handle errors in both routes and middlewares.
273273

274274
The way errors are sent back to the client depends on the route's path. For most routes `Content-Type` is set to `text/html` by default and a simple html error page is delivered. If the route starts with `/api/` (either because it is placed in `api/` or `routes/api/`) the default will change to `application/json` and a JSON object will be sent.
275275

@@ -279,7 +279,7 @@ This behaviour can be overridden by some request properties (e.g.: `Accept` or `
279279

280280
Nitro allows you to add logic at the top-level for each route of your configuration. It can be used for redirecting, proxying, caching and adding headers to routes.
281281

282-
It is a map from route pattern (following [unjs/radix3](https://github.com/unjs/rou3/tree/radix3#route-matcher)) to route options.
282+
It is a map from route pattern (following [rou3](https://github.com/h3js/rou3)) to route options.
283283

284284
When `cache` option is set, handlers matching pattern will be automatically wrapped with `defineCachedEventHandler`. See the [cache guide](/guide/cache) to learn more about this function.
285285

docs/1.guide/3.websocket.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ icon: cib:socket-io
66

77
> Nitro natively supports a cross platform WebSocket API
88
9-
Nitro natively supports runtime agnostic [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) API using [CrossWS](https://crossws.unjs.io/) and [H3 WebSocket](https://h3.unjs.io/guide/websocket).
9+
Nitro natively supports runtime agnostic [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) API using [CrossWS](https://crossws.h3.dev/) and [H3 WebSocket](https://h3.dev/guide/websocket).
1010

1111
:read-more{title="WebSocket in MDN" to="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket"}
1212

@@ -46,7 +46,7 @@ Create a websocket handler in `server/routes/_ws.ts`.
4646
> [!TIP]
4747
> You can use any route like `server/routes/chatroom.ts` to register upgrade handler on `/chatroom`.
4848
49-
<!-- automd:file code src="../../examples/websocket/routes/_ws.ts" -->
49+
<!-- automd-disabled:file code src="../../examples/websocket/routes/_ws.ts" -->
5050

5151
```ts [server/routes/_ws.ts]
5252
export default defineWebSocketHandler({
@@ -79,12 +79,12 @@ export default defineWebSocketHandler({
7979
8080
Use a client to connect to server. Example: (`server/routes/websocket.ts`)
8181

82-
<!-- automd:file code src="../../examples/websocket/routes/index.ts" -->
82+
<!-- automd-disabled:file code src="../../examples/websocket/routes/index.ts" -->
8383

8484
```ts [index.ts]
8585
export default defineEventHandler(() => {
8686
return $fetch(
87-
"https://raw.githubusercontent.com/unjs/crossws/main/examples/h3/public/index.html"
87+
"https://raw.githubusercontent.com/h3js/crossws/main/examples/h3/public/index.html"
8888
);
8989
});
9090

@@ -132,4 +132,4 @@ eventSource.onmessage = (event) => {
132132
}
133133
```
134134

135-
:read-more{to="https://h3.unjs.io/guide/websocket#server-sent-events-sse" title="SSE guide in H3"}
135+
:read-more{to="https://h3.dev/guide/websocket#server-sent-events-sse" title="SSE guide in H3"}

0 commit comments

Comments
 (0)