mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-07 22:28:01 +02:00
add configuration for storage
This commit is contained in:
@@ -23,6 +23,7 @@ interface Config {
|
|||||||
S3_CLIENT_SECRET?: string;
|
S3_CLIENT_SECRET?: string;
|
||||||
S3_ENDPOINT?: string;
|
S3_ENDPOINT?: string;
|
||||||
S3_REGION?: string;
|
S3_REGION?: string;
|
||||||
|
STORAGE: "filesystem" | "s3";
|
||||||
}
|
}
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
CLIENT_ID: "CLIENT_ID",
|
CLIENT_ID: "CLIENT_ID",
|
||||||
@@ -51,7 +52,14 @@ const config: Config = {
|
|||||||
"sol",
|
"sol",
|
||||||
"in",
|
"in",
|
||||||
],
|
],
|
||||||
|
STORAGE: "filesystem",
|
||||||
|
S3_BUCKET: null,
|
||||||
|
S3_CLIENT_ID: null,
|
||||||
|
S3_CLIENT_SECRET: null,
|
||||||
|
S3_ENDPOINT: null,
|
||||||
|
S3_REGION: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let conf in process.env) {
|
for (let conf in process.env) {
|
||||||
if ((config as any)[conf] !== undefined) {
|
if ((config as any)[conf] !== undefined) {
|
||||||
(config as any)[conf] = process.env[conf];
|
(config as any)[conf] = process.env[conf];
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
|
import config from "../config";
|
||||||
import FileSystem from "./storage/FileSystem";
|
import FileSystem from "./storage/FileSystem";
|
||||||
import S3Storage from "./storage/S3";
|
import S3Storage from "./storage/S3";
|
||||||
import { StorageBase } from "./types";
|
import { StorageBase } from "./types";
|
||||||
|
|
||||||
const storage = new FileSystem();
|
const storage = config.STORAGE == "s3" ? new S3Storage() : new FileSystem();
|
||||||
|
|
||||||
export default storage as StorageBase;
|
export default storage as StorageBase;
|
||||||
|
|||||||
Reference in New Issue
Block a user