feat: gestion-utilisateur #1

Merged
Clement merged 37 commits from feat/gestion-utilisateur into master 2024-05-20 10:48:35 +00:00
2 changed files with 38 additions and 0 deletions
Showing only changes of commit 313c197096 - Show all commits

21
front/src/env.d.ts vendored
View File

@ -1 +1,22 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
export interface ImportMetaEnv {
NODE_ENV: string
APP_URL: string
POCKETBASEURL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
declare namespace App {
/**
* Middlewares variables
*/
interface Locals {}
}

17
front/src/libs/Env.ts Normal file
View File

@ -0,0 +1,17 @@
import type { ImportMetaEnv } from 'env'
/**
* Get the environment variable
*
* @param key the env variable key
* @param defaultValue a default value if applicable
* @returns the environment value or undefined if not found
*/
export function getEnv(key: keyof ImportMetaEnv, defaultValue: string): string
export function getEnv(key: keyof ImportMetaEnv, defaultValue?: string | undefined): string | undefined
export function getEnv(key: keyof ImportMetaEnv, defaultValue?: string | undefined): string | undefined {
// get the env variable through Astro > NodeJS > input
const res = import.meta.env[key] ?? process.env[key] ?? defaultValue
return res ?? undefined
}