index.ts 512 B

1234567891011121314151617181920212223242526
  1. import { Instance } from "../project/instance"
  2. export namespace Env {
  3. const state = Instance.state(() => {
  4. return { ...process.env } as Record<string, string | undefined>
  5. })
  6. export function get(key: string) {
  7. const env = state()
  8. return env[key]
  9. }
  10. export function all() {
  11. return state()
  12. }
  13. export function set(key: string, value: string) {
  14. const env = state()
  15. env[key] = value
  16. }
  17. export function remove(key: string) {
  18. const env = state()
  19. delete env[key]
  20. }
  21. }