Fix media code, clean up old types

This commit is contained in:
Jesse Wierzbinski 2024-03-10 13:57:26 -10:00
parent 852efaea50
commit 0e4d6b401c
No known key found for this signature in database
34 changed files with 137 additions and 1204 deletions

View file

@ -4,8 +4,8 @@ import { MediaBackend, MediaBackendType, MediaHasher } from "..";
import type { ConfigType } from "config-manager";
export class LocalMediaBackend extends MediaBackend {
constructor(private config: ConfigType) {
super(MediaBackendType.LOCAL);
constructor(config: ConfigType) {
super(config, MediaBackendType.LOCAL);
}
public async addFile(file: File) {

View file

@ -6,7 +6,7 @@ import type { ConfigType } from "config-manager";
export class S3MediaBackend extends MediaBackend {
constructor(
private config: ConfigType,
config: ConfigType,
private s3Client = new S3Client({
endPoint: config.s3.endpoint,
useSSL: true,
@ -16,7 +16,7 @@ export class S3MediaBackend extends MediaBackend {
secretKey: config.s3.secret_access_key,
})
) {
super(MediaBackendType.S3);
super(config, MediaBackendType.S3);
}
public async addFile(file: File) {

View file

@ -27,7 +27,10 @@ export class MediaHasher {
}
export class MediaBackend {
constructor(private backend: MediaBackendType) {}
constructor(
public config: ConfigType,
public backend: MediaBackendType
) {}
public getBackendType() {
return this.backend;

View file

@ -16,7 +16,6 @@ describe("MediaBackend", () => {
let mockConfig: ConfigType;
beforeEach(() => {
mediaBackend = new MediaBackend(MediaBackendType.S3);
mockConfig = {
media: {
conversion: {
@ -24,6 +23,7 @@ describe("MediaBackend", () => {
},
},
} as ConfigType;
mediaBackend = new MediaBackend(mockConfig, MediaBackendType.S3);
});
it("should initialize with correct backend type", () => {