Skip to content

TypeScript Metadata API

Latest
Compare
Choose a tag to compare
@marcuskohlberg marcuskohlberg released this 12 Apr 14:58
· 51 commits to main since this release

We're excited to announce Encore v1.35, with several improvements to Encore for TypeScript!

Discord

We've also just moved the Encore Community to Discord. This gives us several key features that we believe will make the community more engaging and helpful for all members:

  • This will give us several key features that we believe will make the community more engaging and helpful for all members:
  • Unlimited message history, so we never lose valuable chats.
  • Improved Q&A using built-in forums, making it faster and easier to find answers and share knowledge.
  • Dedicated boards for submitting and voting on suggestions — we love hearing your ideas and want to get better at tracking them.
  • The ability to schedule and host live streamed community events.

Hope to see you there!

TypeScript Metadata API

We've added a new API for querying metadata about the application's running environment. It looks like this:

import { appMeta } from "encore.dev";

const meta = appMeta();

The metadata object contains tons of information about the application and where it's running:

// Describes the running Encore application.
export interface AppMeta {
  // The Encore application ID. If the application is not linked to the Encore platform this will be an empty string.
  // To link to the Encore platform run `encore app link` from your terminal in the root directory of the Encore app.
  appID: string;

  // The base URL which can be used to call the API of this running application.
  //
  // For local development it is "http://localhost:<port>", typically "http://localhost:4000".
  //
  // If a custom domain is used for this environment it is returned here, but note that
  // changes only take effect at the time of deployment while custom domains can be updated at any time.
  apiBaseURL: string;

  // Information about the environment the app is running in.
  environment: EnvironmentMeta;

  // Information about the build.
  build: BuildMeta;

  // Information about the deployment.
  deploy: DeployMeta;
}

// Describes the environment the Encore application is running in.
export interface EnvironmentMeta {
  // The name of environment that this application.
  // For local development it is "local".
  name: string;

  // The type of environment is this application running in.
  // For local development it is "development".
  type: EnvironmentType;

  // The cloud this is running in.
  // For local development it is "local".
  cloud: CloudProvider;
}

// Describes what type of environment the application is running in.
export type EnvironmentType =
  // A production environment.
  | "production"
  // A long-lived cloud-hosted, non-production environment, such as test environments, or local development.
  | "development"
  // A short-lived cloud-hosted, non-production environments, such as preview environments
  | "ephemeral"
  // When running automated tests.
  | "test";

// Describes what cloud provider the application is running in.
export type CloudProvider =
  | "aws" // Amazon Web Services
  | "gcp" // Google Cloud Platform
  | "azure" // Microsoft Azure
  | "encore" // Encore Cloud.
  | "local"; // Local development

// Information about the build that formed the running application.
export interface BuildMeta {
  // The git commit that formed the base of this build.
  revision: string;

  // Whether there were uncommitted changes on top of the commit.
  uncommittedChanges: boolean;
}

// Information about the deployment of the running application.
export interface DeployMeta {
  // The unique id of the deployment. Generated by the Encore Platform.
  id: string;
}

Client Generation improvements

The encore gen client command now accepts --excluded-services=foo,bar to exclude specific services from the generated client.

Various TypeScript Improvements

We're also making rapid improvements to all aspects of Encore for TypeScript:

  • Pub/Sub: Added support for AWS Pub/Sub (SQS + SNS)
  • Pub/Sub: Implemented support for maxConcurrency across local development, GCP, and AWS
  • API: Added trailing slash redirect handling

Full Changelog: v1.34.7...v1.35.3