-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: deprecate NodeApp #15535
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
Merged
+359
−266
Merged
feat: deprecate NodeApp #15535
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
01955b4
move stuff around
florian-lefebvre e40f14e
deprecate
florian-lefebvre 6db5228
utils
florian-lefebvre f94758d
usage
florian-lefebvre 86dd215
changesets
florian-lefebvre a54c88a
Update .changeset/good-clubs-cover.md
florian-lefebvre 1ebff24
Update .changeset/polite-terms-shop.md
florian-lefebvre 797cab6
changeset
florian-lefebvre fd6474e
fix: lint
florian-lefebvre 331f382
Merge branch 'main' into feat/deprecate-node-app
florian-lefebvre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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': major | ||
| --- | ||
|
|
||
| Deprecates `loadManifest()` and `loadApp()` from `astro/app/node` (Adapter API) - ([v6 upgrade guidance](https://v6.docs.astro.build/en/guides/upgrade-to/v6/#deprecated-loadmanifest-and-loadapp-from-astroappnode-adapter-api)) |
This file contains hidden or 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,21 @@ | ||
| --- | ||
| 'astro': minor | ||
| --- | ||
|
|
||
| Exports new `createRequest()` and `writeResponse()` utilities from `astro/app/node` | ||
|
|
||
| To replace the deprecated `NodeApp.createRequest()` and `NodeApp.writeResponse()` methods, the `astro/app/node` module now exposes new `createRequest()` and `writeResponse()` utilities. These can be used to convert a NodeJS `IncomingMessage` into a web-standard `Request` and stream a web-standard `Response` into a NodeJS `ServerResponse`: | ||
|
|
||
| ```js | ||
| import { createApp } from 'astro/app/entrypoint'; | ||
| import { createRequest, writeResponse } from 'astro/app/node'; | ||
| import { createServer } from 'node:http'; | ||
|
|
||
| const app = createApp(); | ||
|
|
||
| const server = createServer(async (req, res) => { | ||
| const request = createRequest(req); | ||
| const response = await app.render(request); | ||
| await writeResponse(response, res); | ||
| }) | ||
| ``` | ||
This file contains hidden or 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 | ||
| --- | ||
|
|
||
| Fixes the types of `createApp()` exported from `astro/app/entrypoint` |
This file contains hidden or 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': major | ||
| --- | ||
|
|
||
| Deprecates `NodeApp` from `astro/app/node` (Adapter API) - ([v6 upgrade guidance](https://v6.docs.astro.build/en/guides/upgrade-to/v6/#deprecated-nodeapp-from-astroappnode-adapter-api)) |
This file contains hidden or 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,16 +1,17 @@ | ||
| import type { IncomingMessage, ServerResponse } from 'node:http'; | ||
| import type { SSRManifest } from 'astro'; | ||
| import { NodeApp } from 'astro/app/node'; | ||
| import { createApp } from 'astro/app/entrypoint'; | ||
| import { createRequest } from 'astro/app/node'; | ||
|
|
||
| export function createExports(manifest: SSRManifest) { | ||
| const app = new NodeApp(manifest); | ||
| return { | ||
| handler: async (req: IncomingMessage, res: ServerResponse) => { | ||
| const start = performance.now(); | ||
| await app.render(req); | ||
| const end = performance.now(); | ||
| res.write(end - start + ''); | ||
| res.end(); | ||
| }, | ||
| }; | ||
| const app = createApp(); | ||
|
|
||
| export async function handler(req: IncomingMessage, res: ServerResponse): Promise<void> { | ||
| const start = performance.now(); | ||
| await app.render( | ||
| createRequest(req, { | ||
| allowedDomains: app.manifest.allowedDomains, | ||
| }), | ||
| ); | ||
| const end = performance.now(); | ||
| res.write(end - start + ''); | ||
| res.end(); | ||
| } |
This file contains hidden or 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 hidden or 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,13 @@ | ||
| export type { RoutesList } from '../../../types/astro.js'; | ||
| export { App } from '../app.js'; | ||
| export { BaseApp, type RenderErrorOptions, type RenderOptions } from '../base.js'; | ||
| export { fromRoutingStrategy, toRoutingStrategy } from '../common.js'; | ||
| export { createConsoleLogger } from '../logging.js'; | ||
| export { | ||
| deserializeManifest, | ||
| deserializeRouteData, | ||
| deserializeRouteInfo, | ||
| serializeRouteData, | ||
| serializeRouteInfo, | ||
| } from '../manifest.js'; | ||
| export { AppPipeline } from '../pipeline.js'; |
This file contains hidden or 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,8 @@ | ||
| export { | ||
| type SerializedRouteData, | ||
| deserializeManifest, | ||
| deserializeRouteData, | ||
| deserializeRouteInfo, | ||
| serializeRouteData, | ||
| serializeRouteInfo, | ||
| } from '../manifest.js'; |
This file contains hidden or 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 @@ | ||
| export { NodeApp, loadApp, loadManifest, createRequest, writeResponse } from '../node.js'; |
10 changes: 5 additions & 5 deletions
10
...ages/astro/src/core/app/entrypoint/dev.ts → ...o/src/core/app/entrypoints/virtual/dev.ts
This file contains hidden or 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 hidden or 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,4 @@ | ||
| import { createApp as _createApp } from 'virtual:astro:app'; | ||
| import type { BaseApp } from '../../base.js'; | ||
|
|
||
| export const createApp: () => BaseApp = _createApp; |
4 changes: 2 additions & 2 deletions
4
...ges/astro/src/core/app/entrypoint/prod.ts → .../src/core/app/entrypoints/virtual/prod.ts
This file contains hidden or 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.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.