summary refs log tree commit diff
path: root/src/start.ts
blob: 822a749fbed800d8235b73c84071a72fd43b986f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import dotenv from "dotenv";
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;
	}
} else {
	process.env.STORAGE_LOCATION = __dirname + "/../files/";
	process.env.STORAGE_PROVIDER = "file";
}

const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
server
	.start()
	.then(() => {
		console.log("[Server] started on :" + server.options.port);
	})
	.catch((e) => console.error("[Server] Error starting: ", e));