Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@astrojs/node

Package Overview
Dependencies
Maintainers
4
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrojs/node - npm Package Compare versions

Comparing version 0.0.0-rc-20220722032928 to 0.0.0-rc-20220725043302

test/api-route.test.js

31

CHANGELOG.md
# @astrojs/node
## 0.0.0-rc-20220722032928
## 0.0.0-rc-20220725043302
### Minor Changes
- [#3973](https://github.com/withastro/astro/pull/3973) [`5a23483ef`](https://github.com/withastro/astro/commit/5a23483efb3ba614b05a00064f84415620605204) Thanks [@matthewp](https://github.com/matthewp)! - Adds support for Astro.clientAddress
- [#4015](https://github.com/withastro/astro/pull/4015) [`6fd161d76`](https://github.com/withastro/astro/commit/6fd161d7691cbf9d3ffa4646e46059dfd0940010) Thanks [@matthewp](https://github.com/matthewp)! - New `output` configuration option
This change introduces a new "output target" configuration option (`output`). Setting the output target lets you decide the format of your final build, either:
- `"static"` (default): A static site. Your final build will be a collection of static assets (HTML, CSS, JS) that you can deploy to any static site host.
- `"server"`: A dynamic server application. Your final build will be an application that will run in a hosted server environment, generating HTML dynamically for different requests.
If `output` is omitted from your config, the default value `"static"` will be used.
When using the `"server"` output target, you must also include a runtime adapter via the `adapter` configuration. An adapter will _adapt_ your final build to run on the deployed platform of your choice (Netlify, Vercel, Node.js, Deno, etc).
To migrate: No action is required for most users. If you currently define an `adapter`, you will need to also add `output: 'server'` to your config file to make it explicit that you are building a server. Here is an example of what that change would look like for someone deploying to Netlify:
```diff
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
export default defineConfig({
adapter: netlify(),
+ output: 'server',
});
```
* [#3973](https://github.com/withastro/astro/pull/3973) [`5a23483ef`](https://github.com/withastro/astro/commit/5a23483efb3ba614b05a00064f84415620605204) Thanks [@matthewp](https://github.com/matthewp)! - Adds support for Astro.clientAddress
The new `Astro.clientAddress` property allows you to get the IP address of the requested user.

@@ -17,2 +40,6 @@

### Patch Changes
- [#4023](https://github.com/withastro/astro/pull/4023) [`4ca6a0933`](https://github.com/withastro/astro/commit/4ca6a0933d92dd559327dd46a28712d918caebf7) Thanks [@matthewp](https://github.com/matthewp)! - Fixes Node adapter to accept a request body
## 0.1.6

@@ -19,0 +46,0 @@

5

dist/index.js

@@ -12,4 +12,7 @@ function getAdapter() {

hooks: {
"astro:config:done": ({ setAdapter }) => {
"astro:config:done": ({ setAdapter, config }) => {
setAdapter(getAdapter());
if (config.output === "static") {
console.warn(`[@astrojs/Node] \`output: "server"\` is required to use this adapter.`);
}
}

@@ -16,0 +19,0 @@ }

@@ -10,16 +10,23 @@ import { polyfill } from "@astrojs/webapi";

async handler(req, res, next) {
const route = app.match(req);
if (route) {
try {
const response = await app.render(req);
await writeWebResponse(res, response);
} catch (err) {
if (next) {
next(err);
} else {
throw err;
try {
const route = app.match(req);
if (route) {
try {
const response = await app.render(req);
await writeWebResponse(res, response);
} catch (err) {
if (next) {
next(err);
} else {
throw err;
}
}
} else if (next) {
return next();
}
} else if (next) {
return next();
} catch (err) {
if (!res.headersSent) {
res.writeHead(500, `Server error`);
res.end();
}
}

@@ -26,0 +33,0 @@ }

{
"name": "@astrojs/node",
"description": "Deploy your site to a Node.js server",
"version": "0.0.0-rc-20220722032928",
"version": "0.0.0-rc-20220725043302",
"type": "module",

@@ -28,4 +28,5 @@ "types": "./dist/index.d.ts",

"devDependencies": {
"astro": "0.0.0-rc-20220722032928",
"astro-scripts": "0.0.6"
"astro": "0.0.0-rc-20220725043302",
"astro-scripts": "0.0.6",
"node-mocks-http": "^1.11.0"
},

@@ -35,4 +36,5 @@ "scripts": {

"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\""
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "mocha --exit --timeout 20000 test/"
}
}

@@ -40,2 +40,3 @@ # @astrojs/node 🔲

// ...
output: 'server',
adapter: node()

@@ -42,0 +43,0 @@ })

@@ -15,4 +15,8 @@ import type { AstroAdapter, AstroIntegration } from 'astro';

hooks: {
'astro:config:done': ({ setAdapter }) => {
'astro:config:done': ({ setAdapter, config }) => {
setAdapter(getAdapter());
if (config.output === 'static') {
console.warn(`[@astrojs/Node] \`output: "server"\` is required to use this adapter.`);
}
},

@@ -19,0 +23,0 @@ },

@@ -15,17 +15,24 @@ import { polyfill } from '@astrojs/webapi';

async handler(req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) {
const route = app.match(req);
try {
const route = app.match(req);
if (route) {
try {
const response = await app.render(req);
await writeWebResponse(res, response);
} catch (err: unknown) {
if (next) {
next(err);
} else {
throw err;
if (route) {
try {
const response = await app.render(req);
await writeWebResponse(res, response);
} catch (err: unknown) {
if (next) {
next(err);
} else {
throw err;
}
}
} else if (next) {
return next();
}
} else if (next) {
return next();
} catch (err: unknown) {
if (!res.headersSent) {
res.writeHead(500, `Server error`);
res.end();
}
}

@@ -32,0 +39,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc