# encore.dev


## Interfaces

<!-- symbol-start: APICallMeta -->
### APICallMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L33" />

Describes an API call being processed.

#### Properties

##### api

`api: APIDesc`

Describes the API Endpoint being called.

##### headers

`headers: Record<string, string | string[]>`

The request headers from the HTTP request.
The values are arrays if the header contains multiple values,
either separated by ";" or when the header key appears more than once.

##### method

`method: Method`

The HTTP method used in the API call.

##### middlewareData?

`optional middlewareData?: Record<string, any>`

Contains values set in middlewares via `MiddlewareRequest.data`.

##### parsedPayload?

`optional parsedPayload?: Record<string, any>`

The parsed request payload, as expected by the application code.
Not provided for raw endpoints or when the API endpoint expects no
request data.

##### path

`path: string`

The request URL path used in the API call,
excluding any query string parameters.
For example "/path/to/endpoint".

##### pathAndQuery

`pathAndQuery: string`

The request URL path used in the API call,
including any query string parameters.
For example "/path/to/endpoint?with=querystring".

##### pathParams

`pathParams: Record<string, any>`

The parsed path parameters for the API endpoint.
The keys are the names of the path parameters,
from the API definition.

For example {id: 5}.

##### type

`type: "api-call"`

Specifies that the request is an API call.

***

<!-- symbol-end -->

<!-- symbol-start: APIDesc -->
### APIDesc <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L4" />

Describes an API endpoint.

#### Properties

##### auth

`auth: boolean`

Whether the endpoint requires auth.

##### endpoint

`endpoint: string`

The name of the endpoint itself.

##### raw

`raw: boolean`

Whether the endpoint is a raw endpoint.

##### service

`service: string`

The name of the service that the endpoint belongs to.

##### tags

`tags: string[]`

Tags specified on the endpoint.

***

<!-- symbol-end -->

<!-- symbol-start: AppMeta -->
### AppMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L4" />

Describes the running Encore application.

#### Properties

##### apiBaseUrl

`apiBaseUrl: 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.

##### appId

`appId: string`

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.

##### build

`build: BuildMeta`

Information about the build.

##### deploy

`deploy: DeployMeta`

Information about the deployment.

##### environment

`environment: EnvironmentMeta`

Information about the environment the app is running in.

***

<!-- symbol-end -->

<!-- symbol-start: BaseRequestMeta -->
### BaseRequestMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L145" />

Common fields shared by all request meta types.

#### Properties

##### trace?

`optional trace?: TraceData`

Information about the trace, if the request is being traced

***

<!-- symbol-end -->

<!-- symbol-start: BuildMeta -->
### BuildMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L72" />

Information about the build that formed the running application.

#### Properties

##### revision

`revision: string`

The git commit that formed the base of this build.

##### uncommittedChanges

`uncommittedChanges: boolean`

Whether there were uncommitted changes on top of the commit.

***

<!-- symbol-end -->

<!-- symbol-start: DeployMeta -->
### DeployMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L81" />

Information about the deployment of the running application.

#### Properties

##### hostedServices

`hostedServices: Record<string, HostedService>`

The services hosted by this deployment, keyed by the service name.

##### id

`id: string`

The unique id of the deployment. Generated by the Encore Platform.

***

<!-- symbol-end -->

<!-- symbol-start: EnvironmentMeta -->
### EnvironmentMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L32" />

Describes the environment the Encore application is running in.

#### Properties

##### cloud

`cloud: CloudProvider`

The cloud this is running in.
For local development it is "local".

##### name

`name: string`

The name of environment that this application.
For local development it is "local".

##### type

`type: EnvironmentType`

The type of environment is this application running in.
For local development it is "development".

***

<!-- symbol-end -->

<!-- symbol-start: HostedService -->
### HostedService <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L89" />

#### Properties

##### name

`name: string`

The name of the service

***

<!-- symbol-end -->

<!-- symbol-start: PubSubMessageMeta -->
### PubSubMessageMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L87" />

Describes a Pub/Sub message being processed.

#### Properties

##### deliveryAttempt

`deliveryAttempt: number`

The delivery attempt. The first attempt starts at 1,
and increases by 1 for each retry.

##### messageId

`messageId: string`

The unique id of the Pub/Sub message.
It is the same id returned by `topic.publish()`.
The message id stays the same across delivery attempts.

##### parsedPayload?

`optional parsedPayload?: Record<string, any>`

The parsed request payload, as expected by the application code.

##### service

`service: string`

The service processing the message.

##### subscription

`subscription: string`

The name of the Pub/Sub subscription.

##### topic

`topic: string`

The name of the Pub/Sub topic.

##### type

`type: "pubsub-message"`

Specifies that the request is a Pub/Sub message.

***

<!-- symbol-end -->

<!-- symbol-start: TraceData -->
### TraceData <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L120" />

Provides information about the active trace.

#### Properties

##### extCorrelationId?

`optional extCorrelationId?: string`

The external correlation id provided when the trace
was created, if any.
For example via the `Request-Id` or `X-Correlation-Id` headers.

##### parentSpanId?

`optional parentSpanId?: string`

The span that initiated this span, if any.

##### parentTraceId?

`optional parentTraceId?: string`

The trace id that initiated this trace, if any.

##### spanId

`spanId: string`

The current span id.

##### traceId

`traceId: string`

The trace id.

<!-- symbol-end -->

## Type Aliases

<!-- symbol-start: CloudProvider -->
### CloudProvider <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L64" />

`type CloudProvider = "aws" | "gcp" | "azure" | "encore" | "local"`

Describes what cloud provider the application is running in.

***

<!-- symbol-end -->

<!-- symbol-start: EnvironmentType -->
### EnvironmentType <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L53" />

`type EnvironmentType = "production" | "development" | "ephemeral" | "test"`

Describes what type of environment the application is running in.

***

<!-- symbol-end -->

<!-- symbol-start: Method -->
### Method <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L21" />

```ts
type Method = 
  | "GET"
  | "POST"
  | "PUT"
  | "PATCH"
  | "DELETE"
  | "HEAD"
  | "OPTIONS"
  | "CONNECT"
  | "TRACE";
```

***

<!-- symbol-end -->

<!-- symbol-start: RequestMeta -->
### RequestMeta <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L151" />

`type RequestMeta = APICallMeta | PubSubMessageMeta & BaseRequestMeta`

Describes an API call or Pub/Sub message being processed.

<!-- symbol-end -->

## Functions

<!-- symbol-start: appMeta() -->
### appMeta() <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/app_meta.ts#L100" />

`function appMeta(): AppMeta`

Returns metadata about the running Encore application.

The metadata is cached and is the same object each call,
and therefore must not be modified by the caller.

#### Returns

[`AppMeta`](#appmeta)

***

<!-- symbol-end -->

<!-- symbol-start: currentRequest() -->
### currentRequest() <SymbolSource href="https://github.com/encoredev/encore/blob/main/runtimes/js/encore.dev/req_meta.ts#L160" />

`function currentRequest(): RequestMeta | undefined`

Returns information about the running Encore request,
such as API calls and Pub/Sub messages being processed.

Returns undefined only if no request is being processed,
such as during system initialization.

#### Returns

[`RequestMeta`](#requestmeta) \| `undefined`


<!-- symbol-end -->
