Skip to content

Commit

Permalink
Adjust to new domain, single-store only
Browse files Browse the repository at this point in the history
  • Loading branch information
crummy committed Sep 23, 2024
1 parent 26d77be commit 68f9582
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CLOUDFRONT_ID = $(shell aws --profile storefront cloudfront list-distributions -

# Has to be run against us-east-1 because that's where cloudfront lives
deploy-cloudformation:
aws --region us-east-1 cloudformation deploy --template-file cloudformation/s3-website.yml --stack-name $(STACK_NAME) --parameter-overrides DomainName="storefront.nz"
aws --region us-east-1 --profile storefront cloudformation deploy --template-file cloudformation/s3-website.yml --stack-name $(STACK_NAME) --parameter-overrides DomainName="windsongorchard.nz"

sync:
cd ui && npm run build && cd - && \
Expand All @@ -24,7 +24,7 @@ add-shop:
-d limit=1 -G \
| jq ".data[0]" --exit-status || curl https://api.stripe.com/v1/webhook_endpoints \
-u $(STRIPE_SECRET_KEY): \
-d url="https://$(STAGE).storefront.nz/shop/$(ID)/order/webhook" \
-d url="https://$(STAGE).windsongorchard.nz/shop/$(ID)/order/webhook" \
-d "enabled_events[]"="checkout.session.completed"

set-google-api-key:
Expand All @@ -34,7 +34,7 @@ set-google-api-key:

deploy:
npm run build
./node_modules/.bin/serverless deploy --aws-profile storefront
./node_modules/.bin/serverless deploy --aws-profile storefront --verbose

env: # doesn't work
export $(cat .env | xargs)
2 changes: 1 addition & 1 deletion cloudformation/s3-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Resources:
DomainName: !Ref DomainName
SubjectAlternativeNames:
- !Sub 'www.${DomainName}'
ValidationMethod: EMAIL
ValidationMethod: DNS

CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Expand Down
8 changes: 4 additions & 4 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ provider:
GOOGLE_API_KEY: ${ssm:/api/${self:provider.stage}/google-api-key} # TODO: remove this, just use service account
GOOGLE_SERVICE_ACCOUNT_EMAIL: ${ssm:/api/${self:provider.stage}/google-service-account-email}
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY: ${ssm:/api/${self:provider.stage}/google-service-account-private-key}
WEBSITE_BASE_URL: https://storefront.nz # TODO: figure out how to get this from CF output
WEBSITE_BASE_URL: https://windsongorchard.nz # TODO: figure out how to get this from CF output
ORDER_CREATED_SES_TEMPLATE: orderCreated_${self:provider.stage}

package:
Expand Down Expand Up @@ -151,8 +151,8 @@ custom:
number: 3
includeLayers: true
customDomain:
domainName: ${self:provider.stage}.storefront.nz
certificateName: "*.storefront.nz"
domainName: ${self:provider.stage}.windsongorchard.nz
certificateName: "*.windsongorchard.nz"
createRoute53Record: true
stage: ${self:provider.stage}
endpointType: 'regional'
autoDomain: true
4 changes: 2 additions & 2 deletions src/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const sendOrderNotification = (order: PlacedOrder, shopConfig: ShopConfig
const link = `${websiteBaseUrl}/${order.shopId}/order/${order.id}`
const address = addressToString(order.address)
const goods = goodsToString(order.goods)
let htmlBody = `<h1>Storefront.nz Order for ${order.shopId}</h1><h2><a href="${link}">Order ID ${order.id}</a></h2>Deliver <b>${goods}</b> via ${order.shipping} to: <br/><a href="mailto:${order.email}">${order.name}</a> (${order.phoneNumber})<br/>, ${address}<br/>`
let textBody = `Storefront.nz Order for ${order.shopId}\r\nOrder ID ${order.id}\r\nDeliver ${goods} via ${order.shipping} to:\r\n${order.name} - ${order.email} - ${order.phoneNumber}\r\n${address}\r\n`
let htmlBody = `<h1>windsongorchard.nz Order for ${order.shopId}</h1><h2><a href="${link}">Order ID ${order.id}</a></h2>Deliver <b>${goods}</b> via ${order.shipping} to: <br/><a href="mailto:${order.email}">${order.name}</a> (${order.phoneNumber})<br/>, ${address}<br/>`
let textBody = `windsongorchard.nz Order for ${order.shopId}\r\nOrder ID ${order.id}\r\nDeliver ${goods} via ${order.shipping} to:\r\n${order.name} - ${order.email} - ${order.phoneNumber}\r\n${address}\r\n`
if (order.note) {
htmlBody += `<b>Note:</b> ${order.note}`
textBody += `Note: ${order.note}`
Expand Down
4 changes: 2 additions & 2 deletions src/test/webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "cs_test_o3836gLsAp9ZI92DN9X39HfzxarNnl6RBVd7xHybFynBo1gSGpfXfEOQ",
"object": "checkout.session",
"billing_address_collection": null,
"cancel_url": "https://storefront.nz/windsong/order/3d792e5f-3d3c-4363-b26b-612fdc4e7f6a/cancel",
"cancel_url": "https://windsongorchard.nz/windsong/order/3d792e5f-3d3c-4363-b26b-612fdc4e7f6a/cancel",
"client_reference_id": "3d792e5f-3d3c-4363-b26b-612fdc4e7f6a",
"customer": "cus_H7dV5uSqgVLLks",
"customer_email": "[email protected]",
Expand Down Expand Up @@ -64,7 +64,7 @@
},
"submit_type": null,
"subscription": null,
"success_url": "https://storefront.nz/windsong/order/3d792e5f-3d3c-4363-b26b-612fdc4e7f6a?sessionId={CHECKOUT_SESSION_ID}"
"success_url": "https://windsongorchard.nz/windsong/order/3d792e5f-3d3c-4363-b26b-612fdc4e7f6a?sessionId={CHECKOUT_SESSION_ID}"
}
}
}
2 changes: 1 addition & 1 deletion ui/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { terser } from 'rollup-plugin-terser';
import replace from '@rollup/plugin-replace';

