Fallback for missing environment variable
All checks were successful
/ Misc Linters (push) Successful in 20s
/ Build App (push) Successful in 50s
Publish / tests (push) Successful in 51s
Publish / Publishing (push) Successful in 1m57s

This commit is contained in:
Valentin Brandl 2024-08-16 15:06:41 +02:00
parent b2bab79562
commit a2e78e2e36
Signed by: vbrandl
GPG Key ID: CAD4DA1A789125F9

View File

@ -1,6 +1,11 @@
// place files you want to import through the `$lib` alias in this folder.
const safePath = (input: string) => input.replace(/\W/g, '');
export const storagePath: string = process.env.STORAGE_PATH;
const defaultPath: string = './uploads';
if (!('STORAGE_PATH' in process.env)) {
console.log(`'STORAGE_PATH' environment variable is not set. Defaulting to ${defaultPath}`);
}
export const storagePath: string = process.env.STORAGE_PATH ?? defaultPath;
export default safePath;