Skip to content

Coercion playgrounds/examples#596

Merged
yamcodes merged 3 commits intocoercionfrom
568-coercion-playgroundsexamples
Dec 22, 2025
Merged

Coercion playgrounds/examples#596
yamcodes merged 3 commits intocoercionfrom
568-coercion-playgroundsexamples

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Dec 22, 2025

Closes #568

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated environment variable validation rules across playgrounds and examples for improved type consistency.
    • Refactored configuration code structure by streamlining variable declarations and removing intermediate bindings.

✏️ Tip: You can customize this high-level summary in your review settings.

- Refined `string.url` type
- Updated port and host type definitions
- Simplified logging in examples
- Standardized VITE_* variable types
@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

⚠️ No Changeset found

Latest commit: cf0720b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
arkenv Ready Ready Preview, Comment Dec 22, 2025 7:34pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

Walkthrough

This pull request updates environment variable validation schemas across multiple playground and example directories. Changes include switching validation types (e.g., string to string.url, string.host to string.ip | 'localhost'), refactoring logging code by removing intermediate variable bindings in favor of direct env property access, and simplifying validator method calls for functional parity.

Changes

Cohort / File(s) Summary
BUN_PUBLIC_API_URL type updates
apps/playgrounds/bun-react/src/env.ts, examples/with-bun-react/src/env.ts
Changed BUN_PUBLIC_API_URL validation from string to string.url
HOST/PORT schema updates
apps/playgrounds/node/index.ts, examples/basic/index.ts
Updated HOST from string.host to string.ip | 'localhost'; PORT from number.port to 0 <= number.integer <= 65535
Variable binding refactoring (direct env access in logging)
apps/playgrounds/bun/index.ts, examples/with-bun/index.ts
Removed intermediate variable bindings (host, port, nodeEnv); console.log now accesses env properties directly inline
Validator method and logging refactoring
apps/playgrounds/standard-schema/index.ts, examples/with-standard-schema/index.ts
Changed DATABASE_URL and ALLOWED_ORIGINS validators from z.string().url() to z.url(); removed intermediate constant bindings for console.log output
Vite config schema type updates
apps/playgrounds/vite-legacy/vite.config.ts
Changed VITE_MY_VAR from string to unknown; VITE_MY_NUMBER from parsed string to direct number; VITE_MY_BOOLEAN from parsed string to direct boolean

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review schema validation type changes across playground and example files to confirm they align with intended validation rules
  • Verify that direct env property access in logging maintains the same output behavior as the removed intermediate variables

Possibly related PRs

Suggested labels

arkenv

Poem

🐰 Hop along with types so clean,
From string to url, a stricter scene,
Variables inline now do we place,
Refactored logs at faster pace!

Pre-merge checks and finishing touches

❌ Failed checks (2 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Coercion playgrounds/examples' is vague and does not clearly convey the specific changes made across multiple files. Consider a more descriptive title like 'Refactor environment validation schemas and simplify logging in playgrounds/examples' to better communicate the scope of changes.
Linked Issues check ❓ Inconclusive Linked issue #568 lacks specific coding requirements or objectives, making it impossible to validate whether the pull request fulfills its stated goals. Review the linked issue #568 to identify specific requirements and confirm that all coding-related objectives have been addressed in this pull request.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes appear to be related to environment variable validation schemas and logging refactoring across playgrounds and examples, which align with the PR's stated objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 568-coercion-playgroundsexamples

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) label Dec 22, 2025
@yamcodes yamcodes changed the title 568 coercion playgroundsexamples Coercion playgrounds/examples Dec 22, 2025
- Use z.url() for direct URL validation
- Remove redundant variable declarations
- Streamline console.log for environment variables
@yamcodes yamcodes marked this pull request as ready for review December 22, 2025 19:35
@yamcodes
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/playgrounds/node/index.ts (1)

4-5: Same validator change as examples/basic/index.ts.

This file has the same change from built-in validators to explicit types. See the comment in examples/basic/index.ts (lines 4-5) for the verification request regarding this pattern.

🧹 Nitpick comments (1)
apps/playgrounds/vite-legacy/vite.config.ts (1)

13-13: Recommend using a more specific type than unknown for the example.

The unknown type provides no validation constraint and doesn't demonstrate best practices for environment variable schemas. Consider using "string", a string literal union (e.g., "'dev' | 'prod'"), or a built-in validator to make this example more useful.

Based on learnings, environment schemas should use built-in validators and descriptive types where possible.

🔎 Example alternatives
-	VITE_MY_VAR: "unknown",
+	VITE_MY_VAR: "string",

Or if demonstrating string literals:

-	VITE_MY_VAR: "unknown",
+	VITE_MY_VAR: "'development' | 'production'",

Or if demonstrating a built-in validator:

-	VITE_MY_VAR: "unknown",
+	VITE_MY_VAR: "string.url",
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78936c3 and cf0720b.

📒 Files selected for processing (9)
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/node/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/basic/index.ts
  • examples/with-bun-react/src/env.ts
  • examples/with-bun/index.ts
  • examples/with-standard-schema/index.ts
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) from src/types.ts when available instead of custom validation
Use ArkEnvError for environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...

Files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
{bin,examples,playgrounds}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Console usage is allowed in bin/ and example/playground directories, otherwise treated as warning

Files:

  • examples/with-bun-react/src/env.ts
  • examples/with-standard-schema/index.ts
  • examples/with-bun/index.ts
  • examples/basic/index.ts
examples/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

examples/**/*.{ts,tsx}: Ensure examples demonstrate secure default practices
Add examples in the examples/ directory for new functionality, demonstrating real-world usage patterns

Files:

  • examples/with-bun-react/src/env.ts
  • examples/with-standard-schema/index.ts
  • examples/with-bun/index.ts
  • examples/basic/index.ts
**/*.{ts,tsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome for linting and formatting instead of ESLint and Prettier

Files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file> for running TypeScript and JavaScript files
Bun automatically loads .env files, so don't use the dotenv package
Use Bun.serve() with built-in WebSocket, HTTPS, and route support instead of express
Use bun:sqlite for SQLite database operations instead of better-sqlite3
Use Bun.redis for Redis operations instead of ioredis
Use Bun.sql for Postgres database operations instead of pg or postgres.js
Use built-in WebSocket instead of the ws package
Prefer Bun.file over node:fs readFile/writeFile methods for file operations
Use Bun.$ template literal syntax for shell commands instead of execa

Files:

  • apps/playgrounds/bun-react/src/env.ts
apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html,css}

📄 CodeRabbit inference engine (apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild for bundling

Files:

  • apps/playgrounds/bun-react/src/env.ts
apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html}

📄 CodeRabbit inference engine (apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

CSS files can be imported directly in TypeScript/JavaScript or referenced in HTML <link> tags, and Bun will automatically bundle them

Files:

  • apps/playgrounds/bun-react/src/env.ts
apps/playgrounds/bun-react/**/*.ts

📄 CodeRabbit inference engine (apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun --hot to run TypeScript entry files with hot module reloading enabled

Files:

  • apps/playgrounds/bun-react/src/env.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use barrel exports (index.ts) for package entry points

Files:

  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
apps/playgrounds/bun/**/*.{ts,js}

📄 CodeRabbit inference engine (apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun <file> instead of node <file> or ts-node <file> for running scripts

Files:

  • apps/playgrounds/bun/index.ts
apps/playgrounds/bun/**/*.{html,ts,tsx,css}

📄 CodeRabbit inference engine (apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild for bundling

Files:

  • apps/playgrounds/bun/index.ts
apps/playgrounds/bun/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

apps/playgrounds/bun/**/*.{ts,tsx,js,jsx}: Bun automatically loads .env files, so don't use dotenv library
Use Bun.serve() with built-in WebSocket, HTTPS, and route support instead of express
Use bun:sqlite for SQLite database operations instead of better-sqlite3
Use Bun.redis for Redis operations instead of ioredis
Use Bun.sql for Postgres operations instead of pg or postgres.js
Use built-in WebSocket instead of ws library
Prefer Bun.file over node:fs readFile/writeFile for file operations
Use Bun.$\command`for shell execution instead ofexeca`

Files:

  • apps/playgrounds/bun/index.ts
apps/playgrounds/bun/**/index.ts

📄 CodeRabbit inference engine (apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Run frontend development with bun --hot ./index.ts for hot module reloading

Files:

  • apps/playgrounds/bun/index.ts
🧠 Learnings (30)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use built-in validators (host, port, url, email) from `src/types.ts` when available instead of custom validation
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use the dotenv package

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use `dotenv` library

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.ts : Use `bun --hot` to run TypeScript entry files with hot module reloading enabled

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use UPPER_SNAKE_CASE for environment variables and constants

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive environment variable names that indicate purpose and format

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx} : Use `Bun.redis` for Redis operations instead of `ioredis`

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx} : Use `Bun.serve()` with built-in WebSocket, HTTPS, and route support instead of `express`

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for bundling

Applied to files:

  • examples/with-bun-react/src/env.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Use `Bun.redis` for Redis operations instead of `ioredis`

Applied to files:

  • examples/with-bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/node/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/node/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions

Applied to files:

  • examples/with-bun-react/src/env.ts
  • apps/playgrounds/bun-react/src/env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export

Applied to files:

  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern

Applied to files:

  • apps/playgrounds/bun-react/src/env.ts
  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Use `Bun.serve()` with built-in WebSocket, HTTPS, and route support instead of `express`

Applied to files:

  • apps/playgrounds/bun-react/src/env.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas

Applied to files:

  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values

Applied to files:

  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/standard-schema/index.ts
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to packages/vite-plugin/src/**/*.test.ts : Test the Vite plugin using the with-vite-react example as a fixture and validate that the plugin works with real Vite projects

Applied to files:

  • apps/playgrounds/vite-legacy/vite.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors

Applied to files:

  • apps/playgrounds/vite-legacy/vite.config.ts
  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use built-in validators (host, port, url, email) from `src/types.ts` when available instead of custom validation

Applied to files:

  • examples/with-standard-schema/index.ts
  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition

Applied to files:

  • examples/with-standard-schema/index.ts
  • apps/playgrounds/node/index.ts
  • apps/playgrounds/standard-schema/index.ts
  • examples/basic/index.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,js} : Use `bun <file>` instead of `node <file>` or `ts-node <file>` for running scripts

Applied to files:

  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx} : Use `bun <file>` instead of `node <file>` or `ts-node <file>` for running TypeScript and JavaScript files

Applied to files:

  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/index.ts : Run frontend development with `bun --hot ./index.ts` for hot module reloading

Applied to files:

  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `process.env` in tests for different scenarios and save/restore original env in `beforeEach`/`afterEach` hooks

Applied to files:

  • examples/with-bun/index.ts
  • apps/playgrounds/bun/index.ts
🧬 Code graph analysis (2)
examples/with-standard-schema/index.ts (3)
packages/arkenv/src/type.ts (1)
  • type (3-3)
apps/playgrounds/js/index.js (1)
  • env (3-7)
examples/basic-js/index.js (1)
  • env (3-7)
apps/playgrounds/standard-schema/index.ts (3)
packages/arkenv/src/type.ts (1)
  • type (3-3)
apps/playgrounds/js/index.js (1)
  • env (3-7)
examples/basic-js/index.js (1)
  • env (3-7)
🔇 Additional comments (9)
examples/with-bun-react/src/env.ts (1)

4-4: LGTM! Enhanced validation for API URL.

The change from "string" to "string.url" adds proper URL validation, ensuring the environment variable contains a valid URL format at runtime.

apps/playgrounds/bun-react/src/env.ts (1)

4-4: LGTM! Consistent URL validation.

The upgrade to "string.url" ensures runtime validation of the API URL format.

apps/playgrounds/bun/index.ts (1)

11-11: LGTM! Cleaner inline property access.

The refactor from intermediate variables to direct env property access simplifies the logging code without changing functionality.

examples/with-bun/index.ts (1)

11-11: LGTM! Simplified logging with inline access.

The refactor to use direct env property access in logging maintains the same output while reducing code verbosity.

apps/playgrounds/standard-schema/index.ts (3)

12-12: LGTM! More idiomatic Zod URL validation.

The change from z.string().url() to z.url() is the preferred Zod pattern for URL validation.


26-26: LGTM! Consistent validator simplification.

The update to use z.url() directly within the array aligns with the idiomatic Zod pattern used for DATABASE_URL.


33-44: LGTM! Streamlined logging.

The refactor to access env properties directly in the console.log removes unnecessary intermediate variables while maintaining identical output.

examples/with-standard-schema/index.ts (1)

12-12: LGTM! Consistent changes with apps/playgrounds/standard-schema/index.ts.

These changes mirror the validator simplification and logging refactor in apps/playgrounds/standard-schema/index.ts, maintaining consistency across standard-schema examples.

Also applies to: 26-26, 33-44

apps/playgrounds/vite-legacy/vite.config.ts (1)

14-15: LGTM! Direct type coercion aligns with the PR objectives.

The use of "number" and "boolean" types demonstrates ArkType's runtime coercion from string environment variables to these native types, which aligns with the coercion examples goal of this PR.

@yamcodes yamcodes merged commit 167ba08 into coercion Dec 22, 2025
7 checks passed
@yamcodes yamcodes deleted the 568-coercion-playgroundsexamples branch December 22, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant