summaryrefslogtreecommitdiff
path: root/api/Order.js
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-08 08:20:36 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-08 08:20:36 +0100
commit788564803d72c8d5aa412165ab7121398dc0feb3 (patch)
tree06873f6fd302c55fe2020f99c4d314e955157d3f /api/Order.js
parent91788279c9ad2712910c611887438920be0581f1 (diff)
Pulls out POST handler
Diffstat (limited to 'api/Order.js')
-rw-r--r--api/Order.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/api/Order.js b/api/Order.js
index 95ff8ab..1ef976d 100644
--- a/api/Order.js
+++ b/api/Order.js
@@ -39,16 +39,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
var _paypal_1 = require("./_paypal");
function handler(request, response) {
return __awaiter(this, void 0, void 0, function () {
+ return __generator(this, function (_a) {
+ switch (_a.label) {
+ case 0:
+ if (!(request.method === 'POST')) return [3 /*break*/, 2];
+ return [4 /*yield*/, handlePost(request, response)];
+ case 1:
+ _a.sent();
+ return [3 /*break*/, 3];
+ case 2:
+ console.warn('Method was not POST. Method was ' + request.method);
+ response.status(404);
+ return [2 /*return*/];
+ case 3: return [2 /*return*/];
+ }
+ });
+ });
+}
+exports.default = handler;
+function handlePost(request, response) {
+ return __awaiter(this, void 0, void 0, function () {
var _a, productDescription, shortDescription, totalPrice, paypalResponse, err_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = request.body, productDescription = _a.productDescription, shortDescription = _a.shortDescription, totalPrice = _a.totalPrice;
- if (request.method !== 'POST') {
- console.warn('Method was not POST. Method was ' + request.method);
- response.status(404);
- return [2 /*return*/];
- }
if (!!productDescription) return [3 /*break*/, 1];
response.status(400).send('Expected body to contain productDescription, but none provided.');
return [3 /*break*/, 6];
@@ -78,5 +93,4 @@ function handler(request, response) {
});
});
}
-exports.default = handler;
//# sourceMappingURL=order.js.map \ No newline at end of file