Basic Typescript configuration.
This commit is contained in:
29
util/serverInit.ts
Normal file
29
util/serverInit.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user