diff --git a/.env.example b/.env.example index 7e32519..adc4dd9 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,5 @@ DB_HOST=127.0.0.1 DB_PORT=3306 SESSION_SECRET=secretkeyhere ADMIN_USERNAME=admin -ADMIN_PASSWORD=admin \ No newline at end of file +ADMIN_PASSWORD=admin +INTERNAL_PORT=3000 \ No newline at end of file diff --git a/app.js b/app.js index b401938..f352bf7 100644 --- a/app.js +++ b/app.js @@ -20,8 +20,8 @@ app.use(session({ })); const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, { - host: process.env.DB_HOST || '127.0.0.1', - port: process.env.DB_PORT || 3306, + host: process.env.DB_HOST || '127.0.0.1', // pulls from .env or defaults to localhost + port: process.env.DB_PORT || 3306, // pulls from .env or defaults to 3306 dialect: 'mysql' }); @@ -40,10 +40,9 @@ const Request = sequelize.define('Request', { } }); -// Sync models +// Sync DB models sequelize.sync(); -// Routes app.get('/', (req, res) => { res.render('index', { currentPage: 'home' }); }); @@ -70,6 +69,9 @@ app.get('/privacy', (req, res) => { res.render('privacy', { currentPage: 'privacy' }); }); +// Guide routes +// TODO: Improve how guides are routed to be simpler + app.get('/guides', (req, res) => { res.render('guides', { currentPage: 'guides' }); }); @@ -135,11 +137,13 @@ function checkAdminAuth(req, res, next) { } } +// Admin routes + app.get('/admin', (req, res) => { if (req.session.admin) { return res.redirect('/admin/dashboard'); } - res.render('admin-login', { currentPage: 'admin', error: null }); + res.render('admin/login', { currentPage: 'admin', error: null }); }); app.post('/admin', (req, res) => { @@ -148,13 +152,13 @@ app.post('/admin', (req, res) => { req.session.admin = true; res.redirect('/admin/dashboard'); } else { - res.render('admin-login', { error: 'An error occurred.' }); + res.render('admin/login', { error: 'An error occurred.' }); } }); app.get('/admin/dashboard', checkAdminAuth, async (req, res) => { const requests = await Request.findAll(); - res.render('admin-dash', { requests, currentPage: 'admin' }); + res.render('admin/dash', { requests, currentPage: 'admin' }); }); app.post('/admin/update-status', checkAdminAuth, async (req, res) => { @@ -169,7 +173,7 @@ app.post('/admin/delete-request', checkAdminAuth, async (req, res) => { res.redirect('/admin/dashboard'); }); -// Start server on 3000 -app.listen(3000, () => { - console.log('Server started on port 3000'); +// Start server on internal port defined in .env +app.listen(process.env.INTERNAL_PORT, () => { + console.log(`Server started on port ${process.env.INTERNAL_PORT}`); }); \ No newline at end of file diff --git a/public/js/register.js b/public/js/register.js deleted file mode 100644 index f61e3b5..0000000 --- a/public/js/register.js +++ /dev/null @@ -1,9 +0,0 @@ -function validateEmail() { - const email = document.getElementById('email').value; - const regex = /^[a-zA-Z0-9.-]+$/; - if (!regex.test(email)) { - alert('An invalid email has been entered. You may only include letters, numbers, periods, and dashes. Make sure you do not include @p0ntus.com'); - return false; - } - return true; -} \ No newline at end of file diff --git a/src/admin-dash.ejs b/src/admin/dash.ejs similarity index 100% rename from src/admin-dash.ejs rename to src/admin/dash.ejs diff --git a/src/admin-login.ejs b/src/admin/login.ejs similarity index 100% rename from src/admin-login.ejs rename to src/admin/login.ejs diff --git a/src/error/email.ejs b/src/error/email.ejs index 4a503c3..c38ca8f 100644 --- a/src/error/email.ejs +++ b/src/error/email.ejs @@ -3,10 +3,15 @@ We need your email
We need an email to check your request. Please enter your p0ntus mail email address below:
- diff --git a/src/register.ejs b/src/register.ejs index 4231880..f4eb109 100644 --- a/src/register.ejs +++ b/src/register.ejs @@ -12,7 +12,7 @@ If you haven't filled out a registration requestDo not use this service for spam. It is a waste of your time. I have added protections to prevent spam, including sending quotas per hour. I will catch you before you can send a good enough amount.
-