Fallback for missing environment variable
This commit is contained in:
parent
b2bab79562
commit
a2e78e2e36
@ -1,6 +1,11 @@
|
|||||||
// place files you want to import through the `$lib` alias in this folder.
|
// place files you want to import through the `$lib` alias in this folder.
|
||||||
|
|
||||||
const safePath = (input: string) => input.replace(/\W/g, '');
|
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;
|
export default safePath;
|
||||||
|
Reference in New Issue
Block a user