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('socket.io')(http)
const cors = require('cors')
app.use(cors())
fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(cookieParser());
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,
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 socket.io code
io.on('connection', socket => {
console.log('A user has connected')
})
//end socket.io 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'
$('form').submit(function(){
var messageToSend = $('#m').val();
//send message to server here?
$('#m').val('');
return false; // prevent form submit from refreshing page
});
});
Any help would be greatly appreciated.