The continuing saga of Advanced Node and Express - Set up the Environment

I’m having a terrible time trying to pass the tests for this particular challenge. I’ve been through all the suggestions made in a previous forum post on this subject, all to no avail. Perhaps the cloud can help me think this through. There is very little I am asked to do in this particular challenge, but it seems to be giving a hard time to anyone who encounters it.

Here is a link to the Glitch repo.

Here is my current code for the server.js file:

'use strict';

const express     = require('express');
const session     = require('express-session');
const bodyParser  = require('body-parser');
const fccTesting  = require('./freeCodeCamp/fcctesting.js');
const auth        = require('./app/auth.js');
const routes      = require('./app/routes.js');
const mongo       = require('mongodb').MongoClient;
const passport    = require('passport');
const cookieParser= require('cookie-parser')
const app         = express();
const http        = require('http').Server(app);
const sessionStore= new session.MemoryStore();
const io = require('')(http)
const cors = require('cors')


fccTesting(app); //For FCC testing purposes

app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'pug')

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,
  key: 'express.sid',
  store: sessionStore,

mongo.connect(process.env.DATABASE, (err, db) => {
    if(err) console.log('Database error: ' + err);
    auth(app, db);
    routes(app, db);
    http.listen(process.env.PORT || 3000);

    //start code  

  io.on('connection', socket => {
    console.log('A user has connected')

    //end code

And here is my code from the public/client.js file:

$( document ).ready(function() {
  /*global io*/
  var socket = io()
  // Form submittion with new message in field with id 'm'
    var messageToSend = $('#m').val();
    //send message to server here?
    return false; // prevent form submit from refreshing page

Any help would be greatly appreciated.


Solved it! I hadn’t completely copied all the code from the .env file of a previous Glitch project. I swear, these advanced Node challenges are very poorly written.


Yes.Same here.Same comment.

Same problem here. It’s such an easy fix to just add a few preliminary setup steps in the documentation as you transition from each new glitch starter project, if we need to use previous code, just state that.