summaryrefslogtreecommitdiffstats
path: root/app.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /app.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'app.js')
-rwxr-xr-xapp.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/app.js b/app.js
new file mode 100755
index 0000000..21a798c
--- /dev/null
+++ b/app.js
@@ -0,0 +1,25 @@
+const path = require("path");
+const express = require("express");
+require('./server/db/mongoose');
+const userRoutes = require('./server/routes/user');
+const auth = require('./server/middleware/auth');
+
+const app = express();
+const port = process.env.PORT || 3000;
+
+app.use(express.json());
+
+app.use('/api/user/', userRoutes);
+
+app.use('/admin/', auth, express.static(path.join(__dirname, 'client/admin')));
+
+app.use('/login/', express.static(path.join(__dirname, 'client/login')));
+
+app.use('/', express.static(path.join(__dirname, 'client/public')));
+
+app.get('*', (req, res) => res.redirect('/'));
+
+app.listen(port, () => {
+ console.log("Server is up on port " + port + ".");
+});
+