aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-08-02 12:06:56 -0400
committerAndrew Lee <alee14498@gmail.com>2019-08-02 12:06:56 -0400
commitf7c360592b6c2ef24b033280aa977a894349476a (patch)
treed057e242caccb73f02ec37c3693317a638fb356a /app.js
parentab197dc41a884902625aff031cf0df089b8065b6 (diff)
downloadalp-website-f7c360592b6c2ef24b033280aa977a894349476a.tar.gz
alp-website-f7c360592b6c2ef24b033280aa977a894349476a.tar.bz2
alp-website-f7c360592b6c2ef24b033280aa977a894349476a.zip
Finally making some progress on the website
Diffstat (limited to 'app.js')
-rw-r--r--app.js58
1 files changed, 43 insertions, 15 deletions
diff --git a/app.js b/app.js
index 8d1024a..b7a6820 100644
--- a/app.js
+++ b/app.js
@@ -18,11 +18,15 @@
**************************************/
const express = require('express');
+const app = express();
const moment = require('moment');
-let app = express();
-const config = require("./config.json")
-const webhook = require("webhook-discord")
-const Hook = new webhook.Webhook(config.durl)
+const readline = require("readline");
+const path = require("path");
+const config = require("./config.json");
+const webhook = require("webhook-discord");
+const Hook = new webhook.Webhook(config.durl);
+
+const port = 4000;
const logger = (req, res, next) => {
console.log(
@@ -33,22 +37,46 @@ const logger = (req, res, next) => {
next();
};
-console.log("Starting up Website...")
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout
+ });
+
+ rl.on("line", (input) => {
+ switch (input) {
+ case "clear":
+ console.clear();
+ break;
+ case "exit":
+ async function exitWebsite() {
+ console.log("[i] Closing website...");
+ await Hook.info("Alee Productions Website","Website is shutting down...");
+ process.exit(0);
+ }
+ exitWebsite();
+ break;
+ default:
+ console.log("[X] Error: Command not found. Use clear or exit.");
+ break;
+ }
+ });
+
+console.log("[i] Starting up Website...")
app.set('view engine', 'ejs');
+app.set("views", path.join(__dirname, "views"));
+app.use(express.static(path.join(__dirname, "public")));
+
app.use(logger)
-app.get('/', (req, res) => {
- res.render('index', {title: 'Alee Production Website'});
-});
+app.use("/", require("./routes/index"));
-app.get('/', function (req, res) {
- Hook.success("Alee Productions Website", Error)
- throw new Error('BROKEN') // Express will catch this on its own.
- })
+app.use((req, res) => {
+ res.status(404).render("404", {title: "404 | Alee Productions"});
+});
-app.listen(4000, () => {
+app.listen(port, () => {
//Hook.success("Alee Productions Website","Website has been loaded!")
-console.log('Website listening on port 4000!'
-)}); \ No newline at end of file
+console.log(`[>] Website listening on port ${port}!`)
+}); \ No newline at end of file