-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(middleware): emit warning if
next
is called and nothing is retu…
…rned (#7010) * fix(middleware): emit warning if `next` is called and nothing is returned * chore: add test case * chore: changeset * chore: restore code, ooops! * chore: change logic * change namespace
- Loading branch information
Showing
12 changed files
with
82 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Call `next()` without return anything should work, with a warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
/// <reference types="astro/client" /> | ||
declare global { | ||
namespace AstroMiddleware { | ||
interface Locals { | ||
user: { | ||
name: string; | ||
surname: string; | ||
}; | ||
} | ||
declare namespace App { | ||
interface Locals { | ||
user: { | ||
name: string; | ||
surname: string; | ||
}; | ||
} | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/middleware-tailwind/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import tailwind from '@astrojs/tailwind'; | ||
|
||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [tailwind()], | ||
experimental: { | ||
middleware: true, | ||
} | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/middleware-tailwind/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/middleware-tailwind", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/tailwind": "workspace:*" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/middleware-tailwind/src/middleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const onRequest = (_, next) => { | ||
next(); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/astro/test/fixtures/middleware-tailwind/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1 class="text-blue-500 text-2xl font-bold">Hello world</h1> | ||
|
||
<style> | ||
p { | ||
color: red; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.