Skip to content
Merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ API for registration, live-site

## How to use and contribute

See documentation here: <https://hackerapi.mchacks.ca>
See documentation here: <https://docs.mchacks.ca>
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.1.1
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (!Services.env.isProduction()) {
} else {
// TODO: change this when necessary
corsOptions = {
origin: [`https://${process.env.FRONTEND_ADDRESS_DEPLOY}`, `https://hackerapi.mchacks.ca`],
origin: [`https://${process.env.FRONTEND_ADDRESS_DEPLOY}`, `https://docs.mchacks.ca`],
credentials: true
};
}
Expand Down
72 changes: 72 additions & 0 deletions constants/success.constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use strict";

const ACCOUNT_GET_BY_EMAIL = "Account found by user email.";
const ACCOUNT_GET_BY_ID = "Account found by user id.";
const ACCOUNT_CREATE = "Account creation successful.";
const ACCOUNT_UPDATE = "Account update successful.";
const ACCOUNT_INVITE = "Account invitation successful.";

const AUTH_LOGIN = "Login successful.";
const AUTH_LOGOUT = "Logout successful.";
const AUTH_SEND_RESET_EMAIL = "Send reset email successful.";
const AUTH_RESET_PASSWORD = "Reset password successful.";
const AUTH_CONFIRM_ACCOUNT = "Confirm account successful.";
const AUTH_GET_ROLE_BINDINGS = "Get role bindings successful.";
const AUTH_GET_ROLES = "Get roles successful.";
const AUTH_SEND_CONFIRMATION_EMAIL = "Send confirmation email successful.";

const HACKER_GET_BY_ID = "Hacker found by id.";
const HACKER_READ = "Hacker retrieval successful.";
const HACKER_CREATE = "Hacker creation successful.";
const HACKER_UPDATE = "Hacker update successful.";

const RESUME_UPLOAD = "Resume upload successful.";
const RESUME_DOWNLOAD = "Resume download successful.";

const SEARCH_QUERY = "Query search successful. Returning results.";
const SEARCH_NO_RESULTS = "Query search successful. No results found.";


const SPONSOR_GET_BY_ID = "Sponsor found by id.";
const SPONSOR_CREATE = "Sponsor creation successful.";

const TEAM_GET_BY_ID = "Team found by id.";
const TEAM_CREATE = "Team creation successful.";

const VOLUNTEER_CREATE = "Volunteer creation successful.";

