-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d8e69ed
Showing
10 changed files
with
1,339 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Deno CI 🦕 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
name: Run Deno Tests 🧪 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository 🛎️ | ||
uses: actions/checkout@v4 | ||
- name: Setup Deno Environment 🦕 | ||
uses: denoland/setup-deno@v2 | ||
with: | ||
deno-version: v2.x | ||
- name: Execute Tests 🧪 | ||
run: deno task test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish to JSR 🚀 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
name: Publish JSR Package 📦 | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write # The OIDC ID token is used for authentication with JSR. | ||
steps: | ||
- name: Checkout Repository 🛎️ | ||
uses: actions/checkout@v4 | ||
- name: Setup Deno 🦕 | ||
uses: denoland/setup-deno@v2 | ||
with: | ||
deno-version: v2.x | ||
- name: Run Tests 🧪 | ||
run: deno task test | ||
- name: Publish Package 🚀 | ||
run: deno publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Logs | ||
*.jsonl | ||
*.log | ||
|
||
# OS generated files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 WüSpace e. V. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# @wuespace/envar | ||
|
||
[![JSR Scope](https://jsr.io/badges/@wuespace)](https://jsr.io/@wuespace) | ||
[![JSR](https://jsr.io/badges/@wuespace/envar)](https://jsr.io/@wuespace/envar) | ||
[![JSR Score](https://jsr.io/badges/@wuespace/envar/score)](https://jsr.io/@wuespace/envar) | ||
[![Deno CI](https://github.com/wuespace/envar/actions/workflows/deno-ci.yml/badge.svg)](https://github.com/wuespace/envar/actions/workflows/deno-ci.yml) | ||
[![Publish Workflow](https://github.com/wuespace/envar/actions/workflows/publish-jsr.yml/badge.svg)](https://github.com/wuespace/envar/actions/workflows/publish-jsr.yml) | ||
|
||
🚀 **Envar** makes it easy to add configurability to your Deno applications. | ||
It supports loading configuration from environment variables as well as | ||
specifying default values. | ||
It even supports configuration values from files specified by environment | ||
variables to provide first-class support for secrets and the like in your | ||
Docker Swarm or Kubernetes deployments. | ||
|
||
## 📦 Usage | ||
|
||
You can use Envar in your Deno application by importing it from the | ||
`jsr:@wuespace/envar` module. | ||
|
||
```tsx | ||
// Import the initVariable function from the module | ||
import { initVariable, EnvNotSetError } from "jsr:@wuespace/envar"; | ||
import { z } from "npm:zod"; | ||
|
||
// Initialize the application variables | ||
await initVariable("PORT", z.string().match(/^[0-9]{1,5}$/), "8080"); | ||
await initVariable("SECRET", z.string().min(32)); | ||
// At this point, we can rest assured that we have valid values for | ||
// PORT and SECRET. Otherwise, the promises would have been rejected. | ||
|
||
// Access the variables like you normally would. | ||
// Everything's synchronous now, so it's quite easy. | ||
console.log(Deno.env.get("PORT")); | ||
console.log(Deno.env.get("SECRET")); | ||
|
||
// For type safety, you'll need to check if it's undefined: | ||
const port = Deno.env.get("PORT"); | ||
if (port == undefined) { | ||
// Automatically generate a nice error message for the user | ||
throw new EnvNotSetError("PORT"); | ||
} | ||
|
||
// Alternatively, you can also use process.env in Deno 2.0+ | ||
console.log(process.env.PORT); | ||
``` | ||
|
||
## 👥 Authors | ||
|
||
This package was created and is maintained by [WüSpace e. V.](https://github.com/wuespace) | ||
|
||
Its primary author is [Zuri Klaschka](https://github.com/pklaschka). | ||
|
||
## 📄 License | ||
|
||
This package is licensed under the MIT license. See the [LICENSE](LICENSE) file for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@wuespace/envar", | ||
"version": "0.0.1", | ||
"exports": "./mod.ts", | ||
"license": "MIT", | ||
"scopes": { | ||
}, | ||
"publish": { | ||
"include": [ | ||
"mod.ts", | ||
"LICENSE", | ||
"README.md" | ||
] | ||
}, | ||
"tasks": { | ||
"dev": "deno task test --watch", | ||
"test": "deno test --allow-env --allow-read --allow-write" | ||
}, | ||
"imports": { | ||
"@std/assert": "jsr:@std/assert@1", | ||
"@std/log": "jsr:@std/log@^0.224.9" | ||
} | ||
} |
Oops, something went wrong.