Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ coverage/*
coverage/
/coverage
.env
config
174 changes: 31 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,157 +1,45 @@
# CSGO
Event Planner Application
# Event Planner
Create Events with specified timing, location, catering, and pay for it online.

#How to run ?
![](https://img.techpowerup.org/200526/event-planner.png)

To run the App, follow the following steps:
1. change the directory to /backend
2. run the command **node index**
3. open another terminal
4. change the directory to /client
5. run the command **npm start**
# Features
* Create a new Event and specify all the details through the web interface
* Create a new location (through <code>/api/places</code>)
* Create a new catering (through <code>/api/caterings</code>)
* Pay for any event you created online

#Dependencies
# Getting Started
* Clone the repo
* Run <code> npm install</code> once in the *backend* folder, and once in the *client* folder
* Run <code> npm run dev</code> in the *backend* folder to run both the frontend and backend simultaneously

To install the dependencies please run **npm i** once backend folder and another in client folder
Backend Dependencies:
# About the app
* This app is written using the MERN stack
* The main components to the app are:
* Backend (Database Schema and routes)
* Frontend (React Components)
* Authentication (using JWT token)
* Docker (Explained below)

1. Axios
2. bycrypt
3. passport
4. express
5. nodemailer
6. stripe
7. mongoose
![](https://i.ibb.co/8BZ31y6/MERN.jpg "MERN Stack")
# Docker

Frontend Dependencies:
* The Backend and Forntend are Dockerized and can be run through **docker-compose up** but you have to make sure that you have docker installed.

1. Axios
2. React libraries
3. particles-bg
* You can also build through **docker-compose build**

#CONFIG
* You can stop running **docker-compose down**

1) create *config* folder
2) create 4 files:
- keys.js
- keys_dev.js
- keys_prod.js
- passport.js

Example for *keys.js*:
* The backend runs on port 5000 and the Frontend runs on port 3000

########################
* *docker-compose.yml* runs the two docker files(one for backend and another for frontend)

if (process.env.NODE_ENV === 'production') {
* The Docker file for backend runs commands **npm i** to install dependencies and **node index** to run the backend in *./Backend* directory

module.exports = require('./keys_prod')

}
* The Docker file for frontend runs commands **npm i** to install dependencies and **npm start** to run the front in *./client* directory

else {

module.exports = require('./keys_dev')

}

########################

Example for *keys_dev.js*:

########################

module.exports = {

mongoURI: *The Url extracted from atlas*,

secretOrKey: *Any Hashing Key*,

SSK: *The Sercret Key extracted from stipe*,

Email: *The Gmail used for sending emails*,

Pass: *The Gmail Password*

}

########################

Example for *keys_prod.js*:

########################

module.exports = {

*Mongo variable used in keys_dev.js*: process.env.MONGO_URI,

*Secret key variable used in keys_dev.js*:(process.env.STRIPE_SECRET_KEY),

*Email variable used in keys_dev.js*:(process.env.Email),

*Password variable used in keys_dev.js*:(process.env.Pass)

}

########################

Example for *passport.js*:

########################

const JwtStrategy = require('passport-jwt').Strategy

const ExtractJwt = require('passport-jwt').ExtractJwt

const mongoose = require('mongoose')

const User = mongoose.model('users')

const tokenKey = require('./keys').secretOrKey

let opts = {};

opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken()

opts.secretOrKey = tokenKey

module.exports = passport => {

passport.use(new JwtStrategy(opts, async (jwt_payload, done) => {

const currentUser = await User.findById(jwt_payload.id)

if(currentUser) return done(null,currentUser)

return done(null,false)

}))

}

########################

#Docker


The Backend and Forntend are Dockerized and can be run through **docker-compose up** but you have to make sure that you have docker installed.

You can also build through **docker-compose build**

You can stop running **docker-compose down**

The backend runs on port 5000 and the Frontend runs on port 3000

*docker-compose.yml* runs the two docker files(one for backend and another for frontend)

The Docker file for backend runs commands **npm i** to install dependencies and **node index** to run the backend in *./Backend* directory

The Docker file for frontend runs commands **npm i** to install dependencies and **npm start** to run the front in *./client* directory

#Backing Service

MongoDb: NoSQL Database.

Stripe: Online Payment method

Nodemailer: Used for sending emails.
# Further Development
* Create frontend components to allow users to create new caterings and new places
* Modify the event model to allow users to be invited to events and for users to sign up for events

1 change: 0 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ coverage/*
coverage/
/coverage
.env
config
6 changes: 6 additions & 0 deletions backend/config/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (process.env.NODE_ENV === 'production') {
module.exports = require('./keys_prod')
}
else {
module.exports = require('./keys_dev')
}
7 changes: 7 additions & 0 deletions backend/config/keys_dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
mongoURI: 'mongodb://koko:wawa@csgo-shard-00-00-w6a6k.mongodb.net:27017,csgo-shard-00-01-w6a6k.mongodb.net:27017,csgo-shard-00-02-w6a6k.mongodb.net:27017/test?ssl=true&replicaSet=CSGO-shard-0&authSource=admin&retryWrites=true&w=majority',
secretOrKey: 'verysecretkey',
SSK:'sk_test_2rMMQj3EKds9n7m9s7J6MbK4000p0HbQNu',
Email:'csgo.oza@gmail.com',
Pass:'kokowawa'
}
6 changes: 6 additions & 0 deletions backend/config/keys_prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
mongoURI: process.env.MONGO_URI,
SSK:(process.env.STRIPE_SECRET_KEY),
Email:(process.env.Email),
Pass:(process.env.Pass)
}
17 changes: 17 additions & 0 deletions backend/config/passport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const JwtStrategy = require('passport-jwt').Strategy
const ExtractJwt = require('passport-jwt').ExtractJwt
const mongoose = require('mongoose')
const User = mongoose.model('users')
const tokenKey = require('./keys').secretOrKey

let opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken()
opts.secretOrKey = tokenKey

module.exports = passport => {
passport.use(new JwtStrategy(opts, async (jwt_payload, done) => {
const currentUser = await User.findById(jwt_payload.id)
if(currentUser) return done(null,currentUser)
return done(null,false)
}))
}
2 changes: 1 addition & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ app.use((req, res, next) => {
})

app.get('/', (req,res) => {
res.send(`<h1>CS GO</h1>`)
res.send(`<h1>Event Planner</h1>`)
})
app.use('/api/events', events)
app.use('/api/places', places)
Expand Down
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Event Planner",
"name": "event-planner",
"version": "1.0.0",
"description": "Event Planning Website",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"server": "nodemon index.js",
"client": "npm start --prefix client",
"client": "npm start --prefix=../client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "El-Sherif",
Expand Down
2 changes: 1 addition & 1 deletion client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand Down
1 change: 0 additions & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Login from './Components/Login';
import { BrowserRouter as Router, Route } from "react-router-dom";
import Register from './Components/Register';
import ForgetPassword from './Components/ForgetPassword'
import ReactDOM from 'react-dom'
import parseJwt from './helpers/decryptAuthToken'
import './App.css';

Expand Down
1 change: 0 additions & 1 deletion client/src/Components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Button, Card, CardDeck } from "react-bootstrap";
import { Redirect } from "react-router-dom";
import { Label, Input } from 'semantic-ui-react'
import axios from "axios";
import { Collapse } from 'reactstrap'
import ParticlesBg from "particles-bg";

class Login extends Component {
Expand Down
8 changes: 4 additions & 4 deletions client/src/Components/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ParticlesBg from "particles-bg";


function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
function validateNumber(num) {
Expand Down Expand Up @@ -51,7 +51,7 @@ class Register extends Component {
ret = "Password has to be atleast 8 characters long";
else if (req.password !== req.confirmPassword)
ret = "The repeated password doesn't match the first one"
else if (req.name.length == 0)
else if (req.name.length === 0)
ret = "Please enter your name";
else if (!validateNumber(req.phone))
ret = "Phone Number contains only digits and cannot be empty";
Expand All @@ -78,7 +78,7 @@ class Register extends Component {
, balance: 0, name: this.state.name, age: this.state.age, phone: this.state.phone, confirmPassword: this.state.confirmPassword, gender: 'Male'
};
let valid = this.validateRequest(body);
if (valid.msg == 'ok') {
if (valid.msg === 'ok') {


try {
Expand All @@ -104,7 +104,7 @@ class Register extends Component {
};
handleGender(event) {
let id = event.target.id;
if (id == 'male') {
if (id === 'male') {
document.getElementById("female").checked = false;
}
else
Expand Down
7 changes: 2 additions & 5 deletions client/src/Components/stripeBtn.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { Component, Fragment } from "react";
import React, { Component } from "react";
import StripeCheckout from "react-stripe-checkout";
import axios from "../../node_modules/axios";
const publishableKey = "pk_test_ehyd5U1bJZcul9sAObB3D8fV00XSCtZpBn";
export class stripeBtn extends Component {
constructor(props) {
super(props)
}


onToken = (token) => {
const body = {
Expand All @@ -15,7 +13,6 @@ export class stripeBtn extends Component {
}; axios
.post("http://localhost:5000/api/users/payfees", body)
.then(response => {
// console.log(111)
console.log(response);
alert("Payment Success");
window.location.reload()
Expand Down
Loading