Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
84c19cf
Reorganized file and component structures to simplify the project. Re…
Dec 18, 2022
d3f99e0
Added working error message components to the create and join party p…
Dec 19, 2022
ab21b74
Reorganized landing, create, and join pages with chakra components. R…
Dec 19, 2022
f33f500
Remade SnackMatch logos in adobe illustrator. Began applying chakra t…
Dec 20, 2022
89c71e0
Restyled restaurant cards with different spacing and chakra badges.
Dec 22, 2022
d4e0a20
Got rid of unneccesary css styling.
Dec 22, 2022
c530e8d
Cropped images on the restaurant cards in the swiping phase. Reformat…
Dec 22, 2022
d39b1cd
Got rid of unnecessary component nesting. Deleted most unnecessary st…
Dec 23, 2022
54dd602
Implemented basic redux store for nickname and partyId information.
Dec 24, 2022
345a8ee
Implemented redux in create/join party routes. Added restaurant list …
Dec 25, 2022
b8fd445
Added isHost state variable for conditional rendering on the party page.
Dec 25, 2022
02ffbe8
Minor syntax corrections.
Dec 25, 2022
5c27fa0
Created a voteCounter stored in redux. Recommendation results now det…
Dec 25, 2022
a2d75d9
Fixed button logic and inconsistencies with restaurant card rendering…
Dec 25, 2022
605c7d7
Integrated web sockets using socket.io. Allows syncing between multip…
Jan 21, 2023
578d6c5
Removed dependencies from git control.
Jan 21, 2023
8e8da7e
Web sockets now sync the entire app flow.
Jan 23, 2023
087b87b
Added consistent styling throughout website.
Jan 26, 2023
f071334
Added option to close parties once voting begins, preventing new memb…
Jan 26, 2023
9d60170
Changed meta data in publix index file.
Jan 26, 2023
84319e6
Merge branch 'main' into post-semester
ronniebeggs Jan 26, 2023
3428295
Removed unnecessary code from production build.
Jan 26, 2023
948b440
Configured project to run with .env variables
Jan 26, 2023
56246f1
Fixing merge
Jan 26, 2023
b3d20c8
Configured backend routes for connection to cloud hosted database.
Jan 28, 2023
0a5deeb
Fixed minor mongoose issue.
Jan 28, 2023
91c9152
Upgraded websocket connection to https.
Jan 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
client/node_modules
api/node_modules
client/.pnp
client/.pnp.js

Expand All @@ -21,3 +23,5 @@ client/.env.production.local
client/npm-debug.log*
client/yarn-debug.log*
client/yarn-error.log*
.env

32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +0,0 @@
# mern-tailwind-vivid-starter
A repository of Snackmatch App files

# Getting Started
This repository contains both an Express backend (within api) and a React frontend (within client). To get started, clone the repository. Navigate to your terminal and execute the following command.

```bash
git clone https://github.com/vivid-labs/mern-tailwind-vivid-starter.git
```
In order to have a fully functional web app, you'll need to run both the frontend and the backend simultaneously.
## Starting the frontend
From the root of the repository, you'll need to enter the client folder, install the necessary dependencies, and run the app.
```bash
cd client
#If you don't already have yarn
npm install --global yarn
yarn install
yarn start
```
Navigate to localhost:3000 to see the running app. You'll notice that the Express status will state "Currently down." It will remain that way until you start the backend.

## Starting the backend
From the root of the repository, you'll need to enter the api folder, install the necessary dependencies, and run the server.
```bash
cd api
yarn install
yarn start
```
Navigate to localhost:9000/testAPI to see the results of the /testAPI route. If you refresh your localhost:3000 tab, your Express status should change.

