Skip to content

Commit 5d0d2df

Browse files
author
Anto Lepejian
authored
New Real Estate integration demo 🏠 (#17)
1 parent 6c4a25c commit 5d0d2df

126 files changed

Lines changed: 18535 additions & 775 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ dist
1010
openapi-ts-error-*.log
1111
**/*/db.json
1212
**/public/exports
13+
.venv
14+
.ruff_cache
15+
.pytest_cache
16+
__pycache__
17+
database.db
18+
.claude

CHANGELOG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 2025-07-07
4+
5+
### 🧰 Added
6+
7+
- Added a new real estate integration demo in `demos/realty`.
8+
9+
### 🐞 Fixed
10+
11+
- Several typos in the documentation.
12+
13+
### 🔧 Changed
14+
15+
- Upgraded `webpack-dev-server` to version `5.2.2` from `5.2.0`.
16+
- Updated Brand Template selector components to display Brand Templates download link more prominently.
17+
18+
### 🗑️ Removed
19+
20+
- Removed the `--ngrok` flag which is not required, but could potentially cause issues if certain environment variables are set.
21+
322
## 2025-05-15
423

524
### 🐞 Fixed
@@ -12,7 +31,7 @@
1231
- Refreshed the OpenAPI yml spec `openapi/spec.yml` to be based on the latest Connect API design.
1332
- Patch and minor version changes to package dependencies in the `ecommerce_shop` and `playground` demos.
1433
- Moved `webpack.config.cjs` to `webpack.config.ts` for type checking.
15-
- Updated file name casing to be consistent, and added an elint rule to enforce this
34+
- Updated file name casing to be consistent, and added an eslint rule to enforce this
1635
- Updated `eslint`, `eslint-plugin-unicorn`, and `typescript-eslint`.
1736

1837
## 2024-12-19
@@ -21,7 +40,7 @@
2140

2241
- Both demo projects now take advantage of the CORS support for the Connect API and make most requests directly from the frontend code
2342
- Updated HeyAPI to version 0.5, and TypeScript to version 5.5
24-
- Dependencies are now pinned to exact versions to reduce accidental incompatabilities
43+
- Dependencies are now pinned to exact versions to reduce accidental incompatibilities
2544
- Refreshed the OpenAPI yml spec `openapi/spec.yml` to be based on the latest Connect API design
2645

2746
## 2024-09-23

README.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This repo contains our openAPI specifications, as well as a demo ecommerce web a
1515

1616
The Canva Connect API doesn't maintain nor publish client SDKs, however, we have made our [OpenAPI spec](./openapi/spec.yml) publicly available, so you can use it with your favorite code generation library, such as [openapi-generator](https://github.com/OpenAPITools/openapi-generator) to generate client SDKs in your language of choice!
1717

18-
To demonstrate this, we're using [openapi-ts](https://www.npmjs.com/package/@hey-api/openapi-ts) to generate TypeScript SDKs in [client/ts](./client//ts/) which is used in our demo app.
18+
To demonstrate this, we're using [openapi-ts](https://www.npmjs.com/package/@hey-api/openapi-ts) to generate TypeScript SDKs in [client/ts](./client/ts/) which is used in our demo app.
1919

2020
## Demos: E-commerce Shop
2121

@@ -63,7 +63,7 @@ cd demos/ecommerce_shop
6363

6464
2. Add your integration settings to the `demos/ecommerce_shop/.env` file.
6565

66-
- `DATABASE_ENCRYPTION_KEY`: This will encrypt and decrypt the tokens stored in the JSON database. A key is automatically get generated for you after running `npm install`, and will already be set in `.env`. If not, run `npm run generate:db-key` from the `demos/ecommerce_shop` directory.
66+
- `DATABASE_ENCRYPTION_KEY`: This will encrypt and decrypt the tokens stored in the JSON database. A key is automatically generated for you after running `npm install`, and will already be set in `.env`. If not, run `npm run generate:db-key` from the `demos/ecommerce_shop` directory.
6767
- `CANVA_CLIENT_ID`: This is the `Client ID` from the prerequisites.
6868
- `CANVA_CLIENT_SECRET`: This is the `client secret` you generated in the prerequisites.
6969

@@ -78,6 +78,75 @@ npm start
7878
7979
4. View your app: [http://127.0.0.1:3000](http://127.0.0.1:3000)
8080

81+
### Brand Templates Setup
82+
83+
To get started with Brand Templates in the e-commerce demo, you can install sample templates from [this Brand Template deck](https://www.canva.com/design/DAGGkcb61HQ/OJhMIQrmz2daIoxo8u3T2g/view).
84+
85+
## Demos: Real-estate demo
86+
87+
### Prerequisites
88+
89+
Before you can run this demo, you'll need to do some setup beforehand.
90+
91+
1. Open the [Developer Portal](https://www.canva.com/developers/integrations/connect-api), and click `Create an integration`.
92+
93+
2. Under `Configuration``Configure your integration`.
94+
95+
- `Integration name`: Add a name.
96+
- `Client ID`: Make a note of this value; you'll need it in a later step.
97+
- `Generate secret`: Click this and save the secret in a secure location, as you'll need it for a later step.
98+
99+
3. Under `Scopes``Set the scopes`, check the following boxes:
100+
101+
- `asset`: Read and Write.
102+
- `brandtemplate:content`: Read.
103+
- `brandtemplate:meta`: Read.
104+
- `design:content`: Read and Write.
105+
- `design:meta`: Read.
106+
- `profile`: Read.
107+
108+
4. Under `Authentication``Add Authentication`, locate `URL 1` and enter the following value:
109+
110+
```
111+
http://127.0.0.1:3001/oauth/redirect
112+
```
113+
114+
5. Under `Return navigation`, toggle on the `Enable return navigation` switch and enter the following as the `Return Url`:
115+
116+
```
117+
http://127.0.0.1:3001/return-nav
118+
```
119+
120+
### How to run
121+
122+
1. Install dependencies
123+
124+
```bash
125+
npm install
126+
cd demos/realty
127+
```
128+
129+
2. Add your integration settings to the `demos/realty/.env` file.
130+
131+
- `DATABASE_ENCRYPTION_KEY`: This will encrypt and decrypt the tokens stored in the JSON database. A key is automatically generated for you after running `npm install`, and will already be set in `.env`. If not, run `npm run generate:db-key` from the `demos/realty` directory.
132+
- `CANVA_CLIENT_ID`: This is the `Client ID` from the prerequisites.
133+
- `CANVA_CLIENT_SECRET`: This is the `client secret` you generated in the prerequisites.
134+
135+
3. Run the app
136+
137+
```bash
138+
npm start
139+
```
140+
141+
> [!WARNING]
142+
> Accessing the app via `localhost:3000` will throw CORS errors, you must access the app via the below URL.
143+
144+
4. View your app: [http://127.0.0.1:3000](http://127.0.0.1:3000)
145+
146+
### Brand Templates Setup
147+
148+
To get started with Brand Templates in the real estate demo, you can install sample templates from [this Brand Template deck](https://www.canva.com/design/DAGGkcb61HQ/OJhMIQrmz2daIoxo8u3T2g/view).
149+
81150
## Demos: Connect API Playground
82151

83152
### Prerequisites
@@ -113,7 +182,7 @@ cd demos/playground
113182

114183
2. Add your integration settings to the `demos/playground/.env` file.
115184

116-
- `DATABASE_ENCRYPTION_KEY`: This will encrypt and decrypt the tokens stored in the JSON database. A key is automatically get generated for you after running `npm install`, and will aready be set in `.env`.
185+
- `DATABASE_ENCRYPTION_KEY`: This will encrypt and decrypt the tokens stored in the JSON database. A key is automatically generated for you after running `npm install`, and will already be set in `.env`.
117186
- `CANVA_CLIENT_ID`: This is the `Client ID` from the prerequisites.
118187
- `CANVA_CLIENT_SECRET`: This is the `client secret` you generated in the prerequisites.
119188

demos/common/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@
1717
"type": "commonjs",
1818
"dependencies": {
1919
"@canva/connect-api-ts": "file:../../client/ts",
20-
"@ngrok/ngrok": "1.4.1",
2120
"@types/jest": "29.5.14",
2221
"chalk": "4.1.2",
2322
"cli-table3": "0.6.5",
2423
"cookie-parser": "1.4.7",
2524
"cors": "2.8.5",
2625
"dotenv": "16.4.7",
27-
"jest": "29.7.0",
28-
"ts-jest": "29.2.5",
2926
"envfile": "7.1.0",
3027
"express": "4.21.2",
28+
"jest": "29.7.0",
3129
"jose": "5.9.6",
3230
"nodemon": "3.0.1",
3331
"open": "10.1.0",
3432
"pug": "3.0.3",
33+
"ts-jest": "29.2.5",
3534
"webpack-cli": "5.1.4",
36-
"webpack-dev-server": "5.2.0",
35+
"webpack-dev-server": "5.2.2",
3736
"yargs": "17.7.2"
3837
},
3938
"devDependencies": {

demos/common/scripts/app-runner.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Context } from "./context";
22
import * as chalk from "chalk";
33
import * as Table from "cli-table3";
4-
import * as ngrok from "@ngrok/ngrok";
54
import * as webpack from "webpack";
65
import * as WebpackDevServer from "webpack-dev-server";
76
import * as nodemon from "nodemon";
@@ -53,31 +52,7 @@ export class AppRunner {
5352
});
5453
});
5554

56-
if (ctx.ngrokEnabled) {
57-
console.log(
58-
warnChalk("Warning:"),
59-
`ngrok exposes a local port via a public URL. Be mindful of what's exposed and shut down the server when it's not in use.\n`,
60-
);
61-
}
62-
63-
let url = ctx.backendUrl;
64-
if (ctx.ngrokEnabled) {
65-
try {
66-
const ngrokListener = await ngrok.forward({
67-
addr: ctx.backendPort,
68-
// requires an `NGROK_AUTHTOKEN` env var to be set
69-
authtoken_from_env: true,
70-
});
71-
url = ngrokListener.url() ?? url;
72-
} catch (err) {
73-
console.log(
74-
errorChalk("Error:"),
75-
`Unable to start ngrok server: ${err}`,
76-
);
77-
}
78-
}
79-
80-
table.push(["Base URL (Backend)", linkChalk(url)]);
55+
table.push(["Base URL (Backend)", linkChalk(ctx.backendUrl)]);
8156
};
8257

8358
private readonly runWebpackDevServer = async (

demos/common/scripts/context.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import * as fs from "fs";
22
import * as path from "path";
33

4-
type CliArgs = {
5-
example?: string;
6-
ngrok?: boolean;
7-
};
8-
94
export class Context {
10-
constructor(
11-
private readonly args: CliArgs,
12-
private readonly rootDir: string,
13-
) {}
5+
constructor(private readonly rootDir: string) {}
146

157
get srcDir() {
168
const src = path.join(this.rootDir, "frontend", "src");
@@ -32,10 +24,6 @@ export class Context {
3224
return index;
3325
}
3426

35-
get ngrokEnabled() {
36-
return !!this.args.ngrok;
37-
}
38-
3927
get frontendUrl(): string {
4028
return process.env.FRONTEND_URL!;
4129
}

demos/ecommerce_shop/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ A lightweight e-commerce shop demo that showcases how to integrate with the Canv
1010
- Creating individual designs in custom sizes from existing products.
1111
- Create multiple designs at once by adding products to your Canva Brand Templates.
1212

13-
For **setup instructions** refer to the steps in the main README:
13+
## Brand Templates Setup
1414

15-
<https://github.com/canva-sdks/canva-connect-api-starter-kit/blob/main/README.md#demos-e-commerce-shop>
15+
To get started with Brand Templates, you can install sample templates from [this Brand Template deck](https://www.canva.com/design/DAGGkcb61HQ/OJhMIQrmz2daIoxo8u3T2g/view).
16+
17+
[See the main README for e-commerce shop demo instructions](../../README.md#demos-e-commerce-shop)

demos/ecommerce_shop/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
"ts-loader": "9.5.2",
4444
"typescript": "5.5.4",
4545
"url-loader": "4.1.1",
46-
"webpack-dev-server": "5.2.0"
46+
"webpack-dev-server": "5.2.2"
4747
}
4848
}

demos/ecommerce_shop/frontend/src/components/marketing/brand-template-selector.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,31 @@ export const BrandTemplateSelector = ({
5656
<Grid item={true} xs={12}>
5757
<Grid container={true} spacing={2}>
5858
<Grid item={true} xs={12} sm={7} md={9}>
59-
<Typography variant="h5">Select brand template</Typography>
59+
<Typography variant="h5">Select Brand Template</Typography>
6060
</Grid>
6161
<Grid item={true} xs={12} sm={5} md={3}>
62-
<DeveloperNote info="Brand templates are only available to Canva Enterprise users." />
62+
<DeveloperNote info="Brand Templates are only available to Canva Enterprise users." />
6363
</Grid>
6464
</Grid>
6565
</Grid>
66+
<Grid item={true} xs={12}>
67+
<Paper
68+
variant="outlined"
69+
sx={{ padding: 2, bgcolor: "background.default" }}
70+
>
71+
<Typography variant="body2" color="text.secondary">
72+
Need sample Brand Templates? Install them from{" "}
73+
<Link
74+
href="https://www.canva.com/design/DAGGkcb61HQ/OJhMIQrmz2daIoxo8u3T2g/view"
75+
target="_blank"
76+
rel="noopener noreferrer"
77+
>
78+
this Brand Template deck
79+
</Link>
80+
.
81+
</Typography>
82+
</Paper>
83+
</Grid>
6684
{!brandTemplates.length ? (
6785
<EmptyState onClose={onClose} />
6886
) : (
@@ -119,17 +137,10 @@ const EmptyState = ({ onClose }: { onClose: () => void }) => (
119137
gap={3}
120138
>
121139
<Stack spacing={2}>
122-
<Typography variant="h6">Don’t see any brand templates?</Typography>
140+
<Typography variant="h6">Don’t see any Brand Templates?</Typography>
123141
<Typography variant="body1">
124-
Follow the instructions{" "}
125-
<Link
126-
href="https://www.canva.com/design/DAGGkcb61HQ/OJhMIQrmz2daIoxo8u3T2g/view"
127-
target="_blank"
128-
rel="noopener noreferrer"
129-
>
130-
here
131-
</Link>{" "}
132-
to install sample templates to your brand folder.
142+
Check the help section above for instructions on installing sample
143+
templates.
133144
</Typography>
134145
<Box>
135146
<DemoButton

demos/ecommerce_shop/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
},
3333
"devDependencies": {
3434
"@eslint/js": "9.23.0",
35-
"@ngrok/ngrok": "1.4.1",
3635
"@types/cookie-parser": "1.4.8",
3736
"@types/jest": "29.5.14",
3837
"@types/node": "20.10.0",
@@ -56,7 +55,7 @@
5655
"typescript": "5.5.4",
5756
"typescript-eslint": "8.27.0",
5857
"webpack-cli": "5.1.4",
59-
"webpack-dev-server": "5.2.0",
58+
"webpack-dev-server": "5.2.2",
6059
"yargs": "17.7.2"
6160
}
6261
}

0 commit comments

Comments
 (0)