Skip to content

Commit

Permalink
Merge branch 'main' into pr/igorjacauna/1763
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 30, 2023
2 parents 2464169 + 1d093d6 commit a85a018
Show file tree
Hide file tree
Showing 116 changed files with 6,593 additions and 3,120 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm stub
- name: Fix lint issues
run: npm run lint:fix
- uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc
- uses: autofix-ci/action@bee19d72e71787c12ca0f29de72f2833e437e4c9
with:
commit-message: "chore: apply automated fixes"
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: pnpm
Expand All @@ -35,7 +35,7 @@ jobs:
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: pnpm
Expand All @@ -54,7 +54,7 @@ jobs:
- run: pnpm vitest-es --coverage
env:
NODE_OPTIONS: --experimental-vm-modules --enable-source-maps
- uses: codecov/codecov-action@v3
# - uses: codecov/codecov-action@v3
- name: Release Nightly
if: |
github.event_name == 'push' &&
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ Temporary Items
.env
.netlify
.vercel
.amplify-hosting
staticwebapp.config.json
.eslintcache
playground/firebase.json
.zeabur

test/fixture/functions

.pnpm-store
.wrangler
144 changes: 144 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,150 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## v2.8.1

[compare changes](https://github.com/unjs/nitro/compare/v2.8.0...v2.8.1)

### 🩹 Fixes

- **dev:** Conditionally access worker address for build info ([#1947](https://github.com/unjs/nitro/pull/1947))
- Force use wasm import strategy for windows ([e73b849f](https://github.com/unjs/nitro/commit/e73b849f))
- **netlify-lambda:** Handle base64 encoded body ([#1940](https://github.com/unjs/nitro/pull/1940))
- **cloudflare:** Wasm support with dynamic chunks ([#1957](https://github.com/unjs/nitro/pull/1957))
- **prerenderer:** Write responses with json signature to original path ([#1963](https://github.com/unjs/nitro/pull/1963))

### 📖 Documentation

- **cache:** Make default value `swr: true` more clear ([#1949](https://github.com/unjs/nitro/pull/1949))

### 🏡 Chore

- Update lockfile ([716edd52](https://github.com/unjs/nitro/commit/716edd52))
- **docs:** Update lockfile ([b4386f8c](https://github.com/unjs/nitro/commit/b4386f8c))

### ✅ Tests

- Add tests for wasm ([#1951](https://github.com/unjs/nitro/pull/1951))
- **cloudflare-pages:** Remover overlapping include rules ([789a13d3](https://github.com/unjs/nitro/commit/789a13d3))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))
- Becem <[email protected]>
- Mick Lawitzke ([@MickL](http://github.com/MickL))

## v2.8.0

[compare changes](https://github.com/unjs/nitro/compare/v2.7.1...v2.8.0)

### 🚀 Enhancements

- Support modules to extend nitro builder ([#1789](https://github.com/unjs/nitro/pull/1789))
- Support `inline` mode for `serveStatic` ([#1864](https://github.com/unjs/nitro/pull/1864))
- Add experimental `winterjs` preset ([#1863](https://github.com/unjs/nitro/pull/1863))
- Allow setting preset using `SERVER_PRESET` environment variable ([#1870](https://github.com/unjs/nitro/pull/1870))
- **cloudflare-pages, cloudflare-module:** Enable code splitting by default ([#1905](https://github.com/unjs/nitro/pull/1905))
- Support `framework` config ([#1843](https://github.com/unjs/nitro/pull/1843))
- Add aws amplify hosting preset ([#1912](https://github.com/unjs/nitro/pull/1912))
- Upgrade to rollup v4 ([#1927](https://github.com/unjs/nitro/pull/1927))
- Improve `nitro.json` build info ([#1930](https://github.com/unjs/nitro/pull/1930))
- **aws-amplify:** Support static builds ([#1933](https://github.com/unjs/nitro/pull/1933))
- Add `defineNitroErrorHandler` type helper ([#1923](https://github.com/unjs/nitro/pull/1923))

### 🩹 Fixes

- **cloudflare-pages:** Filter out overlapping public assets dirs ([#1859](https://github.com/unjs/nitro/pull/1859))
- **winterjs:** 0.1.7 compatibility ([#1876](https://github.com/unjs/nitro/pull/1876))
- **scanner:** Allow having http method as part of the route name ([#1895](https://github.com/unjs/nitro/pull/1895))
- Generate route types with resolve path and stripped extension ([#1897](https://github.com/unjs/nitro/pull/1897))
- Scan dirs for unimport on initialization ([#1908](https://github.com/unjs/nitro/pull/1908))
- **aws-amplify:** Register and auto detect ([0f38eb6f](https://github.com/unjs/nitro/commit/0f38eb6f))
- **prerender:** Decode generated routes ([#1914](https://github.com/unjs/nitro/pull/1914))
- Disabled public asset handler name is `null` ([b7a6a1a6](https://github.com/unjs/nitro/commit/b7a6a1a6))
- **prerender:** Decode uris in headers ([#1932](https://github.com/unjs/nitro/pull/1932))
- **error:** Respect `accept: text/html` request header ([#1921](https://github.com/unjs/nitro/pull/1921))
- **prerender:** Filter encoded links starting with `#` ([#1936](https://github.com/unjs/nitro/pull/1936))

### 💅 Refactors

- **deno-deploy:** Use `Deno.serve` ([#1879](https://github.com/unjs/nitro/pull/1879))
- Split preset types ([#1910](https://github.com/unjs/nitro/pull/1910))

### 📖 Documentation

- **deploy:** Split runtimes from providers ([#1865](https://github.com/unjs/nitro/pull/1865))
- **routing:** Add note about middleware returns ([#1884](https://github.com/unjs/nitro/pull/1884))
- Update edge links to nightly ([#1902](https://github.com/unjs/nitro/pull/1902))
- **deploy:** Add deno to runtime list ([#1899](https://github.com/unjs/nitro/pull/1899))
- **cloudflare:** Updatge wrangler link ([#1913](https://github.com/unjs/nitro/pull/1913))
- **aws-amplify:** Add custom `amplify.yml` ([f412af16](https://github.com/unjs/nitro/commit/f412af16))
- **amplify:** Remove cache from config ([7bbb723e](https://github.com/unjs/nitro/commit/7bbb723e))
- Hide winterjs due to unstability ([048c8ff0](https://github.com/unjs/nitro/commit/048c8ff0))
- **aws-amplify:** Update regions ([#1931](https://github.com/unjs/nitro/pull/1931))
- **aws-amplify:** Add step to enable SSR logging and remove experimental ([#1934](https://github.com/unjs/nitro/pull/1934))
- **aws-amplify:** Remove workaround banner ([#1935](https://github.com/unjs/nitro/pull/1935))

### 🌊 Types

- Export `SerializeTuple` and `SerializeObject` ([#1907](https://github.com/unjs/nitro/pull/1907))

### 🏡 Chore

- **release:** V2.7.1 ([2d803a3c](https://github.com/unjs/nitro/commit/2d803a3c))
- Add jsdoc for `cache.maxAge` ([#1878](https://github.com/unjs/nitro/pull/1878))
- Update lockfile ([dbff232e](https://github.com/unjs/nitro/commit/dbff232e))
- **docs:** Update dependencies ([28867009](https://github.com/unjs/nitro/commit/28867009))
- **docs:** Fix prerender issues ([d2a7d84d](https://github.com/unjs/nitro/commit/d2a7d84d))
- Update unstorage ([110bc4a3](https://github.com/unjs/nitro/commit/110bc4a3))
- Update unstorage ([441db6ca](https://github.com/unjs/nitro/commit/441db6ca))
- Fix typos in aws amplify ([963716dd](https://github.com/unjs/nitro/commit/963716dd))
- Update lockfile ([926bcef4](https://github.com/unjs/nitro/commit/926bcef4))

### ✅ Tests

- Hide winterjs due to unstability ([1b50a9a1](https://github.com/unjs/nitro/commit/1b50a9a1))

### 🤖 CI

- Disable codecov and codeql ([fd4671ce](https://github.com/unjs/nitro/commit/fd4671ce))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))
- Siegerts <[email protected]>
- Passionate-bram
- Daniel Roe <[email protected]>
- Neil Richter ([@noook](http://github.com/noook))
- Xin Du (Clark) <[email protected]>
- Anthony Fu <[email protected]>
- Dario Piotrowicz ([@dario-piotrowicz](http://github.com/dario-piotrowicz))
- Kalwabed Rizki
- Thunfisch987
- Oof2win2 <[email protected]>
- Markthree ([@markthree](http://github.com/markthree))
- Estéban ([@Barbapapazes](http://github.com/Barbapapazes))

## v2.7.1

[compare changes](https://github.com/unjs/nitro/compare/v2.7.0...v2.7.1)

### 🩹 Fixes

- Recursively simplify returned objects ([#1847](https://github.com/unjs/nitro/pull/1847))
- **cache:** Fix `etag` and `last-modified` values ([#1855](https://github.com/unjs/nitro/pull/1855))
- **cache:** Invalidate wrongly cached handler entities ([#1857](https://github.com/unjs/nitro/pull/1857))

### 🏡 Chore

- Update dependencies ([7a6c61db](https://github.com/unjs/nitro/commit/7a6c61db))
- Update lockfile ([9b5ed9a1](https://github.com/unjs/nitro/commit/9b5ed9a1))
- Update lockfile ([b0ec181d](https://github.com/unjs/nitro/commit/b0ec181d))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))
- Daniel Roe <[email protected]>

## v2.7.0

[compare changes](https://github.com/unjs/nitro/compare/v2.6.3...v2.7.0)
Expand Down
3 changes: 2 additions & 1 deletion docs/content/1.guide/3.routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ nitro.config.ts
### Simple Middleware

Middleware are defined exactly like route handlers with the only exception that they should not return anything.
Returning from middleware behaves like returning from a request - the value will be returned as a response and further code will not be ran.

```ts [middleware/auth.ts]
export default defineEventHandler((event) => {
Expand All @@ -181,7 +182,7 @@ export default defineEventHandler((event) => {
```

::alert
Returning anything from a middleware will close the request and should be avoided!
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!**
::

### Execution Order
Expand Down
4 changes: 2 additions & 2 deletions docs/content/1.guide/5.cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Cache a route with [stale-while-revalidate](https://www.rfc-editor.org/rfc/rfc58
export default cachedEventHandler(async () => {
return `Response generated at ${new Date().toISOString()}`;
}, {
swr: true, maxAge: 10
maxAge: 10
});
```

The response will be cached for 10 second and a stale value will be sent to the client while the cache is being updated in the background.
The response will be cached for 10 seconds and a stale value will be sent to the client while the cache is being updated in the background. If you want to immediately return the updated response set `swr: false`.

The cached answer will be store in development inside `.nitro/cache/handlers/_/*.json`.

Expand Down
3 changes: 2 additions & 1 deletion docs/content/2.deploy/0.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ When running Nitro in development mode, Nitro will always use a special preset c

When deploying to the production using CI/CD, Nitro tries to automatically detect the provider environment and set the right one without any additional configuration. Currently, providers below can be auto-detected with zero config.

- [aws amplify](/deploy/providers/aws-amplify)
- [azure](/deploy/providers/azure)
- [cloudflare pages](/deploy/providers/cloudflare#cloudflare-pages)
- [netlify](/deploy/providers/netlify)
- [stormkit](/deploy/providers/stormkit)
- [vercel](/deploy/providers/vercel)

- [zeabur](/deploy/providers/zeabur)

## Changing the deployment preset

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
icon: ri:global-line
---

# Workers
# Edge Workers

Nitro provides out of the box support for deploying to Edge Workers.

Expand All @@ -11,7 +11,7 @@ Nitro provides out of the box support for deploying to Edge Workers.
Nitro provides out of the box support for deploying any Nitro app to different Edge Worker offerings as well as Service Workers.

- [Cloudflare](/deploy/providers/cloudflare)
- [Deno](/deploy/providers/deno)
- [Deno Deploy](/deploy/providers/deno-deploy)
- [Vercel](/deploy/providers/vercel#vercel-edge-functions)
- [Netlify](/deploy/providers/netlify#netlify-edge-functions)
- [Lagon](/deploy/providers/lagon)
Expand Down
1 change: 1 addition & 0 deletions docs/content/2.deploy/10.runtimes/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
icon: codicon:run-all
36 changes: 36 additions & 0 deletions docs/content/2.deploy/10.runtimes/_winterjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
icon: game-icons:cold-heart
---

# WinterJS

**Preset:** `winterjs` ([switch to this preset](/deploy/#changing-the-deployment-preset))

You can easily build Nitro powered applications to run with [wasmerio/winterjs](https://github.com/wasmerio/winterjs) runtime.

[WinterJS](https://github.com/wasmerio/winterjs) is a JavaScript Service Workers server written in Rust, that uses the SpiderMonkey runtime to execute JavaScript (the same runtime that Firefox uses) ([announcement](https://wasmer.io/posts/announcing-winterjs-service-workers)).


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


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


In order to build for this runtime, use `NITRO_PRESET="winterjs"` environment variable:

```sh
NITRO_PRESET="winterjs" npm run build
```

Make sure you have `wasmer` installed locally ([install wasmer](https://docs.wasmer.io/install))

Run locally:

```sh
wasmer run wasmer/winterjs --forward-host-env --net --mapdir app:.output app/server/index.mjs
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
---
icon: simple-icons:bun

---

# Bun

Run Nitro apps with [Bun](https://bun.sh/) runtime.

**Preset:** `bun` ([switch to this preset](/deploy/#changing-the-deployment-preset))

::alert{type="warning"}
Bun preset is experimental and available to try via [edge channel](/guide/getting-started#edge-release-channel).
Bun preset is experimental and available to try via [edge channel](/guide/getting-started#nightly-release-channel).
::

## Building for Bun
Expand Down
25 changes: 25 additions & 0 deletions docs/content/2.deploy/10.runtimes/deno.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
icon: simple-icons:deno
---

# Deno

Run Nitro apps with [Deno](https://deno.com/) runtime.

## Deno Server

**Preset:** `deno-server` ([switch to this preset](/deploy/#changing-the-deployment-preset))

::alert{type="warning"}
Deno runtime preset is experimental.
::

You can build your Nitro server using Node.js to run within [Deno Runtime](https://deno.com/runtime) in a custom server.

```bash
# Build with the deno NITRO preset
NITRO_PRESET=deno-server npm run build

# Start production server
deno run --unstable --allow-net --allow-read --allow-env .output/server/index.ts
```
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/content/2.deploy/20.providers/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
icon: tdesign:cloud
Loading

0 comments on commit a85a018

Please sign in to comment.