-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
37 lines (29 loc) · 1.17 KB
/
app.js
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
// Importing required external npm packages
const express = require('express');
const hbs = require('hbs');
// Importing node internal package
const path = require('path');
// Importing custom modules
const userAuthRoutes = require('./routes/auth-api-routes');
const staticPageRoutes = require('./routes/static-page-routes');
const ratingRoutes = require('./routes/rating-api-routes');
require('./models/db/mongodb-connector');
// Defining path used by express
const publicDirPath = path.join(__dirname, './public');
const viewsDirPath = path.join(__dirname, './views/main-views');
const partialsDirPath = path.join(__dirname, './views/partials');
// Declaring port number
const PORT = process.env.PORT || 3000;
const app = express();
// Setting up handlebars and views
app.set('view engine', 'hbs');
app.set('views', viewsDirPath);
hbs.registerPartials(partialsDirPath);
app.use(express.static(publicDirPath));
app.use(express.json());
app.use('/', staticPageRoutes);
app.use('/userAuth', userAuthRoutes);
app.use('/ratingRoute', ratingRoutes);
app.listen(PORT, () => {
console.log("Server is up and running at -> http://localhost:" + PORT);
});