Basic Typescript configuration.

This commit is contained in:
Patrick Fic
2022-04-28 17:49:41 -07:00
commit 295e4deeb2
12 changed files with 9036 additions and 0 deletions

29
util/serverInit.ts Normal file
View File

@@ -0,0 +1,29 @@
import fs = require("fs-extra");
import path, { resolve } from "path";
import dotenv from "dotenv";
import os from "os";
dotenv.config({
path: resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`),
});
const RootDirectory = process.env.MEDIA_PATH!.replace("~", os.homedir);
export const FolderPaths = {
Root: RootDirectory,
Jobs: path.join(RootDirectory, "Jobs"),
Vendors: path.join(RootDirectory, "Vendors"),
ThumbsSubDir: "/thumbs",
};
export default function InitServer() {
console.log(
`Root Media Path: ${FolderPaths.Root}`,
fs.pathExistsSync(FolderPaths.Root)
);
console.log(`Ensuring Root media path exists: ${FolderPaths.Root}`);
fs.ensureDirSync(FolderPaths.Root);
console.log(`Ensuring Jobs media path exists: ${FolderPaths.Jobs}`);
fs.ensureDirSync(FolderPaths.Jobs);
console.log(`Ensuring Vendors media path exists: ${FolderPaths.Vendors}`);
fs.ensureDirSync(FolderPaths.Vendors);
}