Skip to content

Commit 29f9241

Browse files
committed
added new routes, updated auth, schema, ticketing & mailing system
1 parent d1f28ee commit 29f9241

23 files changed

+1294
-292
lines changed

.env.example

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
PORT=
2-
DB_URI=
1+
PORT=5000
2+
TEST_DB_URI=
3+
PROD_DB_URI=
34
SOURCE_EMAIL=
45
SOURCE_EMAIL_APP_PASSWORD=
5-
EVENT_NAME=
6+
EVENT_NAME=
7+
JWT_SECRET=
8+
CIPHER_KEY=
9+
CIPHER_IV=
10+
CIPHER_ALGORITHM=

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
.env
3-
temp/*.pdf
3+
assets/*.png

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Event Backend
2-
NodeJS backend for official SCCSBS events
2+
NodeJS event management API for hosting online/in-person events
3+
4+
## Features
5+
- [x] Online registration
6+
- [x] Admin routes
7+
- [x] Mailing System
8+
- [x] Ticketing System
9+
- [x] User authentication
10+
- [x] QR Attendance System
11+
- [ ] Razorpay payment integration
312

413
## Built with
514
- NodeJs
@@ -8,6 +17,7 @@ NodeJS backend for official SCCSBS events
817
- Nodemailer
918
- Puppeteer
1019
- Qrcode
20+
- Crypto
1121

1222
## Installation
1323
- Create the `.env` file based on `.env.example`

utils/template.html assets/template.html

+24-16
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
.container {
1212
width: 1000px;
1313
height: 323px;
14-
margin: 9% auto;
15-
background-image: url("https://images.unsplash.com/photo-1492684223066-81342ee5ff30?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80");
16-
background-size: cover;
14+
margin: 1% auto;
15+
background-image: url({{BG_URL}});
16+
background-size: contain;
1717
border-radius: 4px;
1818
box-shadow: 0 8px 16px rgba(35, 51, 64, 0.25);
1919
}
@@ -30,29 +30,37 @@
3030
.qr-holder > img {
3131
margin-top: 20px;
3232
}
33-
.teamName,
34-
.ticket-id {
33+
.teamName {
3534
font-size: 14px;
3635
line-height: 22px;
3736
color: #230065;
3837
margin-top: 15px;
38+
word-wrap: break-word;
3939
}
40-
</style>
40+
.ticket-id {
41+
font-size: 12px;
42+
line-height: 22px;
43+
color: #230065;
44+
margin-top: 15px;
45+
}
46+
</style>
4147
</head>
4248
<body>
49+
4350
<div class="container">
44-
<div class="qr-holder">
45-
<img src="{{QR_CODE_IMAGE_PATH}}" width="120px" height="120px" />
46-
<div class="ticket-id">
47-
TICKET ID:<br/>
48-
<span style="font-size: 12px;"> {{TICKET_ID}} </span>
49-
</div>
50-
<div class="teamName">
51-
TEAM NAME:<br/>
52-
{{TEAM_NAME}}
53-
</div>
51+
<div class="qr-holder">
52+
<img src="{{QR_CODE_IMAGE_PATH}}" width="120px" height="120px" />
53+
<div class="ticket-id">
54+
TICKET ID:<br/>
55+
<span style="font-size: 12px;"> {{TICKET_ID}} </span>
56+
</div>
57+
<div class="teamName">
58+
TEAM NAME:<br/>
59+
{{TEAM_NAME}}
5460
</div>
61+
</div>
5562
</div>
63+
<div style="text-align:center"><h6><span>&copy;<span> RM - All Rights Reserved</h6><div>
5664

5765
</body>
5866
</html>

db.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const mongoose = require("mongoose");
22

3-
const DB_URI = process.env.DB_URI;
3+
const DB_URI = process.env.PROD_DB_URI;
44

55
mongoose
66
.connect(DB_URI, {

db_update.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const mongoose = require("mongoose");
2+
const Registration = require("./models/RegistrationSchema")
3+
const DB_URI = process.env.TEST_DB_URI;
4+
5+
mongoose
6+
.connect(DB_URI, {
7+
useNewUrlParser: true,
8+
useUnifiedTopology: true,
9+
})
10+
.then(async () => {
11+
12+
// add fields
13+
const res = await Registration.updateMany({}, { $set: { "team.room": "" } })
14+
15+
// delete fields
16+
// const res = await Registration.updateMany({}, { $unset: { "team.rooms": 1 }})
17+
18+
console.log(`[+] MongoDB is connected!\n`, res);
19+
})
20+
.catch((e) => {
21+
console.log(`[x] Connection failed! ${e}`);
22+
});

models/AdminSchema.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const mongoose = require("mongoose");
2+
const jwt = require("jsonwebtoken");
3+
4+
const JWT_SECRET = process.env.JWT_SECRET
5+
6+
const adminSchema = new mongoose.Schema({
7+
username: { type: String, required: true, trim: true },
8+
password: { type: String, required: true },
9+
});
10+
11+
adminSchema.methods.makeJwtToken = async () => {
12+
try{
13+
const token = jwt.sign({username: this.username}, JWT_SECRET, {expiresIn:"1d"});
14+
return token
15+
}
16+
catch(e){
17+
console.log(e);
18+
}
19+
}
20+
21+
const Admin = mongoose.model("Admin", adminSchema);
22+
23+
module.exports = Admin;
24+

models/RegistrationSchema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const registrationSchema = new mongoose.Schema({
55
teamName: { type: String, required: true, unique: true },
66
phone: { type: Number, required: true, unique: true },
77
slot: { type: String, enum: ["Slot 1", "Slot 2"] },
8+
room: String,
89
emailSent: { type: Boolean, default: false },
910
attendance: { type: Boolean, default: false },
1011
},
@@ -26,7 +27,6 @@ const registrationSchema = new mongoose.Schema({
2627
default: "pending",
2728
},
2829
totalAmount: Number,
29-
// transactionID: String
3030
},
3131
});
3232

0 commit comments

Comments
 (0)