env plugin for Elysia.js
bun add @yolk-oss/elysia-env
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}`)