Get started with Deno and Aspire
Questi contenuti non sono ancora disponibili nella tua lingua.
The Aspire Community Toolkit Deno hosting integration adds Deno scripts and tasks to your AppHost. Aspire starts the Deno process locally, shows it in the dashboard, and lets you connect it to the rest of your distributed application.
How the integration works
Section titled “How the integration works”The integration is a hosting integration: install it in the AppHost, then model each application with an AddDenoApp / addDenoApp resource or an AddDenoTask / addDenoTask resource. The resource runs the local deno command. You configure its working directory, permissions, arguments, endpoints, environment variables, and health checks in the AppHost.
AddDenoApp runs a script with deno run; AddDenoTask runs a task from deno.json or deno.jsonc with deno task. Both resource types participate in service discovery and can be referenced by other resources.
Prerequisites
Section titled “Prerequisites”- Install Deno and ensure
denois available on yourPATH. - Install the Aspire CLI and meet the Aspire prerequisites.
- Create an AppHost in C# or TypeScript.
Add a Deno resource
Section titled “Add a Deno resource”Add CommunityToolkit.Aspire.Hosting.Deno to your AppHost. Then add a Deno task or script resource:
var builder = DistributedApplication.CreateBuilder(args);
var app = builder.AddDenoTask( name: "web", workingDirectory: "../web", taskName: "dev") .WithHttpEndpoint(env: "PORT") .WithHttpHealthCheck("/");
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const app = await builder .addDenoTask('web', '../web', 'dev') .withHttpEndpoint({ env: 'PORT' }) .withHttpHealthCheck({ path: '/' });
await builder.build().run();Have the Deno application listen on the endpoint environment variable. For example, grant the --allow-env permission when an application reads PORT.
Set up Deno apps in the AppHost