microsoft / microsoft/aspire.dev
Docs: TypeScript AppHost DOES expose withEndpointsInEnvironment (project-resources page says it does not)
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 193
- Forks
- 87
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 73
Description
Page
integrations/dotnet/project-resources → "Filter endpoints in environment variables"
Source: project-resources.mdx
Problem
The TypeScript tab of the "Filter endpoints in environment variables" section states:
"The TypeScript AppHost doesn't currently expose
WithEndpointsInEnvironment. To exclude an endpoint from environment variable injection, define only the endpoints you need and omit theadminendpoint from the project resource."
But the TypeScript AppHost does expose it. There is a dedicated ATS-friendly overload marked [AspireExport] — src/Aspire.Hosting/Ats/CoreExports.cs:
[AspireExport]
public static IResourceBuilder<ProjectResource> WithEndpointsInEnvironment(
this IResourceBuilder<ProjectResource> resource,
string[] endpointNames)
The predicate overload WithEndpointsInEnvironment(Func<EndpointAnnotation, bool> filter) is [AspireExportIgnore] because Func<> isn't ATS-compatible, and its comment explicitly points to the array-based export as "the ATS-friendly implementation."
It appears in the generated TypeScript surface — src/Aspire.Hosting/api/Aspire.Hosting.ats.txt:
Aspire.Hosting/withEndpointsInEnvironment(endpointNames: string[]) -> Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource
and the repository's own polyglot TypeScript AppHost uses it — tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts:
await project.withEndpointsInEnvironment(["https"]);
Note on semantics
The exported TypeScript overload takes an allow-list of endpoint names to include (string[]), which is the inverse of the C# predicate example on the page (which excludes endpoints by returning false). So the correct TypeScript guidance to keep admin out of the environment is to list the endpoints you want to keep:
await builder.addProject("apiservice", "../Networking.ApiService/Networking.ApiService.csproj")
.withHttpsEndpoint()
.withHttpsEndpoint({ port: 19227, name: "admin" })
.withEndpointsInEnvironment(["https"]); // include only "https"; "admin" is excluded
Suggested fix
Replace the "doesn't currently expose WithEndpointsInEnvironment" note in the TypeScript tab with the withEndpointsInEnvironment(endpointNames) allow-list form and an example, noting the include-vs-exclude semantic difference from the C# predicate overload.
Provenance
aspire.dev release/13.5 (project-resources.mdx); aspire release/13.5 (CoreExports.cs, Aspire.Hosting.ats.txt, PolyglotAppHosts TypeScript AppHost). Confirmed working live against the 13.5 candidate CLI 13.5.0-pr.17553.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open src/frontend/src/content/docs/integrations/dotnet/project-resources.mdx and locate the TypeScript tab under “Filter endpoints in environment variables.” Compare the existing guidance with src/Aspire.Hosting/Ats/CoreExports.cs and tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts. Done means the tab documents the allow-list form, includes the shown endpoint example, and explains its difference from the C# predicate overload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100