-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (23 loc) · 1.02 KB
/
app.js
File metadata and controls
40 lines (23 loc) · 1.02 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
const path=require('path'); // node core module.
const express=require('express'); //prod-dependencies
const bodyParser=require('body-parser'); //prod-dependencies.
const userRouter=require('./routes/user');
const errorController=require('./controllers/errorController');
const app=express();
// Using Templating-Engine to Return Dynamic Data to Users.Exposing the Views directory as well.
app.set('view engine','ejs');
app.set('views','views');
// Middleware to Parse Incoming Request.
app.use(bodyParser.urlencoded({extended:false}));
// Middleware to Serve Static Files.Exposing the Public directory.
app.use(express.static(path.join(__dirname,'public')));
// All routes starting with /user
app.use('/user',userRouter.userRouter);
// Default - Landing Page Route
app.get('/',(req,res,next)=>{
res.render('landingPage.ejs',{pageTitle:'My-Notes-App',pageHeading:'Welcome to My-Notes-App'});
})
// All routes starting with /.
app.use('/',errorController.get404Page);
app.listen(5000);
// listening on Port 3000