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

@astrojs/deno

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrojs/deno - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

49

CHANGELOG.md
# @astrojs/node
## 1.1.0
### Minor Changes
- [#4876](https://github.com/withastro/astro/pull/4876) [`d3091f89e`](https://github.com/withastro/astro/commit/d3091f89e92fcfe1ad48daca74055d54b1c853a3) Thanks [@matthewp](https://github.com/matthewp)! - Adds the Astro.cookies API
`Astro.cookies` is a new API for manipulating cookies in Astro components and API routes.
In Astro components, the new `Astro.cookies` object is a map-like object that allows you to get, set, delete, and check for a cookie's existence (`has`):
```astro
---
type Prefs = {
darkMode: boolean;
};
Astro.cookies.set<Prefs>(
'prefs',
{ darkMode: true },
{
expires: '1 month',
}
);
const prefs = Astro.cookies.get<Prefs>('prefs').json();
---
<body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>
```
Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.
This API is also available with the same functionality in API routes:
```js
export function post({ cookies }) {
cookies.set('loggedIn', false);
return new Response(null, {
status: 302,
headers: {
Location: '/login',
},
});
}
```
See [the RFC](https://github.com/withastro/rfcs/blob/main/proposals/0025-cookie-management.md) to learn more.
## 1.0.1

@@ -4,0 +53,0 @@

16

dist/server.js

@@ -17,3 +17,9 @@ import { App } from "astro/app";

Reflect.set(request, Symbol.for("astro.clientAddress"), ip);
return await app.render(request);
const response = await app.render(request);
if (app.setCookieHeaders) {
for (const setCookieHeader of app.setCookieHeaders(response)) {
response.headers.append("Set-Cookie", setCookieHeader);
}
}
return response;
}

@@ -24,3 +30,9 @@ const url = new URL(request.url);

if (fileResp.status == 404) {
return await app.render(request);
const response = await app.render(request);
if (app.setCookieHeaders) {
for (const setCookieHeader of app.setCookieHeaders(response)) {
response.headers.append("Set-Cookie", setCookieHeader);
}
}
return response;
} else {

@@ -27,0 +39,0 @@ return fileResp;

6

package.json
{
"name": "@astrojs/deno",
"description": "Deploy your site to a Deno server",
"version": "1.0.1",
"version": "1.1.0",
"type": "module",

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

"devDependencies": {
"astro": "1.1.3",
"astro-scripts": "0.0.7"
"astro": "1.4.0",
"astro-scripts": "0.0.8"
},

@@ -33,0 +33,0 @@ "scripts": {

@@ -5,2 +5,4 @@ # @astrojs/deno 🦖

Learn how to deploy your Astro site in our [Deno Deploy deployment guide](https://docs.astro.build/en/guides/deploy/deno/).
- <strong>[Why Astro Deno](#why-astro-deno)</strong>

@@ -25,22 +27,55 @@ - <strong>[Installation](#installation)</strong>

First, install the `@astrojs/deno` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
Add the Deno adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
```sh
npm install @astrojs/deno
# Using NPM
npx astro add deno
# Using Yarn
yarn astro add deno
# Using PNPM
pnpm astro add deno
```
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
If you prefer to install the adapter manually instead, complete the following two steps:
__`astro.config.mjs`__
1. Install the Deno adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
```js
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
```bash
npm install @astrojs/deno
```
export default defineConfig({
// ...
output: 'server',
adapter: deno()
});
```
1. Update your `astro.config.mjs` project configuration file with the changes below.
```js ins={3,6-7}
// astro.config.mjs
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
export default defineConfig({
output: 'server',
adapter: deno(),
});
```
Next, Update your `preview` script in `package.json` with the change below.
```json del={8} ins={9}
// package.json
{
// ...
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview"
"preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs"
}
}
```
You can now use this command to preview your production Astro site locally with Deno.
```bash
npm run preview
```

@@ -134,3 +169,3 @@ ## Usage

For help, check out the `#support-threads` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!

@@ -137,0 +172,0 @@ You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.

@@ -29,3 +29,9 @@ // Normal Imports

Reflect.set(request, Symbol.for('astro.clientAddress'), ip);
return await app.render(request);
const response = await app.render(request);
if (app.setCookieHeaders) {
for (const setCookieHeader of app.setCookieHeaders(response)) {
response.headers.append('Set-Cookie', setCookieHeader);
}
}
return response;
}

@@ -42,4 +48,11 @@

// Render the astro custom 404 page
return await app.render(request);
const response = await app.render(request);
if (app.setCookieHeaders) {
for (const setCookieHeader of app.setCookieHeaders(response)) {
response.headers.append('Set-Cookie', setCookieHeader);
}
}
return response;
// If the static file is found

@@ -46,0 +59,0 @@ } else {

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