Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 0 additions & 90 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
1 change: 1 addition & 0 deletions apps/www/app/styles/components/github-alerts.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
.octicon {
margin-right: calc(var(--rehype-github-alerts-default-space) / 2);
display: inline-block;
/* biome-ignore lint/complexity/noImportantStyles: it just works */
overflow: visible !important;
vertical-align: text-bottom;
}
4 changes: 2 additions & 2 deletions apps/www/source.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { remarkInstall } from "fumadocs-docgen";
import { remarkNpm } from "fumadocs-core/mdx-plugins";
import { defineConfig, defineDocs } from "fumadocs-mdx/config";
import { rehypeGithubAlerts } from "rehype-github-alerts";
import remarkGemoji from "remark-gemoji";
Expand All @@ -13,6 +13,6 @@ export const docs = defineDocs({
export default defineConfig({
mdxOptions: {
rehypePlugins: [rehypeGithubAlerts],
remarkPlugins: [remarkGemoji, remarkInstall],
remarkPlugins: [remarkGemoji, remarkNpm],
},
});
3 changes: 2 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"noUnusedImports": "warn"
},
"suspicious": {
"noConsole": "warn"
"noConsole": "warn",
"noUnknownAtRules": "off"
},
"style": {
"noParameterAssign": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"typecheck": "turbo run typecheck",
"docs": "turbo run dev --filter=www",
"www": "turbo run dev --filter=www",
"release": "mv README.md packages/arkenv && pnpm run build:packages && changeset publish",
"release": "pnpm run build:packages && changeset publish",
Comment thread
yamcodes marked this conversation as resolved.
"fix": "biome check --write .",
"check": "biome check",
"check:errors": "biome check --diagnostic-level=error",
Expand Down
91 changes: 87 additions & 4 deletions packages/arkenv/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,90 @@
# `arkenv`
<p align="center">
<a href="https://arkenv.js.org">
<img alt="arkenv - Typesafe Environment Variables" src="https://og.tailgraph.com/og?titleFontFamily=JetBrains+Mono&textFontFamily=Inter&title=ArkEnv&titleTailwind=text-[%23e9eef9]%20font-bold%20relative%20decoration-%5Brgb(180,215,255)%5D%20decoration-wavy%20decoration-[5px]%20underline%20underline-offset-[16px]%20text-5xl%20mb-8&text=Typesafe%20environment%20variables%20powered%20by%20ArkType&textTailwind=text-[%238b9dc1]%20text-3xl&bgTailwind=bg-gradient-to-b%20from-[%23061a3a]%20to-black" width="645px">
</a>
<br />
<a href="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml?query=branch%3Amain"><img alt="Tests Status" src="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml/badge.svg?event=push&branch=main"></a>
<a href="https://bundlephobia.com/package/arkenv"><img alt="Bundle Size" src="https://img.shields.io/bundlephobia/min/arkenv?label=bundle%20size&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMzcgMTU3IiB3aWR0aD0iMTM3IiBoZWlnaHQ9IjE1NyI+PHJlY3QgZmlsbD0iI2ZmZiIgeD0iNjIuMzEiIHk9IjEwMi4zMSIgd2lkdGg9IjE2Ljc0IiBoZWlnaHQ9IjE1Ljk0IiByeD0iNy45NyIvPjxyZWN0IGZpbGw9IiNmZmYiIHg9IjYyLjMxIiB5PSI4Ni4zNyIgd2lkdGg9IjE2Ljc0IiBoZWlnaHQ9IjMxLjg4IiByeD0iOC4zNyIvPjxlbGxpcHNlIGZpbGw9IiNmZmYiIGN4PSI0NC4zNCIgY3k9IjU0LjIyIiByeD0iNy4xMyIgcnk9IjguNDUiLz48ZWxsaXBzZSBmaWxsPSIjZmZmIiBjeD0iOTMuNzUiIGN5P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OC44IDIyLjkyLTQyLjAzIDAtMi40LS4yLTQuOC0uNC03LjF6Ii8+PC9zdmc+"></a>
<a href="https://www.npmjs.com/package/arkenv?activeTab=versions"><img alt="Total Downloads" src="https://badgen.net/npm/dt/arkenv?icon=npm&color=blue&label=downloads"></a>
<a href="https://www.npmjs.com/package/arkenv?activeTab=dependencies"><img alt="Dependency Count" src="https://badgen.net/bundlephobia/dependency-count/arkenv?icon=npm&color=blue&label=dependencies"></a>
<a href="https://arktype.io/"><img alt="Powered By ArkType" src="https://badgen.net/static/powered by/ArkType"></a>
</p>

Hello, developers! Welcome to the `arkenv` package codebase. This directory contains the core implementation of ArkEnv, providing typesafe environment variable parsing and validation for Node.js.
## Installation

Comment thread
yamcodes marked this conversation as resolved.
For more information, please refer to the [README](../../README.md) in the monorepo root.
<details open>
<summary>npm</summary>

Happy coding!
```sh
npm install arkenv arktype
```
</details>

<details>
<summary>pnpm</summary>

```sh
pnpm add arkenv arktype
```
</details>

<details>
<summary>Yarn</summary>

```sh
yarn add arkenv arktype
```
</details>

<details>
<summary>Bun</summary>

```sh
bun add arkenv arktype
```
</details>

## Quickstart

> [!TIP]
> Find more examples in the [examples](https://github.com/yamcodes/arkenv/tree/main/examples) directory.

```ts
import { createEnv } from 'arkenv';

const env = createEnv({
HOST: "string.host", // valid IP address or localhost
PORT: "number.port", // valid port number (0-65535)
NODE_ENV: "'development' | 'production' | 'test'",
});

// Automatically validate and parse process.env
// TypeScript knows the ✨exact✨ types!
console.log(env.HOST); // (property) HOST: string
console.log(env.PORT); // (property) PORT: number
console.log(env.NODE_ENV); // (property) NODE_ENV: "development" | "production" | "test"
```

## Features

- 🔒 **Typesafe**: Full TypeScript support with inferred types
- 🚀 **Runtime validation**: Catch missing or invalid environment variables early
- 💪 **Powered by ArkType**: Leverage ArkType's powerful type system
- 🪶 **Lightweight**: Only a single dependency ([5.6 kB](https://bundlephobia.com/package/chalk@5.4.1))
- ⚡ **Fast**: Optimized for performance with minimal overhead

## Documentation

For detailed documentation and examples, please visit our [documentation site](https://arkenv.js.org/docs).

## Plugins

- [@arkenv/vite-plugin](https://github.com/yamcodes/arkenv/tree/main/packages/vite-plugin): [Vite](https://vite.dev/) plugin to validate environment variables at build time

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.md](https://github.com/yamcodes/arkenv/blob/main/CONTRIBUTING.md) for more information.

## Thanks / Inspiration

Find projects and people who helped or inspired the creation of ArkEnv in [THANKS.md](https://github.com/yamcodes/arkenv/blob/main/THANKS.md). Thank you 🙏
2 changes: 1 addition & 1 deletion packages/arkenv/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type } from "arktype";
* A `string` that can be parsed into a number between 0 and 65535
*/
export const port = type("string", "=>", (data, ctx) => {
const asNumber = Number.parseInt(data);
const asNumber = Number.parseInt(data, 10);
const isInteger = Number.isInteger(asNumber);
const isBetween = 0 <= asNumber && asNumber <= 65535;
if (!isInteger || !isBetween) {
Expand Down
Loading