summary refs log tree commit diff
path: root/src/cdn/util
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
commit0a8ceb9e6349284e75545a01ffad608b020f78e2 (patch)
tree17a9163f963eddabf9168b0b630096b2f7535b64 /src/cdn/util
parentPrettier: use editorconfig (diff)
downloadserver-dev/emma-refactors.tar.xz
Actually run prettier dev/emma-refactors
Diffstat (limited to 'src/cdn/util')
-rw-r--r--src/cdn/util/FileStorage.ts6
-rw-r--r--src/cdn/util/S3Storage.ts6
-rw-r--r--src/cdn/util/Storage.ts12
3 files changed, 6 insertions, 18 deletions
diff --git a/src/cdn/util/FileStorage.ts b/src/cdn/util/FileStorage.ts
index 10b36743..5e53081b 100644
--- a/src/cdn/util/FileStorage.ts
+++ b/src/cdn/util/FileStorage.ts
@@ -30,8 +30,7 @@ function getPath(path: string) {
 	const root = process.env.STORAGE_LOCATION || "../";
 	const filename = join(root, path);
 
-	if (path.indexOf("\0") !== -1 || !filename.startsWith(root))
-		throw new Error("invalid path");
+	if (path.indexOf("\0") !== -1 || !filename.startsWith(root)) throw new Error("invalid path");
 	return filename;
 }
 
@@ -53,8 +52,7 @@ export class FileStorage implements Storage {
 
 	async set(path: string, value: Buffer) {
 		path = getPath(path);
-		if (!fs.existsSync(dirname(path)))
-			fs.mkdirSync(dirname(path), { recursive: true });
+		if (!fs.existsSync(dirname(path))) fs.mkdirSync(dirname(path), { recursive: true });
 
 		const ret = Readable.from(value);
 		const cleaned_file = fs.createWriteStream(path);
diff --git a/src/cdn/util/S3Storage.ts b/src/cdn/util/S3Storage.ts
index 81acd945..fd079ef0 100644
--- a/src/cdn/util/S3Storage.ts
+++ b/src/cdn/util/S3Storage.ts
@@ -29,11 +29,7 @@ const readableToBuffer = (readable: Readable): Promise<Buffer> =>
 	});
 
 export class S3Storage implements Storage {
-	public constructor(
-		private client: S3,
-		private bucket: string,
-		private basePath?: string,
-	) {}
+	public constructor(private client: S3, private bucket: string, private basePath?: string) {}
 
 	/**
 	 * Always return a string, to ensure consistency.
diff --git a/src/cdn/util/Storage.ts b/src/cdn/util/Storage.ts
index 26289af6..609e38e9 100644
--- a/src/cdn/util/Storage.ts
+++ b/src/cdn/util/Storage.ts
@@ -49,16 +49,12 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
 		bucket = process.env.STORAGE_BUCKET;
 
 	if (!region) {
-		console.error(
-			`[CDN] You must provide a region when using the S3 storage provider.`,
-		);
+		console.error(`[CDN] You must provide a region when using the S3 storage provider.`);
 		process.exit(1);
 	}
 
 	if (!bucket) {
-		console.error(
-			`[CDN] You must provide a bucket when using the S3 storage provider.`,
-		);
+		console.error(`[CDN] You must provide a bucket when using the S3 storage provider.`);
 		process.exit(1);
 	}
 
@@ -66,9 +62,7 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
 	let location = process.env.STORAGE_LOCATION;
 
 	if (!location) {
-		console.warn(
-			`[CDN] STORAGE_LOCATION unconfigured for S3 provider, defaulting to the bucket root...`,
-		);
+		console.warn(`[CDN] STORAGE_LOCATION unconfigured for S3 provider, defaulting to the bucket root...`);
 		location = undefined;
 	}