Skip to content

Commit

Permalink
Merge branch 'v2' into feat/default-runtime-node-version
Browse files Browse the repository at this point in the history
  • Loading branch information
luc122c authored Nov 13, 2024
2 parents 75f1aa4 + 9563e9a commit 2d64cf6
Show file tree
Hide file tree
Showing 105 changed files with 4,266 additions and 3,092 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "nitro-devcontainer",
"forwardPorts": [3000],
"image": "node:20.18.0",
"image": "node:22.11.0",
"features": {},
"customizations": {
"vscode": {
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ body:
https://github.com/nuxt/nuxt/issues/new/choose
Please use one of the templates below to create a minimal reproduction :
👉 https://stackblitz.com/github/unjs/nitro/tree/starter
👉 https://codesandbox.io/p/github/unjs/nitro/starter
👉 https://stackblitz.com/github/nitrojs/nitro/tree/starter
👉 https://codesandbox.io/p/github/nitrojs/nitro/starter
- type: textarea
id: bug-env
attributes:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
blank_issues_enabled: true
contact_links:
- name: 📚 Nitro Documentation
url: https://nitro.unjs.io/
url: https://nitro.build/
about: Check the documentation for usage of Nuxt 3
- name: 💬 Discussions
url: https://github.com/unjs/nitro/discussions
url: https://github.com/nitrojs/nitro/discussions
about: Use discussions if you have an idea for improvement and asking questions
- name: 🔗 Nuxt related Issues
url: https://github.com/nuxt/nuxt/issues/new/choose
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- If it is a bug fix, please ensure there is a linked issue with minimal (nitro) reproduction and/or enough context to explain exactly what it is fixing and why this fix is the best option in Nitro.
- If it is a security fix, please always report it first as per https://github.com/unjs/nitro/blob/main/SECURITY.md
- If it is a security fix, please always report it first as per https://github.com/nitrojs/nitro/blob/main/SECURITY.md
- If it is a new feature, please ensure it has already been discussed. Keep the scope of changes minimal to what is essential, and try to break down your changes into smaller PRs when possible.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- run: pnpm test:types
if: ${{ matrix.os != 'windows-latest' }}
- run: pnpm build
- run: pnpm vitest-es --coverage
- run: pnpm vitest --coverage
env:
NODE_OPTIONS: --experimental-vm-modules --enable-source-maps
# - uses: codecov/codecov-action@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ staticwebapp.config.json
.eslintcache
playground/firebase.json
.zeabur
.apphosting

test/fixture/functions
.data
Expand Down
3,317 changes: 1,863 additions & 1,454 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

<!-- /automd -->

Create web servers that run anywhere! 📖 [**documentation**](https://nitro.unjs.io)
Create web servers that run anywhere! 📖 [**documentation**](https://nitro.build)

> [!NOTE]
> You are on the v2 branch. Check [main branch](https://github.com/unjs/nitro/tree/main) for v3 development tree.
> You are on the v2 branch. Check [main branch](https://github.com/nitrojs/nitro/tree/main) for v3 development tree.
## Contribution

Expand All @@ -31,11 +31,11 @@ Create web servers that run anywhere! 📖 [**documentation**](https://nitro.unj

<!-- automd:contributors license=MIT author="pi0" -->

Published under the [MIT](https://github.com/unjs/nitro/blob/main/LICENSE) license.
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/nitro/graphs/contributors) 💛
Published under the [MIT](https://github.com/nitrojs/nitro/blob/main/LICENSE) license.
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/nitrojs/nitro/graphs/contributors) 💛
<br><br>
<a href="https://github.com/unjs/nitro/graphs/contributors">
<img src="https://contrib.rocks/image?repo=unjs/nitro" />
<a href="https://github.com/nitrojs/nitro/graphs/contributors">
<img src="https://contrib.rocks/image?repo=nitrojs/nitro" />
</a>

<!-- /automd -->
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## ⚠️ Reporting a Vulnerability

To report a vulnerability, please send an email to [[email protected]](mailto:[email protected]) or submit it for a bounty via [Huntr](https://huntr.dev/bounties/disclose/?target=https://github.com/unjs/nitro).
To report a vulnerability, please send an email to [[email protected]](mailto:[email protected]) or submit it for a bounty via [Huntr](https://huntr.dev/bounties/disclose/?target=https://github.com/nitrojs/nitro).

All security vulnerabilities will be promptly verified and addressed.

Expand Down
6 changes: 3 additions & 3 deletions docs/.config/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: Nitro
shortDescription: Next Generation Server Toolkit
description: Create web servers with everything you need and deploy them wherever you prefer.
github: unjs/nitro
url: https://nitro.unjs.io
github: nitrojs/nitro
url: https://nitro.build
themeColor: "red"
automd: true
redirects:
Expand All @@ -13,7 +13,7 @@ landing:
playOnline:
label: "Play Online"
icon: "i-simple-icons-lightning"
to: "https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world"
to: "https://stackblitz.com/github/nitrojs/nitro/tree/main/examples/hello-world"
contributors: true
featuresTitle: "A Server for the Modern Web"
features:
Expand Down
4 changes: 2 additions & 2 deletions docs/1.guide/0.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Nitro automatically makes your code compatible with any [deployment](/deploy) pr
## Quick start

> [!TIP]
> Instead of setting up a local development environment, you can use the [online playground](https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world).
> Instead of setting up a local development environment, you can use the [online playground](https://stackblitz.com/github/nitrojs/nitro/tree/main/examples/hello-world).
::note
Make sure you have installed the recommended setup:
Expand Down Expand Up @@ -57,7 +57,7 @@ You can try it locally with:
:pm-run{script="preview"}

::read-more
You can find more examples in the Nitro repository: [unjs/nitro/examples](https://github.com/unjs/nitro/tree/main/examples)
You can find more examples in the Nitro repository: [nitrojs/nitro/examples](https://github.com/nitrojs/nitro/tree/main/examples)
::

## Directory structure
Expand Down
4 changes: 2 additions & 2 deletions docs/1.guide/1.utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Nitro also exposes several built-in utils:
- `nitroPlugin(plugin)`{lang=ts}
- `getRouteRules(event)`{lang=ts}

::read-more{to="https://github.com/unjs/nitro/blob/v2/src/core/config/resolvers/imports.ts#L58"}
Check [the source code](https://github.com/unjs/nitro/blob/v2/src/core/config/resolvers/imports.ts#L58) for list of available Nitro auto imports.
::read-more{to="https://github.com/nitrojs/nitro/blob/v2/src/core/config/resolvers/imports.ts#L58"}
Check [the source code](https://github.com/nitrojs/nitro/blob/v2/src/core/config/resolvers/imports.ts#L58) for list of available Nitro auto imports.
::

::read-more{to="/guide/typescript"}
Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/10.tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ icon: codicon:run-all

> [!IMPORTANT]
> Tasks support is currently experimental.
> See [unjs/nitro#1974](https://github.com/unjs/nitro/issues/1974) for the relevant discussion.
> See [nitrojs/nitro#1974](https://github.com/nitrojs/nitro/issues/1974) for the relevant discussion.
In order to tasks API you need to enable experimental feature flag.

Expand Down
9 changes: 3 additions & 6 deletions docs/1.guide/2.routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ export default defineEventHandler(event => {

### Environment specific handlers

> [!NOTE]
> This feature is currently available in [nightly channel](https://nitro.unjs.io/guide/nightly) only.
You can specify for a route that will only be included in specific builds by adding a `.dev`, `.prod` or `.prerender` suffix to the file name, for example: `routes/test.get.dev.ts` or `routes/test.get.prod.ts`.

> [!TIP]
Expand Down Expand Up @@ -210,8 +207,8 @@ Returning anything from a middleware will close the request and should be avoide

You can define route handler meta at build-time using `defineRouteMeta` micro in the event handler files.

> [!NOTE]
> This feature is currently available in [nightly channel](https://nitro.unjs.io/guide/nightly) only.
> [!IMPORTANT]
> 🚧 This feature is currently experimental.
```ts [/api/test.ts]
defineRouteMeta({
Expand Down Expand Up @@ -275,7 +272,7 @@ You can use the [utilities available in H3](https://h3.unjs.io/guide/event-handl

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 delievered. 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.

This behaviour can be overridden by some request properties (eg.: `Accept` or `User-Agent` headers).
This behaviour can be overridden by some request properties (e.g.: `Accept` or `User-Agent` headers).

## Route Rules

Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/3.websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Nitro natively supports runtime agnostic [WebSocket](https://developer.mozilla.o
## Opt-in to the experimental feature

> [!IMPORTANT]
> WebSockets support is currently experimental. See [unjs/nitro#2171](https://github.com/unjs/nitro/issues/2171) for platform support status.
> WebSockets support is currently experimental. See [nitrojs/nitro#2171](https://github.com/nitrojs/nitro/issues/2171) for platform support status.
In order to enable websocket support you need to enable the experimental `websocket` feature flag.

Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/4.storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default defineNuxtConfig({
::

::warning
This is a temporary workaround, with a better solution coming in the future! Keep a lookout on the GitHub issue [here](https://github.com/unjs/nitro/issues/1161#issuecomment-1511444675).
This is a temporary workaround, with a better solution coming in the future! Keep a lookout on the GitHub issue [here](https://github.com/nitrojs/nitro/issues/1161#issuecomment-1511444675).
::

### Development-only mount points
Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/6.cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ The `cachedEventHandler` and `cachedFunction` functions accept the following opt
A function that returns a `boolean` to bypass the current cache without invalidating the existing entry.
::
::field{name="varies" type="string[]"}
An array of request headers to be considered for the cache, [learn more](https://github.com/unjs/nitro/issues/1031). If utilizing in a multi-tenant environment, you may want to pass `['host', 'x-forwarded-host']` to ensure these headers are not discarded and that the cache is unique per tenant.
An array of request headers to be considered for the cache, [learn more](https://github.com/nitrojs/nitro/issues/1031). If utilizing in a multi-tenant environment, you may want to pass `['host', 'x-forwarded-host']` to ensure these headers are not discarded and that the cache is unique per tenant.
::
::

Expand Down
6 changes: 3 additions & 3 deletions docs/1.guide/9.plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default defineNitroPlugin((nitro) => {

### Available hooks

See the [source code](https://github.com/unjs/nitro/blob/main/src/runtime/types.ts#L24) for list of all available runtime hooks.
See the [source code](https://github.com/nitrojs/nitro/blob/v2/src/core/index.ts#L75) for list of all available runtime hooks.

- `"close", () => {}`
- `"error", (error, { event? }) => {}`
Expand Down Expand Up @@ -114,10 +114,10 @@ export default defineNitroPlugin((nitroApp) => {

### Renderer response

You can use plugins to register a hook that modifies the [`renderer`](https://nitro.unjs.io/config#renderer) response.
You can use plugins to register a hook that modifies the [`renderer`](https://nitro.build/config#renderer) response.

::note
This **only works** for render handler defined with [`renderer`](https://nitro.unjs.io/config#renderer) and won't be called for other api/server routes.
This **only works** for render handler defined with [`renderer`](https://nitro.build/config#renderer) and won't be called for other api/server routes.
In [Nuxt](https://nuxt.com/) this hook will be called for Server Side Rendered pages
::

Expand Down
4 changes: 2 additions & 2 deletions docs/1.guide/98.typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ icon: tabler:brand-typescript
## `tsconfig.json`

To leverage type hints within your project, create a `tsconfig.json` file that extends auto generated types.
To leverage type hints within your project, create a `tsconfig.json` file that extends auto-generated types.

::code-group
```json [tsconfig.json (nitro)]
Expand Down Expand Up @@ -36,7 +36,7 @@ This can be useful in a CI environment or as a `postinstall` command in your `pa
:pm-x{command="nitro prepare"}

::tip
When using `nitro dev` command, types are also auto generated!
When using `nitro dev` command, types are also auto-generated!
::

::note
Expand Down
1 change: 1 addition & 0 deletions docs/2.deploy/0.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ When deploying to production using CI/CD, Nitro tries to automatically detect th
- [aws amplify](/deploy/providers/aws-amplify)
- [azure](/deploy/providers/azure)
- [cloudflare pages](/deploy/providers/cloudflare#cloudflare-pages)
- [firebase app hosting](/deploy/providers/firebase#firebase-app-hosting-beta)
- [netlify](/deploy/providers/netlify)
- [stormkit](/deploy/providers/stormkit)
- [vercel](/deploy/providers/vercel)
Expand Down
2 changes: 1 addition & 1 deletion docs/2.deploy/1.workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Nitro provides out of the box support for deploying any Nitro app to different E
### Incompatible libraries

::note
If you come across a library that you assume to be incompatible with edge workers, please open an issue on the [nitro repo](https://github.com/unjs/nitro/issues/new/choose) and help us keeping this list up to date.
If you come across a library that you assume to be incompatible with edge workers, please open an issue on the [nitro repo](https://github.com/nitrojs/nitro/issues/new/choose) and help us keeping this list up to date.
::

The following libraries are known to be incompatible with edge workers because of one of the above mentioned limitations:
Expand Down
7 changes: 1 addition & 6 deletions docs/2.deploy/10.runtimes/_winterjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ You can easily build Nitro powered applications to run with [wasmerio/winterjs](


::warning
🌙 WinterJS is currently supported in **nightly release channel**. Read the docs for using [Nightly Release Channel](/guide/getting-started#nightly-release-channel).
::


::warning
🚧 WinterJS runtime is unstable and under heavy development. Follow [unjs/nitro#1861](https://github.com/unjs/nitro/issues/1861) for status and information.
🚧 WinterJS runtime is unstable and under heavy development. Follow [nitrojs/nitro#1861](https://github.com/nitrojs/nitro/issues/1861) for status and information.
::


Expand Down
4 changes: 2 additions & 2 deletions docs/2.deploy/2.custom-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Custom local preset support is an experimental feature.
## Example

::note
Check [unjs/nitro-preset-starter](https://github.com/unjs/nitro-preset-starter) for a ready-to-use template.
Check [nitrojs/nitro-preset-starter](https://github.com/nitrojs/nitro-preset-starter) for a ready-to-use template.
::

First, we have to define our preset entry point in a local directory `preset/nitro.config.ts`
Expand Down Expand Up @@ -98,4 +98,4 @@ export default defineNuxtConfig({
::


Refer to the Nitro [source code](https://github.com/unjs/nitro/tree/main/src) directly to have a better understanding of presets and entry points.
Refer to the Nitro [source code](https://github.com/nitrojs/nitro/tree/main/src) directly to have a better understanding of presets and entry points.
21 changes: 10 additions & 11 deletions docs/2.deploy/20.providers/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { statusCode, headers, body } = handler({ rawPath: '/' })

## Inlining chunks

Nitro output, by default uses dynamic chunks for lazy loading code only when needed. However this sometimes can not be ideal for performance. (See discussions in [unjs/nitro#650](https://github.com/unjs/nitro/pull/650)). You can enabling chunk inlining behavior using [`inlineDynamicImports`](/config#inlinedynamicimports) config.
Nitro output, by default uses dynamic chunks for lazy loading code only when needed. However this sometimes can not be ideal for performance. (See discussions in [nitrojs/nitro#650](https://github.com/nitrojs/nitro/pull/650)). You can enabling chunk inlining behavior using [`inlineDynamicImports`](/config#inlinedynamicimports) config.

::code-group

Expand All @@ -41,17 +41,16 @@ export default defineNuxtConfig({
::


## Streaming support (experimental)

**Preset:** `aws_lambda_streaming`

Nitro supports an experimental preset to generate output format compatible with [AWS Lambda](https://aws.amazon.com/lambda/) with streaming invoke turned on.
## Response streaming

:read-more{title="Introducing AWS Lambda response streaming" to="https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/"}

> [!NOTE]
> This preset available via [nightly channel](https://nitro.unjs.io/guide/nightly) to try.
> [!IMPORTANT]
> This preset is not production ready and might be renamed! Please don't advice users or document to indirectly use it.
In order to enable response streaming, enable `awsLambda.streaming` flag:

```ts [nitro.config.ts]
export default defineNitroConfig({
awsLambda: {
streaming: true
}
});
```
2 changes: 1 addition & 1 deletion docs/2.deploy/20.providers/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ If you are using runtimeConfig, you will likely want to configure the correspond

::important
If you encounter any issues, please ensure you're using a Node.js 16+ runtime. You can find more information about [how to set the Node version in the Azure docs](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=v2#setting-the-node-version).
Please see [unjs/nitro#2114](https://github.com/unjs/nitro/issues/2114) for some common issues.
Please see [nitrojs/nitro#2114](https://github.com/nitrojs/nitro/issues/2114) for some common issues.
::

### Local preview
Expand Down
Loading

0 comments on commit 2d64cf6

Please sign in to comment.