Skip to content

Instantly share code, notes, and snippets.

@JosephLivengood
Last active July 8, 2020 10:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephLivengood/338a9c5a326923c3826a666d430e65c3 to your computer and use it in GitHub Desktop.
Save JosephLivengood/338a9c5a326923c3826a666d430e65c3 to your computer and use it in GitHub Desktop.
FCC Advanced Node and Express Checkpoint 1
'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);
});
Copy link

ghost commented Jun 23, 2019

If you stuck with the middleware exercise:

ISSUE https://github.com/freeCodeCamp/boilerplate-advancednode/issues/3

@HansKre
Copy link

HansKre commented May 9, 2020

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