module.exports = {
ACCOUNT_GET_BY_EMAIL: ACCOUNT_GET_BY_EMAIL,
ACCOUNT_GET_BY_ID: ACCOUNT_GET_BY_ID,
ACCOUNT_CREATE: ACCOUNT_CREATE,
ACCOUNT_UPDATE: ACCOUNT_UPDATE,
ACCOUNT_INVITE: ACCOUNT_INVITE,

AUTH_LOGIN: AUTH_LOGIN,
AUTH_LOGOUT: AUTH_LOGOUT,
AUTH_SEND_RESET_EMAIL: AUTH_SEND_RESET_EMAIL,
AUTH_RESET_PASSWORD: AUTH_RESET_PASSWORD,
AUTH_CONFIRM_ACCOUNT: AUTH_CONFIRM_ACCOUNT,
AUTH_GET_ROLE_BINDINGS: AUTH_GET_ROLE_BINDINGS,
AUTH_SEND_CONFIRMATION_EMAIL: AUTH_SEND_CONFIRMATION_EMAIL,
AUTH_GET_ROLES: AUTH_GET_ROLES,

HACKER_GET_BY_ID: HACKER_GET_BY_ID,
HACKER_READ: HACKER_READ,
HACKER_CREATE: HACKER_CREATE,
HACKER_UPDATE: HACKER_UPDATE,

RESUME_UPLOAD: RESUME_UPLOAD,
RESUME_DOWNLOAD: RESUME_DOWNLOAD,

SEARCH_QUERY: SEARCH_QUERY,
SEARCH_NO_RESULTS: SEARCH_NO_RESULTS,

SPONSOR_GET_BY_ID: SPONSOR_GET_BY_ID,
SPONSOR_CREATE: SPONSOR_CREATE,

TEAM_GET_BY_ID: TEAM_GET_BY_ID,
TEAM_CREATE: TEAM_CREATE,

VOLUNTEER_CREATE: VOLUNTEER_CREATE,
};
11 changes: 6 additions & 5 deletions controllers/account.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Services = {
const Util = require("../middlewares/util.middleware");
const Constants = {
Error: require("../constants/error.constant"),
Success: require("../constants/success.constant"),
};


Expand All @@ -22,7 +23,7 @@ async function getUserByEmail(req, res) {

if (acc) {
return res.status(200).json({
message: "Account found by user email",
message: Constants.Success.ACCOUNT_GET_BY_EMAIL,
data: acc.toStrippedJSON()
});
} else {
Expand All @@ -47,7 +48,7 @@ async function getUserById(req, res) {

if (acc) {
return res.status(200).json({
message: "Account found by user id",
message: Constants.Success.ACCOUNT_GET_BY_ID,
data: acc.toStrippedJSON()
});
} else {
Expand All @@ -69,7 +70,7 @@ async function getUserById(req, res) {
async function addUser(req, res) {
const acc = req.body.account;
return res.status(200).json({
message: "Account creation successful",
message: Constants.Success.ACCOUNT_CREATE,
data: acc.toStrippedJSON()
});
}
Expand All @@ -87,14 +88,14 @@ async function addUser(req, res) {
*/
function updatedAccount(req, res) {
return res.status(200).json({
message: "Changed account information",
message: Constants.Success.ACCOUNT_UPDATE,
data: req.body
});
}

function invitedAccount(req, res) {
return res.status(200).json({
message: "Successfully invited user",
message: Constants.Success.ACCOUNT_INVITE,
data: {}
});
}
Expand Down
18 changes: 10 additions & 8 deletions controllers/auth.controller.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
"use strict";

const Success = require("../constants/success.constant");

module.exports = {
onSuccessfulLogin: function (req, res) {
return res.status(200).json({
message: "Successfully logged in",
message: Success.LOGIN,
data: {}
});
},
logout: function (req, res) {
req.logout();
return res.status(200).json({
message: "Successfully logged out",
message: Success.LOGOUT,
data: {}
});
},
sentResetEmail: function (req, res) {
return res.status(200).json({
message: "Sent reset email",
message: Success.AUTH_SEND_RESET_EMAIL,
data: {}
});
},
resetPassword: function (req, res) {
return res.status(200).json({
message: "Successfully reset password",
message: Success.AUTH_RESET_PASSWORD,
data: {}
});
},
confirmAccount: function (req, res) {
return res.status(200).json({
message: "Successfully confirmed account",
message: Success.AUTH_CONFIRM_ACCOUNT,
data: {}
});
},
retrieveRoleBindings: function (req, res) {
return res.status(200).json({
message: "Successfully retrieved role bindings",
message: Success.AUTH_GET_ROLE_BINDINGS,
data: req.roleBindings.toJSON()
});
},
sentConfirmationEmail: function (req, res) {
return res.status(200).json({
message: "Successfully resent account email",
message: Success.AUTH_SEND_CONFIRMATION_EMAIL,
data: {}
})
},
retrievedRoles: function (req, res) {
return res.status(200).json({
message: "Successfully retrieved all roles",
message: Success.AUTH_GET_ROLES,
data: req.roles
})
}
Expand Down
13 changes: 7 additions & 6 deletions controllers/hacker.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Services = {
};
const Util = require("../middlewares/util.middleware");
const Constants = {
Success: require("../constants/success.constant"),
Error: require("../constants/error.constant"),
};

Expand All @@ -21,7 +22,7 @@ async function findById(req, res) {

if (hacker) {
return res.status(200).json({
message: "Successfully retrieved hacker information",
message: Constants.Success.HACKER_GET_BY_ID,
data: hacker.toJSON()
});
} else {
Expand All @@ -41,7 +42,7 @@ async function findById(req, res) {
*/
function showHacker(req, res) {
return res.status(200).json({
message: "Hacker retrieval successful",
message: Constants.Success.HACKER_READ,
data: req.body.hacker.toJSON()
});
}
Expand All @@ -55,7 +56,7 @@ function showHacker(req, res) {
*/
function createdHacker(req, res) {
return res.status(200).json({
message: "Hacker creation successful",
message: Constants.Success.HACKER_CREATE,
data: req.body.hacker.toJSON()
});
}
Expand All @@ -73,14 +74,14 @@ function createdHacker(req, res) {
*/
function updatedHacker(req, res) {
return res.status(200).json({
message: "Changed hacker information",
message: Constants.Success.HACKER_UPDATE,
data: req.body
});
}

function uploadedResume(req, res) {
return res.status(200).json({
message: "Uploaded resume",
message: Constants.Success.RESUME_UPLOAD,
data: {
filename: req.body.gcfilename
}
Expand All @@ -89,7 +90,7 @@ function uploadedResume(req, res) {

function downloadedResume(req, res) {
return res.status(200).json({
message: "Downloaded resume",
message: Constants.Success.RESUME_DOWNLOAD,
data: {
id: req.body.id,
resume: req.body.resume
Expand Down
14 changes: 7 additions & 7 deletions controllers/search.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const Services = {
Logger: require("../services/logger.service")
};
const Util = require("../middlewares/util.middleware");
const Success = require("../constants/success.constant");

async function searchResults(req, res) {
let results = req.body.results;
let message;
if(results.length < 1){
message = "No results found."
results = {}
}
else{
message = "Successfully executed query, returning all results"
if (results.length < 1) {
message = Success.SEARCH_NO_RESULTS;
results = {};
} else {
message = Success.SEARCH_QUERY;
}
return res.status(200).json({
message: message,
Expand All @@ -23,4 +23,4 @@ async function searchResults(req, res) {

module.exports = {
searchResults: Util.asyncMiddleware(searchResults)
}
};
7 changes: 4 additions & 3 deletions controllers/sponsor.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const Services = {
};
const Util = require("../middlewares/util.middleware");
const Constants = {
Success: require("../constants/success.constant"),
Error: require("../constants/error.constant"),
}
};

/**
* @async
Expand All @@ -22,7 +23,7 @@ async function findById(req, res) {

if (sponsor) {
return res.status(200).json({
message: "Successfully retrieved sponsor information",
message: Constants.Success.SPONSOR_GET_BY_ID,
data: sponsor.toJSON()
});
} else {
Expand All @@ -48,7 +49,7 @@ async function createSponsor(req, res) {

if (success) {
return res.status(200).json({
message: "Sponsor creation successful",
message: Constants.Success.SPONSOR_CREATE,
data: sponsorDetails
});
} else {
Expand Down
5 changes: 3 additions & 2 deletions controllers/team.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Services = {
};
const Util = require("../middlewares/util.middleware");
const Constants = {
Success: require("../constants/success.constant"),
Error: require("../constants/error.constant"),
};

Expand All @@ -23,7 +24,7 @@ async function findById(req, res) {

if (team) {
return res.status(200).json({
message: "Successfully retrieved team information",
message: Constants.Success.TEAM_GET_BY_ID,
data: team.toJSON()
});
} else {
Expand All @@ -49,7 +50,7 @@ async function createTeam(req, res) {

if (success) {
return res.status(200).json({
message: "Team creation successful",
message: Constants.Success.TEAM_CREATE,
data: teamDetails
});
} else {
Expand Down
3 changes: 2 additions & 1 deletion controllers/volunteer.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Services = {
};
const Util = require("../middlewares/util.middleware");
const Constants = {
Success: require("../constants/success.constant"),
Error: require("../constants/error.constant"),
}

Expand All @@ -23,7 +24,7 @@ async function createVolunteer(req, res) {

if (success) {
return res.status(200).json({
message: "Volunteer creation successful",
message: Constants.Success.VOLUNTEER_CREATE,
data: volunteerDetails
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
secretName: hackboard-secret
containers:
- name: hackboard
image: gcr.io/mchacks-api/hackboard:1.0.2
image: gcr.io/mchacks-api/hackboard:latest
ports:
# - containerPort: 443
- containerPort: 8080
2 changes: 1 addition & 1 deletion middlewares/validators/hacker.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
VALIDATOR.alphaArrayValidator("body", "ethnicity", false),
VALIDATOR.nameValidator("body", "major", false),
VALIDATOR.integerValidator("body", "graduationYear", false, 2019, 2030),
VALIDATOR.booleanValidator("body", "codeOfConduct", false),
VALIDATOR.booleanValidator("body", "codeOfConduct", false, true),
],

updateConfirmationValidator: [
Expand Down
Loading