From ede8ed4b715a0167a63edcc15cdc5d4c644356c5 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 7 Aug 2021 13:15:35 +0200 Subject: :sparkles: icons + banners route --- src/start.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/start.ts') diff --git a/src/start.ts b/src/start.ts index 822a749f..57c9f704 100644 --- a/src/start.ts +++ b/src/start.ts @@ -1,17 +1,23 @@ +import path from "path"; import dotenv from "dotenv"; +import fse from "fs-extra"; dotenv.config(); -import { CDNServer } from "./Server"; - -if (process.env.STORAGE_LOCATION) { - if (!process.env.STORAGE_LOCATION.startsWith("/")) { - process.env.STORAGE_LOCATION = __dirname + "/../" + process.env.STORAGE_LOCATION; +if (!process.env.STORAGE_PROVIDER) process.env.STORAGE_PROVIDER = "file"; +// TODO:nodejs path.join trailing slash windows compatible +if (process.env.STORAGE_PROVIDER === "file") { + if (process.env.STORAGE_LOCATION) { + if (!process.env.STORAGE_LOCATION.startsWith("/")) { + process.env.STORAGE_LOCATION = path.join(__dirname, "..", process.env.STORAGE_LOCATION, "/"); + } + } else { + process.env.STORAGE_LOCATION = path.join(__dirname, "..", "files", "/"); } -} else { - process.env.STORAGE_LOCATION = __dirname + "/../files/"; - process.env.STORAGE_PROVIDER = "file"; + fse.ensureDirSync(process.env.STORAGE_LOCATION); } +import { CDNServer } from "./Server"; + const server = new CDNServer({ port: Number(process.env.PORT) || 3003 }); server .start() -- cgit 1.5.1