From 5d0005a42f6da7fc9bfca9d07576a7918c170698 Mon Sep 17 00:00:00 2001 From: Sam Rose <11774595+sam-b-rose@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:42:21 -0500 Subject: [PATCH 1/5] Set @remix-run/fs-routes as a dependency to fix Dockerfile build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20f843da..07e995dc 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "dependencies": { "@prisma/client": "^5.11.0", "@remix-run/dev": "^2.7.1", + "@remix-run/fs-routes": "^2.15.0", "@remix-run/node": "^2.7.1", "@remix-run/react": "^2.7.1", "@remix-run/serve": "^2.7.1", @@ -41,7 +42,6 @@ }, "devDependencies": { "@remix-run/eslint-config": "^2.7.1", - "@remix-run/fs-routes": "^2.15.0", "@remix-run/route-config": "^2.15.0", "@shopify/api-codegen-preset": "^1.1.1", "@types/eslint": "^8.40.0", From b55d6bab37ebd8cf843da0418bba47b893569ffa Mon Sep 17 00:00:00 2001 From: Sam Rose <11774595+sam-b-rose@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:45:33 -0500 Subject: [PATCH 2/5] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3517740c..05a31e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 2024.12.05 +- [#907](https://github.com/Shopify/shopify-app-template-remix/pull/907) Move `@remix-run/fs-routes` to `dependencies` to fix Docker image build - [#899](https://github.com/Shopify/shopify-app-template-remix/pull/899) Disable v3_singleFetch flag - [#898](https://github.com/Shopify/shopify-app-template-remix/pull/898) Enable the `removeRest` future flag so new apps aren't tempted to use the REST Admin API. From 4c7c90a40bde20d851fbc8b8327a6f4b3308054f Mon Sep 17 00:00:00 2001 From: Sam Rose <11774595+sam-b-rose@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:48:14 -0500 Subject: [PATCH 3/5] Install OpenSSL in Dockerfile --- CHANGELOG.md | 1 + Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05a31e05..d4dc2ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 2024.12.05 +- [#910](https://github.com/Shopify/shopify-app-template-remix/pull/910) Install `openssl` in Docker image to fix Prisma (see [#25817](https://github.com/prisma/prisma/issues/25817#issuecomment-2538544254)) - [#907](https://github.com/Shopify/shopify-app-template-remix/pull/907) Move `@remix-run/fs-routes` to `dependencies` to fix Docker image build - [#899](https://github.com/Shopify/shopify-app-template-remix/pull/899) Disable v3_singleFetch flag - [#898](https://github.com/Shopify/shopify-app-template-remix/pull/898) Enable the `removeRest` future flag so new apps aren't tempted to use the REST Admin API. diff --git a/Dockerfile b/Dockerfile index 98e0c37d..07bc9cf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:18-alpine +RUN apk add --no-cache openssl EXPOSE 3000 From bdfe4afb61bb0fd75d14c4076d7c32c121b4eaaa Mon Sep 17 00:00:00 2001 From: Allen Chazhoor Date: Thu, 5 Dec 2024 12:04:52 -0500 Subject: [PATCH 4/5] Add webhook --- CHANGELOG.md | 7 +++++-- app/routes/webhooks.app.scopes_update.tsx | 21 +++++++++++++++++++++ shopify.app.toml | 5 +++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 app/routes/webhooks.app.scopes_update.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index d4dc2ab3..fe4cb154 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,13 @@ ## 2024.12.04 +- [875](https://github.com/Shopify/shopify-app-template-remix/pull/875) Add Scopes Update Webhook + +## 2024.12.04 + - [#891](https://github.com/Shopify/shopify-app-template-remix/pull/891) Enable remix future flags. ## 2024.11.26 - - [888](https://github.com/Shopify/shopify-app-template-remix/pull/888) Update restResources version to 2024-10 ## 2024.11.06 @@ -33,7 +36,7 @@ ## 2024.09.17 -- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842)Move webhook processing to individual routes +- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842) Move webhook processing to individual routes ## 2024.08.19 diff --git a/app/routes/webhooks.app.scopes_update.tsx b/app/routes/webhooks.app.scopes_update.tsx new file mode 100644 index 00000000..c36bb64c --- /dev/null +++ b/app/routes/webhooks.app.scopes_update.tsx @@ -0,0 +1,21 @@ +import type { ActionFunctionArgs } from "@remix-run/node"; +import { authenticate } from "../shopify.server"; +import db from "../db.server"; + +export const action = async ({ request }: ActionFunctionArgs) => { + const { payload, session, topic, shop } = await authenticate.webhook(request); + console.log(`Received ${topic} webhook for ${shop}`); + + const current = payload.current as string[]; + if (session) { + await db.session.update({ + where: { + id: session.id + }, + data: { + scope: current.toString(), + }, + }); + } + return new Response(); +}; diff --git a/shopify.app.toml b/shopify.app.toml index e1a27650..7215ddf9 100644 --- a/shopify.app.toml +++ b/shopify.app.toml @@ -10,6 +10,11 @@ api_version = "2024-10" uri = "/webhooks/app/uninstalled" topics = ["app/uninstalled"] + # Handled by: /app/routes/webhooks.app.scopes_update.tsx + [[webhooks.subscriptions]] + topics = [ "app/scopes_update" ] + uri = "/webhooks/app/scopes_update" + # Webhooks can have filters # Only receive webhooks for product updates with a product price >= 10.00 # See: https://shopify.dev/docs/apps/build/webhooks/customize/filters From 19e6d4fc7a34d1822f8992f4c020b1df767ddea6 Mon Sep 17 00:00:00 2001 From: Allen Chazhoor Date: Tue, 17 Dec 2024 17:13:14 -0500 Subject: [PATCH 5/5] Update changelog release date --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe4cb154..427e152b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # @shopify/shopify-app-template-remix +## 2024.12.18 + +- [875](https://github.com/Shopify/shopify-app-template-remix/pull/875) Add Scopes Update Webhook + ## 2024.12.05 - [#910](https://github.com/Shopify/shopify-app-template-remix/pull/910) Install `openssl` in Docker image to fix Prisma (see [#25817](https://github.com/prisma/prisma/issues/25817#issuecomment-2538544254)) @@ -9,10 +13,6 @@ ## 2024.12.04 -- [875](https://github.com/Shopify/shopify-app-template-remix/pull/875) Add Scopes Update Webhook - -## 2024.12.04 - - [#891](https://github.com/Shopify/shopify-app-template-remix/pull/891) Enable remix future flags. ## 2024.11.26