const production = !process.env.ROLLUP_WATCH;
const apiUrl = "https://dev.storefront.nz" // TODO: different one for prod
const apiUrl = "https://dev.windsongorchard.nz" // TODO: different one for prod

export default {
input: 'src/main.js',
Expand Down
7 changes: 3 additions & 4 deletions ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import router from "page";
import Shop from "./routes/Shop.svelte";
import Order from "./routes/Order.svelte";
import Welcome from "./routes/Welcome.svelte";
import Cancel from "./routes/Cancel.svelte";
import {getShop, getOrder} from "./api";
import {parseQuery} from "./queryString"
Expand All @@ -11,7 +10,7 @@
let params = {}
const loadShop = (ctx, next) => {
params.shopId = ctx.params.shopId
params.shopId = ctx.params.shopId || "windsong"
getShop(params.shopId).then(result => {
params.shop = {goods: result.goods, shippingCosts: result.shippingCosts, id: result.id, ...result.fields}
document.title = result.fields.title
Expand All @@ -33,7 +32,7 @@
next()
}
router("/", () => (page = Welcome));
router("/", loadShop, () => (page = Shop));
router("/:shopId/*", loadShop);
router("/:shopId", loadShop, () => (page = Shop));
router("/:shopId/order/:orderId", loadOrder, loadQueryString, () => (page = Order));
Expand All @@ -58,7 +57,7 @@
</style>

<svelte:head>
<title>storefront.nz</title>
<title>windsongorchard.nz</title>
</svelte:head>
<svelte:component this={page} {params}/>

Expand Down
2 changes: 1 addition & 1 deletion ui/src/routes/Welcome.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<main>
<h1>storefront.nz</h1>
<h1>windsongorchard.nz</h1>
<h2>A simpler way to sell</h2>
Created by Malcolm Crum
</main>

0 comments on commit 68f9582

Please sign in to comment.