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
31 changes: 15 additions & 16 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Services = {
log: require("./services/logger.service"),
db: require("./services/database.service"),
auth: require("./services/auth.service"),
env: require("./services/env.service")
env: require("./services/env.service"),
};

const envLoadResult = Services.env.load(path.join(__dirname, "./.env"));
Expand All @@ -31,6 +31,7 @@ const searchRouter = require("./routes/api/search");
const settingsRouter = require("./routes/api/settings");
const volunteerRouter = require("./routes/api/volunteer");
const roleRouter = require("./routes/api/role");
const emailsRouter = require("./routes/api/emails");

const app = express();
Services.db.connect();
Expand All @@ -40,42 +41,40 @@ let corsOptions = {};
if (!Services.env.isProduction()) {
corsOptions = {
origin: [`http://${process.env.FRONTEND_ADDRESS_DEV}`],
credentials: true
credentials: true,
};
} else {
corsOptions = {
origin: (origin, callback) => {
const allowedOrigins = [
`https://${process.env.FRONTEND_ADDRESS_DEPLOY}`,
`https://${process.env.FRONTEND_ADDRESS_BETA}`,
`https://docs.mchacks.ca`
`https://docs.mchacks.ca`,
];

const regex = /^https:\/\/dashboard-[\w-]+\.vercel\.app$/;

if (
allowedOrigins.includes(origin) || // Explicitly allowed origins
regex.test(origin) // Matches dashboard subdomains
regex.test(origin) // Matches dashboard subdomains
) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
callback(new Error("Not allowed by CORS"));
}
},
credentials: true
credentials: true,
};
}



app.use(cors(corsOptions));
app.use(Services.log.requestLogger);
app.use(Services.log.errorLogger);
app.use(express.json());
app.use(
express.urlencoded({
extended: false
})
extended: false,
}),
);
app.use(cookieParser());
//Cookie-based session tracking
Expand All @@ -86,8 +85,8 @@ app.use(
// Cookie Options
maxAge: 48 * 60 * 60 * 1000, //Logged in for 48 hours
sameSite: process.env.COOKIE_SAME_SITE,
secureProxy: !Services.env.isTest()
})
secureProxy: !Services.env.isTest(),
}),
);
app.use(passport.initialize());
app.use(passport.session()); //persistent login session
Expand Down Expand Up @@ -116,10 +115,10 @@ settingsRouter.activate(apiRouter);
Services.log.info("Settings router activated");
roleRouter.activate(apiRouter);
Services.log.info("Role router activated");
emailsRouter.activate(apiRouter);
Services.log.info("Emails router activated");

apiRouter.use("/", indexRouter);
app.use("/", indexRouter);

app.use("/api", apiRouter);

//Custom error handler
Expand All @@ -140,10 +139,10 @@ app.use((err, req, res, next) => {
}
res.status(status).json({
message: message,
data: errorContents
data: errorContents,
});
});

module.exports = {
app: app
app: app,
};
4 changes: 2 additions & 2 deletions assets/email/statusEmail/Accepted.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,12 @@
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#4D4D4D;">
Congratulations, {{firstName}}! 🎉
<br><br>
Were thrilled to offer you a spot at McHacks! We can't wait to see what
We're thrilled to offer you a spot at McHacks! We can't wait to see what
you create with us this year.
<br><br>
Confirm your attendance on our <a href="https://app.mchacks.ca/"
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#F2463A;text-decoration:none;">hacker
dashboard</a> no later than <b>January 21th at 11:59PM EST</b>.
dashboard</a> no later than <b>January 13th at 11:59PM EST</b>.
<br><br>
If you can no longer attend McHacks, please let us know as soon as
possible by withdrawing your application on our <a
Expand Down
4 changes: 2 additions & 2 deletions assets/email/statusEmail/Applied.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@
href="https://app.mchacks.ca/"
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#F2463A;text-decoration:none;">hacker
dashboard</a> until the deadline on <b
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-weight: 700;">January
3rd at
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-weight: 700;">December
20th at
11:59 PM ET</b>.
<br><br>
In the meantime, follow us on <a href="https://instagram.com/mcgillhacks"
Expand Down
2 changes: 1 addition & 1 deletion assets/email/statusEmail/Confirmed.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#4D4D4D;">
Hi, {{firstName}},
<br><br>
Thanks for confirming your attendance for McHacks! We hope youre just
Thanks for confirming your attendance for McHacks! We hope you're just
as excited as we are. Keep an eye out for our week-of email with more
details regarding McHacks. Happy hacking!
<br><br>
Expand Down
Loading