Last active
July 8, 2020 10:24
-
-
Save JosephLivengood/338a9c5a326923c3826a666d430e65c3 to your computer and use it in GitHub Desktop.
FCC Advanced Node and Express Checkpoint 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const fccTesting = require('./freeCodeCamp/fcctesting.js'); | |
const session = require('express-session'); | |
const passport = require('passport'); | |
const app = express(); | |
fccTesting(app); //For FCC testing purposes | |
app.use('/public', express.static(process.cwd() + '/public')); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.set('view engine', 'pug') | |
app.use(session({ | |
secret: process.env.SESSION_SECRET, | |
resave: true, | |
saveUninitialized: true, | |
})); | |
app.use(passport.initialize()); | |
app.use(passport.session()); | |
app.route('/') | |
.get((req, res) => { | |
res.render(process.cwd() + '/views/pug/index', {title: 'Hello', message: 'Please login'}); | |
}); | |
app.listen(process.env.PORT || 3000, () => { | |
console.log("Listening on port " + process.env.PORT); | |
}); |
Thanks, Joseph!
Maybe worth mentioning that
SESSION_SECRET=RANDOM_STUFF_12345
goes into the
.env
file of your project. I'm saying that because I struggled mainly with the syntax where no quotes are needed for the assigned value but no white spaces are allowed as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you stuck with the middleware exercise:
ISSUE https://github.com/freeCodeCamp/boilerplate-advancednode/issues/3