Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
astro-auto-adapter
Advanced tools
Let's you choose between Astro Adapters based off of the `ASTRO_ADAPTER_MODE` environment variable.
Let's you choose Astro Adapters based off of the ASTRO_ADAPTER_MODE
environment variable.
Supported Adapters:
What's New? 🚀
astro-auto-adapter
is now even smarter! Previously, you had to manually set theASTRO_ADAPTER_MODE
environment variable to choose the right Astro adapter for your project. Now, we've added some magic to automatically detect the deployment environment you're using.For example, if you're deploying on
Vercel Serverless
, theVERCEL
environment variable is set to1
, and we'll automatically choose theVercel serverless
adapter for you. Neat, right?Dive into the docs to see the magic behind each adapter platform:
Heads Up: Some adapters require additional configuration. Don't worry; we've got detailed examples below to guide you through it.
npm install astro-auto-adapter
yarn add astro-auto-adapter
or
pnpm install astro-auto-adapter
First, import the necessary types and the adapter
function from the package:
import { adapter, type IAdapterOptions } from "astro-auto-adapter";
Next, call the adapter()
function with the desired adapter type and options:
const astroAdapter = await adapter("netlify", {
netlify: {
dist: new URL("path/to/dist", import.meta.url),
},
});
Here is an overview of the available adapter options:
VercelAdapterOptions
Configuration options for the Vercel serverless adapter.
import type { VercelAdapterOptions } from "astro-auto-adapter";
VercelEdgeAdapterOptions
Configuration options for the Vercel edge adapter.
import type { VercelEdgeAdapterOptions } from "astro-auto-adapter";
NodeAdapterOptions
Configuration options for the Node adapter.
import type { NodeAdapterOptions } from "astro-auto-adapter";
CloudflareAdapterOptions
Configuration options for the Cloudflare adapter.
import type { CloudflareAdapterOptions } from "astro-auto-adapter";
DenoAdapterOptions
Configuration options for the Deno adapter.
import type { DenoAdapterOptions } from "astro-auto-adapter";
NetlifyAdapterOptions
Configuration options for the Netlify adapter.
import type { NetlifyAdapterOptions } from "astro-auto-adapter";
NetlifyEdgeAdapterOptions
Configuration options for the Netlify edge adapter.
import type { NetlifyEdgeAdapterOptions } from "astro-auto-adapter";
You can use the ASTRO_ADAPTER_MODE
environment variable to set the adapter type instead of providing it directly to the adapter()
function. If the environment variable is not set, the function defaults to the "node" adapter.
export ASTRO_ADAPTER_MODE="netlify"
The package also includes a default export that can be used as a shorthand for calling the adapter()
function.
import adapter from "astro-auto-adapter";
const astroAdapter = await adapter("netlify", {
netlify: {
dist: new URL("path/to/dist", import.meta.url),
},
});
Here are some examples of how to use the package with various adapter types and configurations:
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').CloudflareAdapterOptions} */
const options = {
mode: "directory",
};
const astroAdapter = await adapter("cloudflare", { cloudflare: options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').DenoAdapterOptions} */
const options = {
port: 3000,
hostname: "localhost",
};
const astroAdapter = await adapter("deno", { deno: options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').NetlifyAdapterOptions} */
const options = {
dist: new URL("path/to/dist", import.meta.url),
builders: true,
binaryMediaTypes: ["application/octet-stream"],
};
const astroAdapter = await adapter("netlify", { netlify: options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').NetlifyEdgeAdapterOptions} */
const options = {
dist: new URL("path/to/dist", import.meta.url),
};
const astroAdapter = await adapter("netlify-edge", { "netlify-edge": options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').VercelAdapterOptions} */
const options = {
// Configuration options go here
};
const astroAdapter = await adapter("vercel", { vercel: options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').VercelEdgeAdapterOptions} */
const options = {
// Configuration options go here
};
const astroAdapter = await adapter("vercel-edge", { "vercel-edge": options });
import { adapter } from "astro-auto-adapter";
/** @type {import('astro-auto-adapter').NodeAdapterOptions} */
const options = {
// Configuration options go here
};
const astroAdapter = await adapter("node", { node: options });
A couple sites/projects that use astro-auto-adapter
:
I encourage you to use pnpm to contribute to this repo, but you can also use yarn or npm if you prefer.
Install all necessary packages
npm install
Then run tests
npm test
Build project
npm run build
Note: This project uses Conventional Commits standard for commits, so, please format your commits using the rules it sets out.
See the LICENSE file for license rights and limitations (MIT).
1.0.0 (2023-08-25)
fix jsdoc comment (1bbf16b)
fix type issues w/ astro-auto-adapter (eb36825)
feat!: use adapter system env vars (a84fb02)
astro-auto-adapter
now returns a promise which then returns the AstroIntegration
e.g.export default defineConfig({
output: "server",
- adapter: adapter(),
+ adapter: await adapter(),
srcDir: "./example"
});
FAQs
Let's you choose between Astro Adapters based off of the `ASTRO_ADAPTER_MODE` environment variable.
The npm package astro-auto-adapter receives a total of 33 weekly downloads. As such, astro-auto-adapter popularity was classified as not popular.
We found that astro-auto-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.