Skip to content

Commit

Permalink
Latest Update
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiartaputra committed Feb 9, 2018
0 parents commit d52fe63
Show file tree
Hide file tree
Showing 4,446 changed files with 678,762 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sports-hub
38 changes: 38 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const express = require('express')
const Model = require('./models')
const session = require('express-session')
const favIcon = require('express-favicon')
const app = express()
const bodyParser = require('body-parser')

const authLogin = require('./helpers/authLogin')
const Person = require('./routes/person');
const Agenda = require('./routes/agenda');
const SportList = require('./routes/sport_list');
const Login = require('./routes/login');
const SignUp = require('./routes/signUp');
const Events = require('./routes/event')
const Logout = require('./routes/logout');

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(session({
secret: 'key'
}))

app.set('views', './views')
app.set('view engine', 'ejs')

app.get('/', authLogin.checkLogin, function (req, res) {
res.render('home')
})

app.use('/login', Login)
app.use('/signUp', SignUp)
app.use('/logout', authLogin.checkLoginUser, Logout)
app.use('/people', authLogin.checkLogin, Person)
app.use('/agendas', authLogin.checkLogin, Agenda)
app.use('/sport_lists', authLogin.checkLogin, SportList)
app.use('/events', authLogin.checkLoginUser, Events)

app.listen(3000, console.log(`Ready.. Set.. GO!`))
9 changes: 9 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"development": {
"username": "saibmmag",
"password": "I-by-vjMbyaHQzyfykhhbr3SP4u6zeTv",
"database": "saibmmag",
"host": "baasu.db.elephantsql.com",
"dialect": "postgres"
}
}
25 changes: 25 additions & 0 deletions helpers/authLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function checkLogin(req, res, next) {
let isLogin = req.session.isLogin
// let isLogin = true
if (isLogin) {
next()
} else {
if (req.session.isLoginUser) {
res.redirect('/events')
} else {
res.redirect('/login')
}
}
}

function checkLoginUser(req, res, next) {
let isLoginUser = req.session.isLoginUser
// let isLoginUser = true
if (isLoginUser) {
next()
} else {
res.redirect('/login')
}
}

module.exports = {checkLogin, checkLoginUser};
381 changes: 381 additions & 0 deletions helpers/email-full-booked.js

Large diffs are not rendered by default.

370 changes: 370 additions & 0 deletions helpers/email-host.js

Large diffs are not rendered by default.

370 changes: 370 additions & 0 deletions helpers/email-join.js

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions helpers/send_email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'
const api_key = 'key-25fc0a73025b3329627740cc582f9021';
const domain = 'sandboxb33efd7116d9434ab04cbd7bc49c1833.mailgun.org';
const mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
const emailJoin = require('./email-join');
const emailFull = require('./email-full-booked');

function sendEmailToUser(person,agenda) {
var data = {
from: 'Sports Hub Fuadhi <[email protected]>',
to: person.email,
subject: 'Hello From Sports Hub!!',
html: emailFull(person,agenda)
};
mailgun.messages().send(data, function (error, body) {
console.log('body ..',body);
console.log('error ..',error);
});
}

function sendEmailToHost(person,agenda) {
var data = {
from: 'Sports Hub Fuadhi <[email protected]>',
to: person.email,
subject: 'Hello From Sports Hub!!',
text: `Congrats! Your Hosted Event ${agenda.name} is fully booked`
};
mailgun.messages().send(data, function (error, body) {
console.log('body ..',body);
console.log('error ..',error);
});
}

function sendEmailWhenJoin(person,agenda) {
var data = {
from: 'Sports Hub Fuadhi <[email protected]>',
to: person.email,
subject: 'Hello From Sports Hub!!',
html: emailJoin(person, agenda)
};
mailgun.messages().send(data, function (error, body) {
console.log('body ..',body);
console.log('error ..',error);
});
}

module.exports = {sendEmailToUser: sendEmailToUser, sendEmailToHost: sendEmailToHost, sendEmailWhenJoin: sendEmailWhenJoin};
20 changes: 20 additions & 0 deletions mailgun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


// var mailgun = new Mailgun({apiKey: api_key, domain: domain});

// var members = [
// {
// address: "[email protected]"
// }
// ];
// //For the sake of this tutorial you need to create a mailing list on Mailgun.com/cp/lists and put its address below
// mailgun.lists('[email protected]').members().add({ members: members, subscribed: true }, function (err, body) {
// console.log('bodyyyyyy',body);
// console.log('errrrrrrr',err);
// if (err) {
// console.log("Error - check console");
// }
// else {
// console.log("Added to mailing list");
// }
// });
39 changes: 39 additions & 0 deletions migrations/20180126133539-create-person.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('People', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
location: {
type: Sequelize.STRING
},
email: {
type: Sequelize.STRING
},
sport_interest: {
type: Sequelize.STRING
},
phone: {
type: Sequelize.STRING
},
createdAt: {
allowNull: true,
type: Sequelize.DATE
},
updatedAt: {
allowNull: true,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('People');
}
};
42 changes: 42 additions & 0 deletions migrations/20180126134006-create-agenda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Agendas', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
place: {
type: Sequelize.STRING
},
date: {
type: Sequelize.STRING
},
time: {
type: Sequelize.STRING
},
max_player: {
type: Sequelize.INTEGER
},
SportId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: true,
type: Sequelize.DATE
},
updatedAt: {
allowNull: true,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Agendas');
}
};
30 changes: 30 additions & 0 deletions migrations/20180126135911-create-people-agendas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('PeopleAgendas', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
PeopleId: {
type: Sequelize.INTEGER
},
AgendaId: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: true,
type: Sequelize.DATE
},
updatedAt: {
allowNull: true,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('PeopleAgendas');
}
};
27 changes: 27 additions & 0 deletions migrations/20180126144057-create-sport-lists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('SportLists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
createdAt: {
allowNull: true,
type: Sequelize.DATE
},
updatedAt: {
allowNull: true,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('SportLists');
}
};
18 changes: 18 additions & 0 deletions migrations/20180129063046-change_sportId_column_at_agenda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {

return queryInterface.renameColumn('Agendas', 'SportId', 'SportListId')
},

down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
}
};
24 changes: 24 additions & 0 deletions migrations/20180129074114-add-column-password-at-people.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
/*
Add altering commands here.
Return a promise to correctly handle asynchronicity.
Example:
*/
return queryInterface.addColumn('People', 'password', Sequelize.STRING)
},

down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('People', 'password', Sequelize.STRING)
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
}
};
24 changes: 24 additions & 0 deletions migrations/20180129105422-rename-column-peopleId-to-PersonId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
/*
Add altering commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
return queryInterface.renameColumn('PeopleAgendas', 'PeopleId', 'PersonId')
},

down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
}
};
25 changes: 25 additions & 0 deletions migrations/20180130083846-add-column-host-id-at-table-agendas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
/*
Add altering commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
return queryInterface.addColumn('Agendas', 'hostId', Sequelize.INTEGER)
},

down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Agendas', 'hostId', Sequelize.INTEGER)
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
}
};
11 changes: 11 additions & 0 deletions migrations/20180201063715-add-column-on-Agenda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('Agendas','bookingId',Sequelize.INTEGER);
},

down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Agendas','bookingId',Sequelize.INTEGER);
}
};
Loading

0 comments on commit d52fe63

Please sign in to comment.