add s3 and local dir support, fix session roles, make sure delete invite checks if its valid first

This commit is contained in:
creations 2025-03-05 08:45:08 -05:00
parent 9a91f1e7e3
commit 774c8e22ce
Signed by: creations
GPG key ID: 8F553AA4320FC711
11 changed files with 171 additions and 12 deletions

View file

@ -1,5 +1,7 @@
import { dataType } from "@config/environment";
import { logger } from "@helpers/logger";
import { type ReservedSQL, sql } from "bun";
import { type ReservedSQL, s3, sql } from "bun";
import { existsSync, mkdirSync } from "fs";
import { readdir } from "fs/promises";
import { resolve } from "path";
@ -40,6 +42,41 @@ async function main(): Promise<void> {
process.exit(1);
}
if (dataType.type === "local" && dataType.path) {
if (!existsSync(dataType.path)) {
try {
mkdirSync(dataType.path);
} catch (error) {
logger.error([
"Could not create datasource local directory",
error as Error,
]);
process.exit(1);
}
}
logger.info([
"Using local datasource directory",
`${dataType.path}`,
]);
} else {
try {
await s3.write("test", "test");
await s3.delete("test");
logger.info([
"Connected to S3 with bucket",
`${process.env.S3_BUCKET}`,
]);
} catch (error) {
logger.error([
"Could not establish a connection to S3 bucket:",
error as Error,
]);
process.exit(1);
}
}
await redis.initialize();
serverHandler.initialize();
await initializeDatabase();