Tell us what’s happening:
test are failing try to delete the nodes and install again but following the step from test 4 they keep failing
###Your project link(s)
solution: https://3000-freecodecam-boilerplate-xuhf289jwg6.ws-us118.gitpod.io
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Challenge Information:
Advanced Node and Express - Serialization of a User Object
How are you setting this boilerplate up in gitpod? The issue with this is the links timing out in 30 mins.
Submit your page when you think you’ve got it right. If you’re running into errors, you can check out the project completed up to this point.
Post a repo or a Gitpod snapshot as outlined on the initial challenge page.
What do you mean by nodes? Are you talking about the dependencies?
I delete the node_modules. I can post the link again https://3000-freecodecam-boilerplate-xuhf289jwg6.ws-us118.gitpod.io.
and this is the code in the server.js folder
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const { ObjectID } = require('mongodb');
const app = express();
app.set('view engine', 'pug');
app.set('views', './views/pug');
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
cookie: { secure: false }
}));
app.use(passport.initialize());
app.use(passport.session());
fccTesting(app); // For fCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.route('/').get((req, res) => {
res.render('index', { title: 'Hello', message: 'Please log in' });
});
passport.serializeUser((user, done) => {
done(null, user._id);
});
passport.deserializeUser((id, done) => {
// myDataBase.findOne({ _id: new ObjectID(id) }, (err, doc) => {
done(null, null);
//});
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});
It is working now after restarting the server
The boilerplate comes with two scripts, dev
and start
, dev
uses nodemon and will auto restart when making file changes and saving, start
will not.
You could add the --watch
flag to the start
script.
package.json
"scripts": {
"start": "node --watch server.js",
"dev": "nodemon server.js"
},
1 Like