Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z committed May 19, 2024
1 parent 0ee9237 commit 69ebbb0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions include/Route.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class Route {
throw exception();
}

void Get(string name, function<void(Request, Response&)> handler) {
void get(string name, function<void(Request, Response&)> handler) {
this->server->Get(name, handler);
}

void Post(string name, function<void(Request, Response&)> handler, vector<string> body_format) {
void post(string name, function<void(Request, Response&)> handler, vector<string> body_format) {
server->Post(name, [body_format, this, handler](Request request, Response& response) {
log<DEBUG>("validating input...");
if (this->validate(request, body_format)) {
Expand All @@ -123,7 +123,7 @@ class Route {
}
});
}
void Delete(string name, function<void(Request, Response&)> handler) {
void _Delete(string name, function<void(Request, Response&)> handler) {
server->Delete(name, handler);
}
};
2 changes: 1 addition & 1 deletion include/Routes/Answers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Answers : public Route {
/// @brief Initializes the Answers endpoints.
void init() override {
/// @brief Returns a specific answer provided that the user has permission to access it.
Get("/answers/get/:answerId/:token", [&](Request request, Response& response){
get("/answers/get/:answerId/:token", [&](Request request, Response& response){
auto answerId = stoi(request.path_params["answerId"]);
auto token = request.path_params["token"];
json response_data;
Expand Down
8 changes: 4 additions & 4 deletions include/Routes/Journals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Journals : public Route {
/// @brief Initializes the Journal endpoints.
void init() override {
/// @brief Submits a new journal to the system
Post("/journals/new", [&](Request request, Response& response){
post("/journals/new", [&](Request request, Response& response){
auto time = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
auto body = json::parse(request.body);
auto token = body["token"].get<string>();
Expand Down Expand Up @@ -51,7 +51,7 @@ class Journals : public Route {
}
}, {"token", "data"});
/// @brief Returns a journal with a given journal id.
Get("/journals/get/:jid", [&](Request request, Response& response){
get("/journals/get/:jid", [&](Request request, Response& response){
auto jid = stoi(request.path_params["jid"]);
json response_data;
if (jid <= 0 || db["journals"].get_where("id", jid).size() == 0) {
Expand All @@ -67,7 +67,7 @@ class Journals : public Route {
respond(&response, response_data);
});
/// @brief Returns all the journal ids belonging to a specific user.
Get("/journals/ids/:token", [&](Request request, Response& response){
get("/journals/ids/:token", [&](Request request, Response& response){
json response_data;
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
Expand All @@ -82,7 +82,7 @@ class Journals : public Route {
respond(&response, response_data);
});
/// @brief Deletes a journal from the system with a given journal id.
Delete("/journals/delete/:jid/:token", [&](Request request, Response& response){
_delete("/journals/delete/:jid/:token", [&](Request request, Response& response){
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
auto jid = stoi(request.path_params["jid"]);
Expand Down
6 changes: 3 additions & 3 deletions include/Routes/Mitigations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Mitigations : public Route {
/// @brief Initializes the Mitigations endpoints.
void init() override {
/// @brief Returns a specific mitigation with a given id.
Get("/mitigations/get/:mid", [&](Request request, Response& response){
get("/mitigations/get/:mid", [&](Request request, Response& response){
auto mid = stoi(request.path_params["mid"]);
json response_data;
if (mid <= 0 || db["mitigations"].get_where("id", mid).size() == 0) {
Expand All @@ -33,7 +33,7 @@ class Mitigations : public Route {
respond(&response, response_data);
});
/// @brief Returns a specific mitigation with a given id.
Get("/mitigations/tags/:tag", [&](Request request, Response& response){
get("/mitigations/tags/:tag", [&](Request request, Response& response){
auto tagparam = request.path_params["tag"];
auto tags = split_string(tagparam);
json response_data;
Expand Down Expand Up @@ -67,7 +67,7 @@ class Mitigations : public Route {
respond(&response, response_data, 400);
}
});
Get("/mitigations/new/:token", [&](Request request, Response& response) {
get("/mitigations/new/:token", [&](Request request, Response& response) {
json response_data;
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
Expand Down
4 changes: 2 additions & 2 deletions include/Routes/Predictions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Predictions : public Route {
/// @brief Initializes the Prediction endpoints.
void init() override {
/// @brief Returns all predictions from a specific user.
Get("/predictions/get/:token", [&](Request request, Response& response){
get("/predictions/get/:token", [&](Request request, Response& response){
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
json response_data;
Expand All @@ -46,7 +46,7 @@ class Predictions : public Route {
respond(&response, response_data);
});
/// @brief Submits a prediction to the system.
Post("/predictions/add", [&](Request request, Response& response){
post("/predictions/add", [&](Request request, Response& response){
auto body = json::parse(request.body);
auto token = body["token"].get<string>();
auto uid = user_id_from_token(token);
Expand Down
6 changes: 3 additions & 3 deletions include/Routes/Questions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Questions : public Route {
/// @brief Initializes the Questions endpoints.
void init() override {
/// @brief Returns the default questions (those with the tag "default").
Get("/questions/defaults", [&](Request request, Response& response){
get("/questions/defaults", [&](Request request, Response& response){
if (db["questions"].get_where("tags", "default").size() == 0) {
json response_data;
response_data["error"] = "Somehow there are no default questions???";
Expand All @@ -35,7 +35,7 @@ class Questions : public Route {
respond(&response, response_data);
});
/// @brief Returns all the questions with a given tag.
Get("/questions/get/:tag", [&](Request request, Response& response){
get("/questions/get/:tag", [&](Request request, Response& response){
auto tag = request.path_params["tag"];
json response_data;
if (db["questions"].get_where("tags", tag).size() == 0) {
Expand All @@ -59,7 +59,7 @@ class Questions : public Route {
}
respond(&response, response_data);
});
Get("/questions/legend/:qid", [&](Request request, Response& response){
get("/questions/legend/:qid", [&](Request request, Response& response){
auto qid = request.path_params["qid"];
auto lids = db["legends"].get_where("questionId", stoi(qid));
vector<Row> legends;
Expand Down
4 changes: 2 additions & 2 deletions include/Routes/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Settings : public Route {
/// @brief Initializes the Settings endpoints.
void init() override {
/// @brief Returns all the settings belonging to a given user.
Get("/settings/get/:token", [&](Request request, Response& response){
get("/settings/get/:token", [&](Request request, Response& response){
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
json response_data;
Expand All @@ -37,7 +37,7 @@ class Settings : public Route {
respond(&response, response_data);
});
/// @brief Updates all the specified settings for a given user.
Post("/settings/update", [&](Request request, Response& response){
post("/settings/update", [&](Request request, Response& response){
auto body = json::parse(request.body);
auto token = body["token"].get<std::string>();
auto uid = user_id_from_token(token);
Expand Down
2 changes: 1 addition & 1 deletion include/Routes/Tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Tests : public Route {
using Route::Route;

void init() override {
Post("/tests/rate", [&](Request request, Response response){
post("/tests/rate", [&](Request request, Response response){
auto body = json::parse(request.body);
auto token = body["token"].get<string>();
auto uid = user_id_from_token(token);
Expand Down
18 changes: 9 additions & 9 deletions include/Routes/Users.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Users : public Route {
using Route::Route;
/// @brief Initializes the User endpoints.
void init() override {
/// @brief Gets the userdata of a user.
Get("/user/get/:token", [&](Request request, Response& response){
/// @brief gets the userdata of a user.
get("/user/get/:token", [&](Request request, Response& response){
json response_data;
auto token = request.path_params["token"];
auto uid = user_id_from_token(token);
Expand Down Expand Up @@ -59,8 +59,8 @@ class Users : public Route {

respond(&response, response_data);
});
/// @brief Get a range of user ids with a given min and max value.
Get("/user/ids/:min/:max", [&](Request request, Response& response){
/// @brief get a range of user ids with a given min and max value.
get("/user/ids/:min/:max", [&](Request request, Response& response){
json response_data;
auto min = stoi(request.path_params["min"]);
auto max = stoi(request.path_params["max"]);
Expand All @@ -80,13 +80,13 @@ class Users : public Route {
response_data = filteredUsers;
respond(&response, response_data);
});
/// @brief Gets all user ids.
Get("/user/ids", [&](Request request, Response& response){
/// @brief gets all user ids.
get("/user/ids", [&](Request request, Response& response){
json data = db["users"].get_where();
respond(&response, data);
});
/// @brief Authenticate a user.
Post("/user/auth", [&](Request request, Response& response){
post("/user/auth", [&](Request request, Response& response){
auto body = json::parse(request.body);
auto username = body["username"].get<string>();
auto password = body["password"].get<string>();
Expand All @@ -110,7 +110,7 @@ class Users : public Route {
}
}, {"username", "password"});
/// @brief Register a new user into the system.
Post("/user/register", [&](Request request, Response& response){
post("/user/register", [&](Request request, Response& response){
auto body = json::parse(request.body);
auto username = body["username"].get<string>();
auto password = body["password"].get<string>();
Expand All @@ -136,7 +136,7 @@ class Users : public Route {
}
}, {"username", "password"});
/// @brief Updates or creates a user's userdata with new values.
Post("/user/data/update", [&](Request request, Response& response){
post("/user/data/update", [&](Request request, Response& response){
auto body = json::parse(request.body);
auto token = body["token"].get<std::string>();
auto uid = user_id_from_token(token);
Expand Down

0 comments on commit 69ebbb0

Please sign in to comment.