-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (34 loc) · 1.22 KB
/
Copy pathapp.js
File metadata and controls
44 lines (34 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { urlencoded } = require('express');
const express = require('express');
const app = express();
const port = process.env.PORT || 8000;
const nav = [
{link: "/dashboard", name: "My Library"},
{link:"/books", name:"Books"},
{link: "/authors", name:"Authors"},
{link: "/admin", name:"Admin panel"},
{link: "/", name: "Log out"}
];
const booksRouter = require('./src/routes/bookRoutes')(nav);
const authorsRouter = require('./src/routes/authorRoutes')(nav);
const signupRouter = require('./src/routes/signupRoutes')(nav);
const loginRouter = require('./src/routes/loginRoutes')(nav);
const acRouter = require('./src/routes/acRoutes')(nav);
const adminRouter = require('./src/routes/adminRoutes')(nav);
app.use(express.static('./public'));
app.set('view engine', 'ejs');
app.set('views','./src/views');
app.use(urlencoded({extended:true}));
app.use('/books', booksRouter);
app.use('/authors', authorsRouter);
app.use('/signup', signupRouter);
app.use('/login', loginRouter);
app.use('/dashboard', acRouter);
app.use('/admin', adminRouter);
app.get('/', function(req, res){
res.render("index",
{
nav, title: 'Your Own Library'
});
});
app.listen(port, ()=>{console.log("Server ready at " + port)});