mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
commit
8bd5a4d5f5
24 changed files with 93 additions and 43 deletions
|
@ -1,5 +1,57 @@
|
|||
# @astrojs/node
|
||||
|
||||
## 6.0.0-rc.1
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#8179](https://github.com/withastro/astro/pull/8179) [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7) Thanks [@matthewp](https://github.com/matthewp)! - Astro 3.0 Release Candidate
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#8176](https://github.com/withastro/astro/pull/8176) [`d08c83ee3`](https://github.com/withastro/astro/commit/d08c83ee3fe0f10374264f61ee473255dcf0cd06) Thanks [@ematipico](https://github.com/ematipico)! - Fix an issue where `express` couldn't use the `handler` in `middleware` mode.
|
||||
|
||||
- Updated dependencies [[`adf9fccfd`](https://github.com/withastro/astro/commit/adf9fccfdda107c2224558f1c2e6a77847ac0a8a), [`582132328`](https://github.com/withastro/astro/commit/5821323285646aee7ff9194a505f708028e4db57), [`81545197a`](https://github.com/withastro/astro/commit/81545197a32fd015d763fc386c8b67e0e08b7393), [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7), [`be6bbd2c8`](https://github.com/withastro/astro/commit/be6bbd2c86b9bf5268e765bb937dda00ff15781a), [`42785c7b7`](https://github.com/withastro/astro/commit/42785c7b784b151e6d582570e5d74482129e8eb8), [`95120efbe`](https://github.com/withastro/astro/commit/95120efbe817163663492181cbeb225849354493), [`2ae9d37f0`](https://github.com/withastro/astro/commit/2ae9d37f0a9cb21ab288d3c30aecb6d84db87788), [`f003e7364`](https://github.com/withastro/astro/commit/f003e7364317cafdb8589913b26b28e928dd07c9), [`732111cdc`](https://github.com/withastro/astro/commit/732111cdce441639db31f40f621df48442d00969), [`33b8910cf`](https://github.com/withastro/astro/commit/33b8910cfdce5713891c50a84a0a8fe926311710), [`e79e3779d`](https://github.com/withastro/astro/commit/e79e3779df0ad35253abcdb931d622847d9adb12), [`179796405`](https://github.com/withastro/astro/commit/179796405e053b559d83f84507e5a465861a029a), [`a87cbe400`](https://github.com/withastro/astro/commit/a87cbe400314341d5f72abf86ea264e6b47c091f), [`767eb6866`](https://github.com/withastro/astro/commit/767eb68666eb777965baa0d6ade20bbafecf95bf)]:
|
||||
- astro@3.0.0-rc.5
|
||||
|
||||
## 6.0.0-beta.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [`1eae2e3f7`](https://github.com/withastro/astro/commit/1eae2e3f7d693c9dfe91c8ccfbe606d32bf2fb81) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
|
||||
|
||||
- [`3dc1ca2fa`](https://github.com/withastro/astro/commit/3dc1ca2fac8d9965cc5085a5d09e72ed87b4281a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Reduced the amount of polyfills provided by Astro. Astro will no longer provide (no-op) polyfills for several web apis such as HTMLElement, Image or Document. If you need access to those APIs on the server, we recommend using more proper polyfills available on npm.
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [`9b4f70a62`](https://github.com/withastro/astro/commit/9b4f70a629f55e461759ba46f68af7097a2e9215) Thanks [@ematipico](https://github.com/ematipico)! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter
|
||||
can tell Astro if it can support it.
|
||||
|
||||
```ts
|
||||
import { AstroIntegration } from './astro';
|
||||
|
||||
function myIntegration(): AstroIntegration {
|
||||
return {
|
||||
name: 'astro-awesome-list',
|
||||
// new feature map
|
||||
supportedAstroFeatures: {
|
||||
hybridOutput: 'experimental',
|
||||
staticOutput: 'stable',
|
||||
serverOutput: 'stable',
|
||||
assets: {
|
||||
supportKind: 'stable',
|
||||
isSharpCompatible: false,
|
||||
isSquooshCompatible: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`1eae2e3f7`](https://github.com/withastro/astro/commit/1eae2e3f7d693c9dfe91c8ccfbe606d32bf2fb81), [`76ddef19c`](https://github.com/withastro/astro/commit/76ddef19ccab6e5f7d3a5740cd41acf10e334b38), [`9b4f70a62`](https://github.com/withastro/astro/commit/9b4f70a629f55e461759ba46f68af7097a2e9215), [`3fdf509b2`](https://github.com/withastro/astro/commit/3fdf509b2731a9b2f972d89291e57cf78d62c769), [`2f951cd40`](https://github.com/withastro/astro/commit/2f951cd403dfcc2c3ca6aae618ae3e1409516e32), [`c022a4217`](https://github.com/withastro/astro/commit/c022a4217a805d223c1494e9eda4e48bbf810388), [`67becaa58`](https://github.com/withastro/astro/commit/67becaa580b8f787df58de66b7008b7098f1209c), [`bc37331d8`](https://github.com/withastro/astro/commit/bc37331d8154e3e95a8df9131e4e014e78a7a9e7), [`dfc2d93e3`](https://github.com/withastro/astro/commit/dfc2d93e3c645995379358fabbdfa9aab99f43d8), [`3dc1ca2fa`](https://github.com/withastro/astro/commit/3dc1ca2fac8d9965cc5085a5d09e72ed87b4281a), [`1be84dfee`](https://github.com/withastro/astro/commit/1be84dfee3ce8e6f5cc624f99aec4e980f6fde37), [`35f01df79`](https://github.com/withastro/astro/commit/35f01df797d23315f2bee2fc3fd795adb0559c58), [`3fdf509b2`](https://github.com/withastro/astro/commit/3fdf509b2731a9b2f972d89291e57cf78d62c769), [`78de801f2`](https://github.com/withastro/astro/commit/78de801f21fd4ca1653950027d953bf08614566b), [`59d6e569f`](https://github.com/withastro/astro/commit/59d6e569f63e175c97e82e94aa7974febfb76f7c), [`7723c4cc9`](https://github.com/withastro/astro/commit/7723c4cc93298c2e6530e55da7afda048f22cf81), [`fb5cd6b56`](https://github.com/withastro/astro/commit/fb5cd6b56dc27a71366ed5e1ab8bfe9b8f96bac5), [`631b9c410`](https://github.com/withastro/astro/commit/631b9c410d5d66fa384674027ba95d69ebb5063f)]:
|
||||
- astro@3.0.0-beta.0
|
||||
|
||||
## 5.3.6
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
@ -161,7 +161,7 @@ For standalone mode the server handles file servering in addition to the page an
|
|||
You can override the host and port the standalone server runs on by passing them as environment variables at runtime:
|
||||
|
||||
```shell
|
||||
HOST=0.0.0.0 PORT=3000 node ./dist/server/entry.mjs
|
||||
HOST=0.0.0.0 PORT=4321 node ./dist/server/entry.mjs
|
||||
```
|
||||
|
||||
#### HTTPS
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@astrojs/node",
|
||||
"description": "Deploy your site to a Node.js server",
|
||||
"version": "5.3.6",
|
||||
"version": "6.0.0-rc.1",
|
||||
"type": "module",
|
||||
"types": "./dist/index.d.ts",
|
||||
"author": "withastro",
|
||||
|
@ -33,24 +33,23 @@
|
|||
"test": "mocha --exit --timeout 20000 test/"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/webapi": "^2.2.0",
|
||||
"send": "^0.18.0",
|
||||
"server-destroy": "^1.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"astro": "workspace:^2.10.14"
|
||||
"astro": "workspace:^3.0.0-rc.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.16.18",
|
||||
"@types/node": "^18.17.8",
|
||||
"@types/send": "^0.17.1",
|
||||
"@types/server-destroy": "^1.0.1",
|
||||
"astro": "workspace:*",
|
||||
"astro-scripts": "workspace:*",
|
||||
"chai": "^4.3.7",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"mocha": "^9.2.2",
|
||||
"express": "^4.18.2",
|
||||
"mocha": "^10.2.0",
|
||||
"node-mocks-http": "^1.13.0",
|
||||
"undici": "^5.22.1",
|
||||
"express": "^4.18.2"
|
||||
"undici": "^5.23.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,16 @@ export function getAdapter(options: Options): AstroAdapter {
|
|||
previewEntrypoint: '@astrojs/node/preview.js',
|
||||
exports: ['handler', 'startServer'],
|
||||
args: options,
|
||||
supportedAstroFeatures: {
|
||||
hybridOutput: 'stable',
|
||||
staticOutput: 'stable',
|
||||
serverOutput: 'stable',
|
||||
assets: {
|
||||
supportKind: 'stable',
|
||||
isSharpCompatible: true,
|
||||
isSquooshCompatible: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import type { ReadableStreamDefaultReadResult } from 'node:stream/web';
|
||||
import { Readable as NodeReadableStream } from 'stream';
|
||||
import type { Response as NodeResponse } from 'undici';
|
||||
|
||||
interface NodeStreamIterator<T> {
|
||||
next(): Promise<IteratorResult<T, boolean | undefined>>;
|
||||
|
@ -35,8 +34,8 @@ function isBuffer(value: any): value is Buffer {
|
|||
);
|
||||
}
|
||||
|
||||
function isNodeResponse(value: any): value is NodeResponse {
|
||||
return !!(value as NodeResponse).body;
|
||||
function isNodeResponse(value: any): value is Response {
|
||||
return !!(value as Response).body;
|
||||
}
|
||||
|
||||
function isReadableStream(value: any): value is ReadableStream<any> {
|
||||
|
@ -121,7 +120,7 @@ function nodeStreamIterator<T>(stream: NodeReadableStream): AsyncIterableIterato
|
|||
| IteratorResult<T, boolean | undefined>
|
||||
| PromiseLike<IteratorResult<T, boolean | undefined>>
|
||||
) => void,
|
||||
(reason?: any) => void
|
||||
(reason?: any) => void,
|
||||
][] = [];
|
||||
|
||||
function onData(chunk: any) {
|
||||
|
@ -201,9 +200,7 @@ function asyncIterator<T>(source: AsyncIterableIterator<T>): AsyncIterableIterat
|
|||
};
|
||||
}
|
||||
|
||||
export function responseIterator<T>(
|
||||
response: Response | NodeResponse | Buffer
|
||||
): AsyncIterableIterator<T> {
|
||||
export function responseIterator<T>(response: Response | Buffer): AsyncIterableIterator<T> {
|
||||
let body: unknown = response;
|
||||
|
||||
if (isNodeResponse(response)) body = response.body;
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import { polyfill } from '@astrojs/webapi';
|
||||
import type { SSRManifest } from 'astro';
|
||||
import { NodeApp } from 'astro/app/node';
|
||||
import { NodeApp, applyPolyfills } from 'astro/app/node';
|
||||
import middleware from './nodeMiddleware.js';
|
||||
import startServer from './standalone.js';
|
||||
import type { Options } from './types';
|
||||
|
||||
polyfill(globalThis, {
|
||||
exclude: 'window document',
|
||||
});
|
||||
|
||||
applyPolyfills();
|
||||
export function createExports(manifest: SSRManifest, options: Options) {
|
||||
const app = new NodeApp(manifest);
|
||||
return {
|
||||
|
|
|
@ -21,7 +21,7 @@ export type RequestHandlerParams = [
|
|||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
next?: (err?: unknown) => void,
|
||||
locals?: object
|
||||
locals?: object,
|
||||
];
|
||||
|
||||
export type ErrorHandlerParams = [unknown, ...RequestHandlerParams];
|
||||
|
|
|
@ -41,6 +41,6 @@ describe('API routes', () => {
|
|||
}
|
||||
const stillWork = await fixture.fetch('/');
|
||||
const text = await stillWork.text();
|
||||
expect(text).to.equal('<!DOCTYPE html>\nHello!');
|
||||
expect(text).to.equal('<!DOCTYPE html>Hello!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
export async function post({ request }: { request: Request }) {
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
let body = await request.arrayBuffer();
|
||||
let data = new Uint8Array(body);
|
||||
let r = data.reverse();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
export async function post({ request }) {
|
||||
export async function POST({ request }) {
|
||||
let body = await request.json();
|
||||
const recipes = [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function get({ request, cookies }: APIContext) {
|
||||
export async function GET({ request, cookies }: APIContext) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
cookies.set('from1', 'astro1');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function get({ request, cookies }: APIContext) {
|
||||
export async function GET({ request, cookies }: APIContext) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
cookies.set('from1', 'astro1');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function get({ request, cookies }: APIContext) {
|
||||
export async function GET({ request, cookies }: APIContext) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('set-cookie', 'from1=response1');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function get({ request, cookies }: APIContext) {
|
||||
export async function GET({ request, cookies }: APIContext) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('set-cookie', 'from1=response1');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('x-SINGLE', 'single');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('Set-Cookie', 'hello1=world1');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('Set-Cookie', 'hello1=world1');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
const headers = new Headers();
|
||||
return new Response('hello world', { headers });
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
return new Response('hello world', { headers: undefined });
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export async function get({ request }: { request: Request }) {
|
||||
export async function GET({ request }: { request: Request }) {
|
||||
const headers = new Headers();
|
||||
headers.append('content-type', 'text/plain;charset=utf-8');
|
||||
headers.append('X-HELLO', 'world');
|
||||
|
|
|
@ -2,7 +2,8 @@ import { expect } from 'chai';
|
|||
import nodejs from '../dist/index.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('Image endpoint', () => {
|
||||
// Temporary skip until we figure out the "Could not find Sharp" issue as `sharp` is bundled
|
||||
describe.skip('Image endpoint', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let devPreview;
|
||||
|
@ -12,9 +13,6 @@ describe('Image endpoint', () => {
|
|||
root: './fixtures/image/',
|
||||
output: 'server',
|
||||
adapter: nodejs({ mode: 'standalone' }),
|
||||
experimental: {
|
||||
assets: true,
|
||||
},
|
||||
});
|
||||
await fixture.build();
|
||||
devPreview = await fixture.preview();
|
||||
|
|
|
@ -2,7 +2,6 @@ import nodejs from '../dist/index.js';
|
|||
import { loadFixture } from './test-utils.js';
|
||||
import { expect } from 'chai';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { fetch } from 'undici';
|
||||
|
||||
/**
|
||||
* @typedef {import('../../../astro/test/test-utils').Fixture} Fixture
|
||||
|
@ -102,7 +101,7 @@ describe('Prerender 404', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// length will be 0 if the stylesheet does not get included
|
||||
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);
|
||||
expect($('style[type="text/css"]')).to.have.a.lengthOf(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import nodejs from '../dist/index.js';
|
|||
import { loadFixture } from './test-utils.js';
|
||||
import { expect } from 'chai';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { fetch } from 'undici';
|
||||
|
||||
/**
|
||||
* @typedef {import('../../../astro/test/test-utils').Fixture} Fixture
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"allowJs": true,
|
||||
"module": "ES2022",
|
||||
"outDir": "./dist",
|
||||
"target": "ES2021"
|
||||
"target": "ES2022"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue