@yolk-oss/elysia-env
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@yolk-oss/elysia-env

NPM License NPM Version

env plugin for Elysia.js

Installation

bun add @yolk-oss/elysia-env

Usage

import { Elysia, t } from 'elysia'
import { env } from '@yolk-oss/elysia-env'

const app = new Elysia()
    .use(
        env({
            TOKEN: t.String({
                minLength: 5,
                error: 'TOKEN is required for a service!',
            }),
        }),
    )
    .get('/', ({ env }) => env.TOKEN)
    //                           ^? (property) TOKEN: string
    .listen(8080)

console.log(`Listening on http://${app.server!.hostname}:${app.server!.port}`)

Checkout the examples and tests folders on github.

License

MIT

Package Sidebar

Install

npm i @yolk-oss/elysia-env

Weekly Downloads

196

Version

1.0.2

License

MIT

Unpacked Size

9.73 kB

Total Files

7

Last publish

Collaborators

  • fecony