diff options
| author | Adam Soltys <[email protected]> | 2023-09-20 16:13:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-09-20 16:13:58 -0700 |
| commit | 948efb0f123532c9f276831b485a9769cbe6b413 (patch) | |
| tree | 15293ec3c96ec1bf8c63703a3c1c8ac95a3c764f | |
| parent | f990bf00785bc39b861a743bfb2c2c7f9e94d42c (diff) | |
| download | coinos-server-948efb0f123532c9f276831b485a9769cbe6b413.tar.gz coinos-server-948efb0f123532c9f276831b485a9769cbe6b413.zip | |
pass username to shopify endpoint
| -rw-r--r-- | index.js | 2 | ||||
| -rw-r--r-- | routes/shopify.js | 31 |
2 files changed, 19 insertions, 14 deletions
@@ -95,7 +95,7 @@ app.post("/requests", auth, requests.create); app.post("/requests/delete", auth, requests.destroy); app.post("/proxy", payments.proxy); -app.post("/shopify/:id", auth, shopify); +app.post("/shopify/:username/:id", shopify); let host = process.env.HOST || "0.0.0.0"; let port = process.env.PORT || 3119; diff --git a/routes/shopify.js b/routes/shopify.js index f15a3468..a0aab057 100644 --- a/routes/shopify.js +++ b/routes/shopify.js @@ -1,4 +1,5 @@ import got from "got"; +import { g } from "$lib/db"; let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) { orderMarkAsPaid(input: $input) { @@ -10,20 +11,24 @@ let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) { } }`; -export default async ({ body, params: { id }, user }, res) => { - let r = await got.post( - `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, - { - headers: { - "Content-Type": "application/json", - "X-Shopify-Access-Token": user.shopifyToken - }, - json: { - query, - variables: { input: { id: `gid://shopify/Order/${id}` } } +export default async ({ body, params: { id, username } }, res) => { + let user = await g(`user:${await g(`user:${username}`)}`); + + let r = await got + .post( + `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, + { + headers: { + "Content-Type": "application/json", + "X-Shopify-Access-Token": user.shopifyToken + }, + json: { + query, + variables: { input: { id: `gid://shopify/Order/${id}` } } + } } - } - ).json(); + ) + .json(); res.send(r); }; |
