1.0.0-alpha.28 • Published 8 months ago

@arcjet/env v1.0.0-alpha.28

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@arcjet/env

Arcjet environment detection.

Currently operates on an environment object with the type:

type Env = {
  FLY_APP_NAME?: string;
  NODE_ENV?: string;
  ARCJET_KEY?: string;
  ARCJET_ENV?: string;
  ARCJET_LOG_LEVEL?: string;
  ARCJET_BASE_URL?: string;
};

Installation

npm install -S @arcjet/env

Example

import * as env from "@arcjet/env";

env.platform({ FLY_APP_NAME: "foobar" }) === "fly-io";
env.platform({}) === undefined;

env.isDevelopment({ NODE_ENV: "production" }) === false;
env.isDevelopment({ NODE_ENV: "development" }) === true;
env.isDevelopment({ ARCJET_ENV: "production" }) === false;
env.isDevelopment({ ARCJET_ENV: "development" }) === true;

env.logLevel({ ARCJET_LOG_LEVEL: "debug" }) === "debug";
env.logLevel({ ARCJET_LOG_LEVEL: "info" }) === "info";
env.logLevel({ ARCJET_LOG_LEVEL: "warn" }) === "warn";
env.logLevel({ ARCJET_LOG_LEVEL: "error" }) === "error";
env.logLevel({ ARCJET_LOG_LEVEL: "" }) === "warn"; // default

// Will use various environment variables to detect the proper base URL
env.baseUrl(process.env);

env.apiKey({ ARCJET_KEY: "ajkey_abc123" }) === "ajkey_abc123";
env.apiKey({ ARCJET_KEY: "invalid" }) === undefined;

License

Licensed under the Apache License, Version 2.0.

1.0.0-alpha.28

8 months ago

1.0.0-alpha.27

9 months ago

1.0.0-alpha.26

9 months ago

1.0.0-alpha.23

10 months ago

1.0.0-alpha.25

9 months ago

1.0.0-alpha.24

10 months ago

1.0.0-alpha.22

10 months ago

1.0.0-alpha.21

11 months ago

1.0.0-alpha.20

11 months ago

1.0.0-alpha.19

11 months ago

1.0.0-alpha.18

12 months ago

1.0.0-alpha.17

1 year ago

1.0.0-alpha.16

1 year ago

1.0.0-alpha.15

1 year ago

1.0.0-alpha.14

1 year ago