Set up Deno apps in the AppHost
Это содержимое пока не доступно на вашем языке.
This reference covers the Deno AppHost API from the Aspire Community Toolkit. For an introduction, see Get started with the Deno integration.
Installation
Section titled “Installation”Install the hosting package in your AppHost:
aspire add communitytoolkit-denoAspire CLI интерактивен; выберите подходящий результат поиска при запросе:
Select an integration to add:
> communitytoolkit-deno (CommunityToolkit.Aspire.Hosting.Deno)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.Deno@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.Deno" Version="*" />The Deno executable must be available on PATH when Aspire runs the resource.
Add a Deno script
Section titled “Add a Deno script”AddDenoApp / addDenoApp creates an executable resource that runs deno run, followed by permission flags, the script path, and application arguments.
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp( name: "deno-api", scriptPath: "main.ts", workingDirectory: "../deno-api", permissionFlags: ["--allow-env", "--allow-net"], args: ["--verbose"]);
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const api = await builder.addDenoApp( 'deno-api', 'main.ts', '../deno-api', ['--allow-env', '--allow-net'], ['--verbose']);
await builder.build().run();name identifies the dashboard resource. scriptPath is passed to deno run. workingDirectory is resolved from the AppHost directory; when omitted, it defaults to ../<name>. permissionFlags and args are optional arrays. Use Deno permission flags appropriate to the application, such as --allow-net for network access and --allow-env when it reads environment variables.
Script resources set DENO_ENV to development in the development environment and production otherwise. They also configure the OTLP exporter.
Add a Deno task
Section titled “Add a Deno task”AddDenoTask / addDenoTask runs deno task <taskName>, using the task configuration in the resource’s working directory.
var builder = DistributedApplication.CreateBuilder(args);
var web = builder.AddDenoTask( name: "web", workingDirectory: "../web", taskName: "dev", args: ["--host", "0.0.0.0"]);
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const web = await builder.addDenoTask('web', '../web', 'dev', [ '--host', '0.0.0.0',]);
await builder.build().run();taskName defaults to start; the working-directory default is also ../<name>. Task resources run the deno command with task, the task name, and the supplied arguments.
Install Deno packages before startup
Section titled “Install Deno packages before startup”WithDenoPackageInstallation / withDenoPackageInstallation adds a deno install setup resource named <resource-name>-deno-install. The application waits for that setup resource to complete.
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp("deno-api", "main.ts") .WithDenoPackageInstallation();
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const api = await builder .addDenoApp('deno-api', 'main.ts') .withDenoPackageInstallation();
await builder.build().run();In C#, an overload also accepts a callback that configures the installer resource. It is marked [AspireExportIgnore] because Action<IResourceBuilder<DenoInstallerResource>> is not ATS-compatible; TypeScript uses the exported overload without configureInstaller.
Configure endpoints, environment, and health checks
Section titled “Configure endpoints, environment, and health checks”Deno resources are executable resources with endpoint, environment, argument, wait, and service-discovery support. Use the standard AppHost APIs to pass a listening port, configure additional environment variables, and define a probe:
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp( "deno-api", "main.ts", permissionFlags: ["--allow-env", "--allow-net"]) .WithHttpEndpoint(port: 8000, env: "PORT") .WithEnvironment("LOG_LEVEL", "debug") .WithHttpHealthCheck("/health");
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const api = await builder .addDenoApp('deno-api', 'main.ts', undefined, ['--allow-env', '--allow-net']) .withHttpEndpoint({ port: 8000, env: 'PORT' }) .withEnvironment('LOG_LEVEL', 'debug') .withHttpHealthCheck({ path: '/health' });
await builder.build().run();The application must read the PORT variable and listen on that port. It must also have the Deno permissions required to read its environment and serve network traffic. WithHttpHealthCheck / withHttpHealthCheck makes Aspire poll the specified HTTP path. Add WithEndpoint / withEndpoint when you need an additional endpoint definition, as in the Toolkit Deno samples.
Resource actions and references
Section titled “Resource actions and references”The dashboard exposes the normal executable-resource lifecycle controls for Deno resources. Other AppHost resources can use WithReference / withReference and dependency APIs with a Deno resource because it supports service discovery. Add explicit endpoints before consumers need an address.
Publishing behavior
Section titled “Publishing behavior”WithDenoPackageInstallation only creates its installer resource in run mode. The installer is excluded from the application manifest and is not created during publishing. The integration does not implement a Deno-specific container build or publish artifact; provide deployment packaging appropriate for your Deno application.
For deployment guidance, see the Aspire deployment overview.