-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
77 lines (61 loc) · 2.27 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
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
69
70
71
72
73
74
75
76
77
require('dotenv').config();
//require('./config/connection');
//require('./config/authStrategy');
const express = require('express');
const path = require('node:path');
const helmet = require('helmet');
const passport = require('passport');
const cors = require('cors');
const session = require('express-session');
const morgan = require('morgan');
const app = express();
const PORT = 4200;
// const PORT = process.env.PORT || 4200;
// Define the Routing Variable
const indexRoutes = require('./routes/indexRoutes');
//const authRoutes = require('./routes/authRoutes');
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname + '/views'));
app.use(helmet({ contentSecurityPolicy: false }));
app.use(morgan('dev'));
app.use(cors());
app.use(express.json());
app.use(express.static(path.join(__dirname + '/public')));
app.use(express.urlencoded({ extended: true }));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
}));
app.use(passport.initialize());
app.use(passport.session());
// Routing Paths
//app.use('/admin/', authRoutes);
app.use('/portfolio/', indexRoutes);
app.get('/', (request, response, next) => {
response.redirect('/portfolio/home')
});
app.get('/index-v1', (request, response, next) => {
response.render('pages/index')
});
app.get('/prev-projects', (request, response, next) => {
response.render('pages/projects')
});
const portfolioSample = {
id: 10,
title: "Complete Node Podcast",
author: "Kit Fenrir Amreik (they/she)",
audience: "students/self-learning and development",
reason: "Refactor the Node.js Podcast Index API to use in JSON based back end environment successfully using advanced back end techniques such as crypto detection, the node fetch commands and created six files only for ease and comprehension.",
technologies: "Javascript",
github: "https://github.com/Kitamreik/complete-node-pod"
}
app.get('/portfolio/10', (request, response, next) => {
response.status(200).json({success: {message: "You have successfully navigated to the entry for the tenth project."}, data: {portfolioSample}, statusCode: 200});
});
//Server
app.listen(PORT, () => {
console.log(`The server is listening on port ${PORT}`);
console.log(`http://localhost:${PORT}/`)
console.log(`Google Analytics:`);
});