From 2a10837194a87cb14133677cd20aaa63ae7e4c2e Mon Sep 17 00:00:00 2001
From: Dragory <2606411+Dragory@users.noreply.github.com>
Date: Sun, 21 Jul 2019 14:37:46 +0300
Subject: [PATCH] Separate bot and API server .env files. Add example .env
 files.

---
 api.env.example        | 9 +++++++++
 bot.env.example        | 5 +++++
 dashboard/.env.example | 1 +
 src/api/index.ts       | 3 ++-
 src/index.ts           | 2 +-
 5 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 api.env.example
 create mode 100644 bot.env.example
 create mode 100644 dashboard/.env.example

diff --git a/api.env.example b/api.env.example
new file mode 100644
index 00000000..5a003966
--- /dev/null
+++ b/api.env.example
@@ -0,0 +1,9 @@
+PORT=
+CLIENT_ID=
+CLIENT_SECRET=
+OAUTH_CALLBACK_URL=
+DASHBOARD_URL=
+DB_HOST=
+DB_USER=
+DB_PASSWORD=
+DB_DATABASE=
diff --git a/bot.env.example b/bot.env.example
new file mode 100644
index 00000000..8a2956a3
--- /dev/null
+++ b/bot.env.example
@@ -0,0 +1,5 @@
+TOKEN=
+DB_HOST=
+DB_USER=
+DB_PASSWORD=
+DB_DATABASE=
diff --git a/dashboard/.env.example b/dashboard/.env.example
new file mode 100644
index 00000000..fb6be76e
--- /dev/null
+++ b/dashboard/.env.example
@@ -0,0 +1 @@
+API_URL=
diff --git a/src/api/index.ts b/src/api/index.ts
index c2de62b3..29da96ed 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,6 +1,6 @@
 import { error, notFound } from "./responses";
 
-require("dotenv").config();
+require("dotenv").config({ path: path.resolve(__dirname, "..", "..", "api.env") });
 
 import express from "express";
 import cors from "cors";
@@ -8,6 +8,7 @@ import { initAuth } from "./auth";
 import { initGuildsAPI } from "./guilds";
 import { initArchives } from "./archives";
 import { connect } from "../data/db";
+import path from "path";
 
 console.log("Connecting to database...");
 connect().then(() => {
diff --git a/src/index.ts b/src/index.ts
index d2e88fbe..ae56d20f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -12,7 +12,7 @@ import DiscordHTTPError from "eris/lib/errors/DiscordHTTPError"; // tslint:disab
 
 import { Configs } from "./data/Configs";
 
-require("dotenv").config();
+require("dotenv").config({ path: path.resolve(__dirname, "..", "bot.env") });
 
 // Error handling
 let recentPluginErrors = 0;