Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yolk-oss/elysia-env
env plugin for Elysia 🦊
https://github.com/yolk-oss/elysia-env
Last synced: 3 months ago
JSON representation
env plugin for Elysia 🦊
- Host: GitHub
- URL: https://github.com/yolk-oss/elysia-env
- Owner: yolk-oss
- License: mit
- Created: 2024-03-20T23:36:27.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-28T15:10:38.000Z (8 months ago)
- Last Synced: 2024-07-26T15:31:00.853Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 111 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @yolk-oss/elysia-env
[![elysia][elysia-src]][elysia-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![License][license-src]][license-href]env plugin for [Elysia.js](https://elysiajs.com)
## Installation
```bash
bun add @yolk-oss/elysia-env
```## Usage
```ts
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](./examples) and [tests](./tests) folders on github.
## License
[MIT](LICENSE)
[elysia-src]: https://img.shields.io/badge/%F0%9F%A6%8A-f6f8fa?style=flat-square&label=elysia&labelColor=f06292
[elysia-href]: https://elysiajs.com/
[npm-version-src]: https://img.shields.io/npm/v/@yolk-oss/elysia-env?style=flat-square&labelColor=EFEBE8&color=F4BB29
[npm-version-href]: https://npmjs.com/package/@yolk-oss/elysia-env
[npm-downloads-src]: https://img.shields.io/npm/dm/@yolk-oss/elysia-env?style=flat-square&labelColor=EFEBE8&color=F4BB29
[npm-downloads-href]: https://npmjs.com/package/@yolk-oss/elysia-env
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@yolk-oss/elysia-env?style=flat-square&labelColor=EFEBE8&color=F4BB29&label=bundlephobia
[bundle-href]: https://bundlephobia.com/result?p=@yolk-oss/elysia-env
[license-src]: https://img.shields.io/github/license/yolk-oss/elysia-env.svg?style=flat-square&labelColor=EFEBE8&color=F4BB29
[license-href]: https://github.com/yolk-oss/elysia-plugin/blob/main/LICENSE