diff --git a/app.js b/app.js index 7ec44f3..647eb25 100644 --- a/app.js +++ b/app.js @@ -1,29 +1,47 @@ //Importing npm packages + const express = require("express"); + const http = require("http"); + const cookieParser = require("cookie-parser"); + const cookieSession = require("cookie-session"); + const bodyParser = require("body-parser"); + const methodOverride = require('method-override'); + const passport = require("passport"); + const keys = require("./config/keys"); + const socketio = require("socket.io"); + const formatMessage = require('./utils/messages'); + const moment = require("moment"); + + //Importing MongoDB models + require("./db/mongoose"); const User = require("./models/User"); const webScraper = require("./db/webScraper"); + //Importing Routes + const user = require("./routes/user"); const auth = require("./routes/auth"); const friend = require("./routes/friend"); + //Variables const port = process.env.PORT||3000; const app = express(); + const server=http.createServer(app); const io = socketio(server); @@ -62,6 +80,7 @@ app.get("/",(req,res)=>{ }); }else{ User.findOne({email:req.user.email},(err,user)=>{ + // console.log(err) if(err) Error(err); if(user){ res.redirect("/user/dashboard"); @@ -71,6 +90,7 @@ app.get("/",(req,res)=>{ }); +// new web socket connection io.on('connection',(socket)=>{ @@ -79,12 +99,12 @@ io.on('connection',(socket)=>{ // Runs when user joins room socket.on('joinRoom',({user_id})=>{ socket.join(user_id); + // console.log(user_id) console.log("Room Joined"); }); - // Listen for chat message + // Listen for the chat message socket.on('chatMessage',({msg,friend_id,user_id})=>{ - User.findOne({_id:user_id},async(err,user)=>{ User.findOne({_id:friend_id},async (err,friend)=>{ @@ -113,8 +133,9 @@ io.on('connection',(socket)=>{ await friend.save(); } }); - + // messaging to a friend io.to(user_id).emit('message',formatMessage(user_id,msg,friend_id)); + io.to(friend_id).emit('message',formatMessage(user_id,msg,user_id)); }); }); diff --git a/assets/css/hackathon.css b/assets/css/hackathon.css index aa02220..d9cfcc7 100644 --- a/assets/css/hackathon.css +++ b/assets/css/hackathon.css @@ -19,7 +19,7 @@ } .back-crcle{ font-size: medium; - color: #fff; + color: #ffffff; position: relative; display: flex; justify-content: center; @@ -33,7 +33,7 @@ .back-crcle:hover{ transform: scale(1.1); transition: 0.25s ease; -color: #fff; +color: #ffffff; } .underline{ height: 2px; @@ -52,7 +52,7 @@ color: #fff; margin-top:-100px ; } .mn p{ - color: #FFF !important; font-size: 27px;font-family: 'Raleway', sans-serif; + color: #FFFFFF !important; font-size: 27px;font-family: 'Raleway', sans-serif; } .usp{ display: flex; @@ -82,7 +82,7 @@ color: #fff; justify-content: center; } .soc-icons{ - color: #fff; + color: #ffffff; font-size: xx-large; } .soc-icons i{ @@ -234,19 +234,7 @@ color: #fff; .form-control{ border: 1px solid #23232321 !important; } -.chat-container{ - background: rgb(8,25,45); -background: -moz-linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); -background: -webkit-linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); -background: linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); -filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#08192d",endColorstr="#d7dbd6",GradientType=1); - height: 100vh; - width: 100vw; - display: flex; - justify-content: center; - align-items: center; - overflow: hidden; -} + .chat-total{ background-color: #fff; width: 90vw; @@ -285,6 +273,19 @@ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#08192d",endCo .chat-form input{ width: 92%; } +.chat-container{ + background: rgb(8,25,45); +background: -moz-linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); +background: -webkit-linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); +background: linear-gradient(180deg, rgba(8,25,45,1) 0%, rgba(65,78,93,1) 20%, rgba(215,219,214,1) 20%, rgba(215,219,214,1) 100%); +filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#08192d",endColorstr="#d7dbd6",GradientType=1); + height: 100vh; + width: 100vw; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; +} .heading { diff --git a/models/Hackathon.js b/models/Hackathon.js index 956125d..0ce5dd3 100644 --- a/models/Hackathon.js +++ b/models/Hackathon.js @@ -1,27 +1,35 @@ +// model for each hackathon + const mongoose = require("mongoose"); const HackSchema = new mongoose.Schema({ + title: { type: String, trim: true, required: true, }, + start_date: { type: Date, required: true, }, + end_date: { type: Date, required: true, }, + link: { type: String, trim: true, }, + finished:{ type:Boolean, required: true }, + participants: [{ type: mongoose.Schema.Types.ObjectId, ref: "User" }], }); diff --git a/models/Suggestion.js b/models/Suggestion.js index e8ede0f..6804c2a 100644 --- a/models/Suggestion.js +++ b/models/Suggestion.js @@ -1,21 +1,25 @@ const mongoose = require("mongoose"); const SuggestionSchema = new mongoose.Schema({ + name: { type: String, trim: true, required: true, }, + email: { type: String, trim: true, required: true, }, + subject: { type: String, trim: true, required: true, }, + message:{ type: String, trim:true, diff --git a/models/User.js b/models/User.js index 2fa0fa3..86f06ee 100644 --- a/models/User.js +++ b/models/User.js @@ -1,21 +1,28 @@ +// model for a particular user + const mongoose = require("mongoose"); const UserSchema = new mongoose.Schema({ + accessToken: [String], + name: { type: String, trim: true, required: true }, + bio: { type: String, trim: true }, + googleId:{ type:String, trim:true, required:true }, + email: { type: String, trim: true, @@ -25,22 +32,28 @@ const UserSchema = new mongoose.Schema({ type: String, trim: true }, + contact:{ type:Number, trim:true }, + skills:{ type:[String] }, + currentHacks:{ type: [{ type: mongoose.Schema.Types.ObjectId, ref: "Hack" }] }, + github:{ type:String }, + linkedin:{ type:String }, + friends:[{ friend_id:{ type:String