();
- });
-
CROW_ROUTE(app, "/testRequest")
([](){
- string customerEmailAddress = "test@testmail.com";
- string freelancer = "michael";
- string templateName = "coding";
- string currencyPreference = "XMR";
- string priceUpFront = "0.36";
- string priceOnDeliver = "0.36";
- string requestDescription = "This is a test";
- string accepted = "0";
- string upFrontInvoiceID = "12424242424";
- string onDeliverInvoiceID = "329532532532";
- string upFrontPaid = "0";
- string onDeliverPaid = "0";
- string sql = fmt::format("INSERT INTO requests(id, customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid) \
- VALUES(DEFAULT, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}' );", customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid );
-
+ string customerEmailAddress = "test@testmail.com";
+ string freelancer = "michael";
+ string templateName = "coding";
+ string currencyPreference = "XMR";
+ string priceUpFront = "0.36";
+ string priceOnDeliver = "0.36";
+ string requestDescription = "This is a test";
+ string accepted = "0";
+ string upFrontInvoiceID = "12424242424";
+ string onDeliverInvoiceID = "329532532532";
+ string upFrontPaid = "0";
+ string onDeliverPaid = "0";
+ string sql = fmt::format("INSERT INTO requests(id, customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid) \
+ VALUES(DEFAULT, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}' );", customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid );
- pqxx::connection db("postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm");
- pqxx::work work(db);
- work.exec( sql );
- work.commit();
- return crow::response(200);
+ pqxx::connection db("postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm");
+ pqxx::work work(db);
+ work.exec( sql );
+ work.commit();
+
+ return crow::response(200);
});
CROW_ROUTE(app, "/newRequest")
.methods("POST"_method)
([](const crow::request& req){
- auto jsonBody = crow::json::load(req.body);
- if (!jsonBody)
- return crow::response(crow::status::BAD_REQUEST);
+ auto jsonBody = crow::json::load(req.body);
+ if (!jsonBody)
+ return crow::response(crow::status::BAD_REQUEST);
- /*
- * Example CURL to insert into DB:
- * curl -d '{"customerEmailAddress":"test@testmail.com","freelancer":"michael","templateName":"coding","currencyPreference":"XMR","priceUpFront":0.36,"priceOnDeliver":0.36,"requestDescription":"This is a test","accepted":false,"upFrontInvoiceID":"12424242424","onDeliverInvoiceID":"329532532532","upFrontPaid":false,"onDeliverPaid":false}' http://0.0.0.0:18080/newRequest
- */
+ /*
+ * Example CURL to insert into DB:
+ * curl -d '{"customerEmailAddress":"test@testmail.com","freelancer":"michael","templateName":"coding","currencyPreference":"XMR","priceUpFront":0.36,"priceOnDeliver":0.36,"requestDescription":"This is a test","accepted":false,"upFrontInvoiceID":"12424242424","onDeliverInvoiceID":"329532532532","upFrontPaid":false,"onDeliverPaid":false}' http://0.0.0.0:18080/newRequest
+ */
- string customerEmailAddress = jsonBody["customerEmailAddress"].s();
- string freelancer = jsonBody["freelancer"].s();
- string templateName = jsonBody["templateName"].s();
- string currencyPreference = jsonBody["currencyPreference"].s();
- double priceUpFront = jsonBody["priceUpFront"].d();
- double priceOnDeliver = jsonBody["priceOnDeliver"].d();
- string requestDescription = jsonBody["requestDescription"].s();
- bool accepted = jsonBody["accepted"].b();
- string upFrontInvoiceID = jsonBody["upFrontInvoiceID"].s();
- string onDeliverInvoiceID = jsonBody["onDeliverInvoiceID"].s();
- bool upFrontPaid = jsonBody["upFrontPaid"].b();
- bool onDeliverPaid = jsonBody["onDeliverPaid"].b();
+ string customerEmailAddress = jsonBody["customerEmailAddress"].s();
+ string freelancer = jsonBody["freelancer"].s();
+ string templateName = jsonBody["templateName"].s();
+ string currencyPreference = jsonBody["currencyPreference"].s();
+ double priceUpFront = jsonBody["priceUpFront"].d();
+ double priceOnDeliver = jsonBody["priceOnDeliver"].d();
+ string requestDescription = jsonBody["requestDescription"].s();
+ bool accepted = jsonBody["accepted"].b();
+ string upFrontInvoiceID = jsonBody["upFrontInvoiceID"].s();
+ string onDeliverInvoiceID = jsonBody["onDeliverInvoiceID"].s();
+ bool upFrontPaid = jsonBody["upFrontPaid"].b();
+ bool onDeliverPaid = jsonBody["onDeliverPaid"].b();
- string sql = fmt::format("INSERT INTO requests(id, customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid) \
- VALUES(DEFAULT, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}');", customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted ,upFrontInvoiceID , onDeliverInvoiceID, upFrontPaid, onDeliverPaid );
+ string sql = fmt::format("INSERT INTO requests(id, customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid) \
+ VALUES(DEFAULT, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}');", customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted ,upFrontInvoiceID , onDeliverInvoiceID, upFrontPaid, onDeliverPaid );
- /*
+ /*
In C++20 this would be valid:
sql = std::format("INSERT INTO requests \
- VALUES(DEFAULT, \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\" ,\"{}\" ,\"{}\" ,\"{}\" ,\"{}\", \"{}\", \"{}\");",
- customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid);
+ VALUES(DEFAULT, \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\" ,\"{}\" ,\"{}\" ,\"{}\" ,\"{}\", \"{}\", \"{}\");",
+ customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, accepted, upFrontInvoiceID, onDeliverInvoiceID, upFrontPaid, onDeliverPaid);
*/
- pqxx::connection db("postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm");
- pqxx::work work(db);
- work.exec( sql );
- work.commit();
+ pqxx::connection db("postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm");
+ pqxx::work work(db);
+ work.exec( sql );
+ work.commit();
- return crow::response(200);
- });
+ return crow::response(200);
+ });
//set the port, set the app to run on multiple threads, and run the app
diff --git a/templates/test.html b/templates/test.html
new file mode 100644
index 0000000..693c151
--- /dev/null
+++ b/templates/test.html
@@ -0,0 +1,13 @@
+id: {{id}}
+customerEmailAddress: {{customerEmailAddress}}
+freelancer: {{freelancer}}
+templateName: {{templateName}}
+currencyPreference: {{currencyPreference}}
+priceUpFront: {{priceUpFront}}
+priceOnDeliver: {{priceOnDeliver}}
+requestDescription: {{requestDescription}}
+upFrontInvoiceID: {{upFrontInvoiceID}}
+onDeliverInvoiceID: {{onDeliverInvoiceID}}
+upFrontPaid: {{upFrontPaid}}
+onDeliverPaid: {{onDeliverPaid}}
+accepted: {{accepted}}