# @lifeomic/alpha

> Unified client for HTTP services.

Latest version **7.1.0** (published 2026-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lifeomic/alpha
pnpm add @lifeomic/alpha
yarn add @lifeomic/alpha
bun add @lifeomic/alpha
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.1.0 |
| Published | 2026-06-05 |
| First published | 2017-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 14 |
| Unpacked size | 150.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 19 |
| Author | LifeOmic |
| Maintainers | lifeomicdev, npm-lifeomicdev-github, joshmyers, hallsamuel90 |

## Links

- npm: https://www.npmjs.com/package/@lifeomic/alpha
- Repository: https://github.com/lifeomic/alpha
- Homepage: https://github.com/lifeomic/alpha#readme
- Issues: https://github.com/lifeomic/alpha/issues
- npm.io page: https://npm.io/package/@lifeomic/alpha

## Dependencies (14)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [axios](https://npm.io/package/axios.md) ^1.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [nearley](https://npm.io/package/nearley.md) 2
- [url-parse](https://npm.io/package/url-parse.md) ^1.5.10
- [@types/aws-lambda](https://npm.io/package/@types/aws-lambda.md) ^8.10.101
- [aws-xray-sdk-core](https://npm.io/package/aws-xray-sdk-core.md) ^3.12.0
- [@aws-sdk/url-parser](https://npm.io/package/@aws-sdk/url-parser.md) ^3.357.0
- [@aws-sdk/signature-v4](https://npm.io/package/@aws-sdk/signature-v4.md) ^3.110.0
- [@aws-sdk/client-lambda](https://npm.io/package/@aws-sdk/client-lambda.md) ^3.118.1
- [@aws-sdk/abort-controller](https://npm.io/package/@aws-sdk/abort-controller.md) ^3.110.0
- [@aws-crypto/sha256-browser](https://npm.io/package/@aws-crypto/sha256-browser.md) ^2.0.1
- [@aws-sdk/node-http-handler](https://npm.io/package/@aws-sdk/node-http-handler.md) ^3.118.1
- [@aws-sdk/credential-provider-node](https://npm.io/package/@aws-sdk/credential-provider-node.md) ^3.121.0

## Recent versions

- 7.1.0 (latest) — 2026-06-05
- 5.3.0-alpha.1 (alpha) — 2024-02-26
- 2.0.2-pr-120-1773212537-1643641031.0 (pr-120) — 2022-01-31
- 2.0.3-pr-119-1764237666-1643415301.0 (pr-119) — 2022-01-29
- 2.0.2-pr-117-1763461396-1643401195.0 (pr-117) — 2022-01-28
- 2.0.1-pr-116-1698933465-1642183132.0 (pr-116) — 2022-01-14
- 2.0.1-pr-115-1698560824-1642176971.0 (pr-115) — 2022-01-14
- 2.0.1-pr-114-1698529647-1642176516.0 (pr-114) — 2022-01-14
- 2.0.1-pr-112-1608559743-1640118807.0 (pr-112) — 2021-12-21
- 2.0.1-pr-111-1295985448-1633109026.0 (pr-111) — 2021-10-01
- 1.5.1-pr-110-1291898890-1633019882.0 (pr-110) — 2021-09-30
- 1.4.3-pr-102-1095417579-1628090088.0 (pr-102) — 2021-08-04
- 1.4.3-pr-99-936267128-1623683896.0 (pr-99) — 2021-06-14
- 1.4.3-pr-96-860317229-1621512531.0 (pr-96) — 2021-05-20
- 1.4.2-pr-95-854045840-1621356344.0 (pr-95) — 2021-05-18
- … 80 more at https://npm.io/package/@lifeomic/alpha/versions

## README

# alpha

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/lifeomic/alpha.svg?branch=master)](https://travis-ci.org/lifeomic/alpha)
[![Coverage Status](https://coveralls.io/repos/github/lifeomic/alpha/badge.svg?branch=master)](https://coveralls.io/github/lifeomic/alpha?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/lifeomic/alpha.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/github/lifeomic/alpha/badge.svg?targetFile=package.json)](https://snyk.io/test/github/lifeomic/alpha?targetFile=package.json)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/lifeomic/alpha)

Alpha is a module that provides a single client interface for interacting with
HTTP micro-services regardless of whether they are implemented as Lambda
functions or real HTTP servers.

## API

`Alpha` instances are [`axios`][axios] clients at their core. This means that they
support the full `axios` API. The difference is how `Alpha` instances are
instantiated. Regardless of how an `Alpha` instance is instantiated, requests
to fully qualified HTTP URLs will _always_ perform a real HTTP request. Requests
made to Lambda functions with a `Buffer` payload will automatically encode the
request body using the base64 encoding.

### `new Alpha(target)`

Creates a new `Alpha` instances. All `Alpha` instances support the full
[`axios`][axios] API.

#### HTTP Targets

When an `Alpha` instance is created with an HTTP(S) base URL target, requests to
unqualified URLs will be relative to the base URL. For example, the following
code will dispatch the request to `http://example.com/some/path`.

```javascript
const alpha = new Alpha('http://example.com');
const response = await alpha.get('/some/path');
```

#### Lambda Function Targets

When an `Alpha` instance is created with a base URL using the `lambda` scheme,
requests to unqualified URLs will cause the specified [Lambda function][lambda]
to be invoked with a synthetic [API Gateway][api-gateway] event using the
optional [Lambda alias][lambda-alias]. For example, the following code will
invoke the `test-function` Lambda function with the `named-alias`.

```javascript
const alpha = new Alpha('lambda://test-function:named-alias');
const response = await alpha.get('/some/path');
```

The `lambda` URL scheme is interpreted according to the following pattern:

```xml
    lambda://<function-name>:<named-alias>
```

#### Lambda Handler Targets

When an `Alpha` instance is created with a handler function target, requests to
unqualified URLs will be transformed into synthetic [API Gateway (v1)][api-gateway]
events that will be passed directly to the handler function. This is primarily
used for unit testing Lambda handlers.

```javascript
const alpha = new Alpha(handlerFunction);
const response = await alpha.get('/some/path');
```

### Request Retries

An `Alpha` client can be configured to retry a failed attempt. A retryable failure
currently means a request that failed from a network error or had a `5xx` status
code.

```javascript
// Retry failed requests using default settings
const alpha = new Alpha('http://example.com', { retry: true });
```

```javascript
// Retry failed requests using custom settings
const alpha = new Alpha('http://example.com', { retry: {
    attempts: 3,        // The number of attempts to make (default 3)
    factor: 2,          // The factor to use for the exponential backoff delay (default 2)
    maxTimeout: 10000,  // The max timeout in milliseconds to delay before the next attempt (default 10000)
    retryCondition: function (error) { } // If function result is truthy, the error will be retried (default is retry network and 5xx errors)
  });
```

#### Mocking Lambda

To redirect the Lambda requests to a mocked implementation, either set the
`LAMBDA_ENDPOINT` environment variable, or use the `lambdaEndpoint` config option:

```javascript
const alpha = new Alpha('lambda:my-lambda', { 
  lambdaEndpoint: 'http://localstack:4566'
});
```

The value of this option will be used when creating the AWS Lambda client.

### `Alpha.dockerLambda(options, clientOptions)`

Creates an `Alpha` client instance that dispatches requests to
[`docker-lambda`][docker-lambda]. This facilitates testing Lambda services in a
full mock Lambda environment running in a docker container. The `options` are
passed to the [`docker-lambda`][docker-lambda] library and the `clientOptions`
configure the `Alpha` client instance that is created.

[api-gateway]: https://aws.amazon.com/documentation/apigateway/ "AWS API Gateway"
[axios]: https://github.com/mzabriskie/axios "Axios"
[docker-lambda]: https://github.com/lambci/docker-lambda "docker-lambda"
[lambda]: https://aws.amazon.com/documentation/lambda/ "AWS Lambda"
[lambda-alias]: https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html "AWS Lambda Versioning / Aliases"

---
_Source: https://npm.io/package/@lifeomic/alpha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
