diff --git a/src/cdn/util/FileStorage.ts b/src/cdn/util/FileStorage.ts
index aee9d345..fea013a6 100644
--- a/src/cdn/util/FileStorage.ts
+++ b/src/cdn/util/FileStorage.ts
@@ -1,7 +1,7 @@
-import { Storage } from "./Storage";
import fs from "fs";
-import { join, relative, dirname } from "path";
+import { dirname, join } from "path";
import { Readable } from "stream";
+import { Storage } from "./Storage";
//import ExifTransformer = require("exif-be-gone");
import ExifTransformer from "exif-be-gone";
@@ -12,8 +12,7 @@ function getPath(path: string) {
const root = process.env.STORAGE_LOCATION || "../";
let 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;
}
@@ -36,7 +35,7 @@ export class FileStorage implements Storage {
async set(path: string, value: any) {
path = getPath(path);
//fse.ensureDirSync(dirname(path));
- fs.mkdirSync(dirname(path), {recursive: true});
+ fs.mkdirSync(dirname(path), { recursive: true });
value = Readable.from(value);
const cleaned_file = fs.createWriteStream(path);
diff --git a/src/cdn/util/S3Storage.ts b/src/cdn/util/S3Storage.ts
index c4066817..a7892e5e 100644
--- a/src/cdn/util/S3Storage.ts
+++ b/src/cdn/util/S3Storage.ts
@@ -11,11 +11,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.
@@ -28,7 +24,7 @@ export class S3Storage implements Storage {
await this.client.putObject({
Bucket: this.bucket,
Key: `${this.bucketBasePath}${path}`,
- Body: data,
+ Body: data
});
}
@@ -36,7 +32,7 @@ export class S3Storage implements Storage {
try {
const s3Object = await this.client.getObject({
Bucket: this.bucket,
- Key: `${this.bucketBasePath ?? ""}${path}`,
+ Key: `${this.bucketBasePath ?? ""}${path}`
});
if (!s3Object.Body) return null;
@@ -54,7 +50,7 @@ export class S3Storage implements Storage {
async delete(path: string): Promise<void> {
await this.client.deleteObject({
Bucket: this.bucket,
- Key: `${this.bucketBasePath}${path}`,
+ Key: `${this.bucketBasePath}${path}`
});
}
}
diff --git a/src/cdn/util/Storage.ts b/src/cdn/util/Storage.ts
index 728804a0..1ab6a1d9 100644
--- a/src/cdn/util/Storage.ts
+++ b/src/cdn/util/Storage.ts
@@ -1,9 +1,9 @@
-import { FileStorage } from "./FileStorage";
import path from "path";
+import { FileStorage } from "./FileStorage";
//import fse from "fs-extra";
+import { S3 } from "@aws-sdk/client-s3";
import fs from "fs";
import { bgCyan, black } from "picocolors";
-import { S3 } from "@aws-sdk/client-s3";
import { S3Storage } from "./S3Storage";
process.cwd();
@@ -24,7 +24,7 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
}
console.log(`[CDN] storage location: ${bgCyan(`${black(location)}`)}`);
//fse.ensureDirSync(location);
- fs.mkdirSync(location, {recursive: true});
+ fs.mkdirSync(location, { recursive: true });
process.env.STORAGE_LOCATION = location;
storage = new FileStorage();
@@ -33,16 +33,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);
}
@@ -50,9 +46,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;
}
diff --git a/src/cdn/util/multer.ts b/src/cdn/util/multer.ts
index bfdf6aff..f56b0fb5 100644
--- a/src/cdn/util/multer.ts
+++ b/src/cdn/util/multer.ts
@@ -5,6 +5,6 @@ export const multer = multerConfig({
limits: {
fields: 10,
files: 10,
- fileSize: 1024 * 1024 * 100, // 100 mb
- },
+ fileSize: 1024 * 1024 * 100 // 100 mb
+ }
});
|