summary refs log tree commit diff
path: root/src/util/FileStorage.ts
blob: b4d002138d113256f5c5f01d445fedfa1aed475e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { Storage } from "./Storage";
import fs from "fs/promises";
import { join } from "path";

export class FileStorage implements Storage {
	async get(path: string) {
		return fs.readFile(join(process.env.STORAGE_LOCATION || "", path), { encoding: "binary" });
	}

	async set(path: string, value: any) {
		return fs.writeFile(join(process.env.STORAGE_LOCATION || "", path), value, { encoding: "binary" });
	}
}