🚧 file storage

This commit is contained in:
Flam3rboy
2021-05-27 20:01:50 +02:00
parent 293894a4f9
commit 4e69d83457
6 changed files with 21 additions and 14 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ if (process.env.STORAGE_LOCATION) {
}
} else process.env.STORAGE_LOCATION = __dirname + "/../files/";
const server = new CDNServer();
const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
server
.start()
.then(() => {
+8 -2
View File
@@ -1,7 +1,13 @@
import { Storage } from "./Storage";
import fs from "fs/promises";
import { join } from "path";
export class FileStorage implements Storage {
async get(path: string, prefix?: string) {}
async get(path: string) {
return fs.readFile(join(process.env.STORAGE_LOCATION || "", path), { encoding: "binary" });
}
async set(path: string, value: any) {}
async set(path: string, value: any) {
return fs.writeFile(join(process.env.STORAGE_LOCATION || "", path), value, { encoding: "binary" });
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
import { FileStorage } from "./FileStorage";
export interface Storage {
set(hash: string, data: any, prefix?: string): Promise<void>;
get(hash: string, prefix?: string): Promise<any>;
set(path: string, data: any): Promise<void>;
get(path: string): Promise<any>;
}
var storage: Storage;