# Styling with Vivid
Vivid lets you style with Tailwind in your browser. <kbd>Cmd</kbd>-Click (Windows: <kbd>Ctrl</kbd>) on any component to see its code. Check out [Vivid's docs](https://docs.vivid.lol) for a guide to its full functionality.
93 changes: 51 additions & 42 deletions api/app.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,68 @@
// STARTER CODE ---
var createError = require("http-errors");
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
var cors = require("cors");

// built-in router from template
var indexRouter = require("./routes/index");
// import party router
var partyRouter = require("./routes/party");
// const createError = require("http-errors");
const express = require("express");
const cors = require("cors");

const app = express();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

var app = express();
// websocket.io initialization
const https = require('https');
const { Server } = require('socket.io');
const server = https.createServer(app);
const io = new Server(server, {
cors: {
methods: ["GET", "POST"]
}
});

// PORT
const PORT = process.env.PORT || 9000;
var partyRouter = require("./routes/party");
app.use("/party", partyRouter);

// Initiate Mongo Server --- uncomment when db is setup
const InitiateMongoServer = require("./config/db");
InitiateMongoServer();

// STARTER CODE --- view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "jade");
require('dotenv').config();
const PORT = process.env.PORT;

app.use(cors());
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
app.get("/", (req, res) => {
res.send("this is the test route to make sure server is working")
})

app.use("/", indexRouter);
// new party router below
app.use("/party", partyRouter);
io.on('connection', (socket) => {
// console.log(`a user connected: ${socket.id}`);

// STARTER CODE --- catch 404 and forward to error handler
app.use(function (req, res, next) {
next(createError(404));
});
socket.on('party-creation', (data) => {
socket.join(data.partyId);
});

socket.on('party-connection', (data) => {
socket.join(data.partyId);
socket.to(data.partyId).emit('new-connection');
});

socket.on('start-request', (data) => {
socket.in(data.partyId).emit('start-matching');
});

socket.on('finish-voting', (data) => {
socket.to(data.partyId).emit('other-user-finished', data.nickname);
});

// STARTER CODE --- error handler
app.use(function (err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get("env") === "development" ? err : {};
socket.on('navigate-to-results', (data) => {
socket.in(data.partyId).emit('finish-matching');
});

// render the error page
res.status(err.status || 500);
res.render("error");
// executed when a user disconnects from the server
socket.on('disconnect', () => {
// console.log('A user disconnected');
});
});

// initiates the server on the provided port
app.listen(PORT, (req, res) => {
console.log(`Server Started at http://localhost:${PORT}`);
server.listen(PORT, (req, res) => {
console.log(`Server hosted on port: ${PORT}`);
});

module.exports = app;
86 changes: 0 additions & 86 deletions api/bin/www

This file was deleted.

15 changes: 9 additions & 6 deletions api/config/db.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const mongoose = require("mongoose");
const mongoose = require('mongoose');
mongoose.set('strictQuery', false);
require('dotenv').config();

// Replace this with your MONGOURI.
const MONGOURI = "mongodb://127.0.0.1:27017/snack-match-tests";
const MONGOURI = process.env.MONGODB_URI;
const InitiateMongoServer = async () => {
try {
// attempts a connection to the database
await mongoose.connect(MONGOURI, {
useNewUrlParser: true,
});
// console message indicates that a proper connection has been made
console.log("Connected to DB !!");
dbName: 'gameData',
useNewUrlParser: true,
});
// console message indicates that a proper connection has been made
console.log("Connected to DB !!");
} catch (error) {
console.log(error);
throw error;
Expand Down
11 changes: 10 additions & 1 deletion api/models/PartySchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const PartySchema = mongoose.Schema({
required: true,
},
// list containing all party members (catch if exceeds maximum party size)
partyMembers: {
memberList: {
type: Array,
required: true,
},
Expand All @@ -22,6 +22,15 @@ const PartySchema = mongoose.Schema({
type: Array,
required: true,
},
isClosed: {
type: Boolean,
default: false,
},
// restaurant match results
matchResults: {
type: Array,
default: [],
},
// provided in default scheme
// could be used as another parameter for authentification?
createdAt: {
Expand Down
2 changes: 1 addition & 1 deletion api/models/UserSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const UserSchema = mongoose.Schema({
// list containing all restaurants taken from the party schema
voteCounter: {
type: Object,
required: true
required: true,
},
// provided in default scheme
// could be used as another parameter for authentification?
Expand Down
1 change: 0 additions & 1 deletion api/node_modules/.bin/acorn

This file was deleted.

1 change: 0 additions & 1 deletion api/node_modules/.bin/cleancss

This file was deleted.

1 change: 0 additions & 1 deletion api/node_modules/.bin/jade

This file was deleted.

1 change: 0 additions & 1 deletion api/node_modules/.bin/mime

This file was deleted.

1 change: 0 additions & 1 deletion api/node_modules/.bin/mkdirp

This file was deleted.

1 change: 0 additions & 1 deletion api/node_modules/.bin/uglifyjs

This file was deleted.

Loading