-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (62 loc) · 2.55 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
* Feel free to remove this comment block and all other comments after pulling.
* They're for information purposes only.
*
* This layout is provided to you for an easy and quick setup to either pull
* or use to correct yours after working at least 1 hour on Team Activity 02.
* Throughout the course, we'll be using Express.js for our view engines.
* However, feel free to use pug or handlebars ('with extension hbs'). You will
* need to make sure you install them beforehand according to the reading from
* Udemy course.
* IMPORTANT: Make sure to run "npm install" in your root before "npm start"
*******************************************************************************/
// Our initial setup (package requires, port number setup)
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const PORT = process.env.PORT || 5000; // So we can run on heroku || (OR) localhost:5000
const app = express();
// Route setup. You can implement more in the future!
// Routes for Team Activities
const ta01Routes = require('./routes/ta01');
const ta02Routes = require('./routes/ta02');
const ta03Routes = require('./routes/ta03');
const ta04Routes = require('./routes/ta04');
const ta05Routes = require('./routes/ta05');
const ta06Routes = require('./routes/ta06');
const ta07Routes = require('./routes/ta07');
// Routes for Prove Assignments
const pa01Routes = require('./routes/pa01');
const pa02Routes = require('./routes/pa02');
const pa03Routes = require('./routes/pa03');
const pa08Routes = require('./routes/pa08');
app
.use(express.static(path.join(__dirname, 'public')))
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
.use(bodyParser({ extended: false })) // For parsing the body of a POST
// Team Activities
.use('/ta01', ta01Routes)
.use('/ta02', ta02Routes)
.use('/ta03', ta03Routes)
.use('/ta04', ta04Routes)
.use('/ta05', ta05Routes)
.use('/ta06', ta06Routes)
.use('/ta07', ta07Routes)
// Prove Assignments
.use('/pa01', pa01Routes)
.use('/pa02', pa02Routes)
.use('/pa03', pa03Routes)
.use('/pa08', pa08Routes)
.get('/', (req, res, next) => {
// This is the primary index, always handled last.
res.render('pages/index', {
title: 'Welcome to my CSE341 repo',
path: '/',
});
})
.use((req, res, next) => {
// 404 page
res.render('pages/404', { title: '404 - Page Not Found', path: req.url });
})
.listen(PORT, () => console.log(`Listening on ${PORT}`));