I forgot a lot of things there, also, me when '.js' works for a router file
This commit is contained in:
parent
aa7bcee4ec
commit
f35f0ebcb1
6
index.js
6
index.js
|
@ -52,10 +52,10 @@ app.set("view engine", "ejs");
|
|||
app.set("views", "./views");
|
||||
|
||||
app.use((req, res, next) => {
|
||||
return res.send("Test 123")
|
||||
if (!dbReady) {
|
||||
return res.render('error', { error: 'Database is not ready. Please try again later.' });
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
const routersDir = path.join(__dirname, 'routes');
|
||||
|
@ -67,9 +67,7 @@ fs.readdirSync(routersDir).forEach(file => {
|
|||
}
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.redirect('/login');
|
||||
})
|
||||
|
||||
const port = process.env.APP_PORT || 8080
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
|
|
12
routes/.js
Normal file
12
routes/.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
const express = require('express');
|
||||
const db = global.db;
|
||||
const router = express.Router();
|
||||
|
||||
// GET /login
|
||||
router.get('/', (req, res) => {
|
||||
res.send("Test")
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
// I genuinely have no clue if this'll work.... but hey, it's worth a shot.
|
Loading…
Reference in a new issue