@canva/cli 0.0.1-beta.3 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -110
- package/cli.js +422 -358
- package/package.json +1 -1
- package/templates/base/eslint.config.mjs +0 -2
- package/templates/base/package.json +22 -19
- package/templates/common/.gitignore.template +5 -6
- package/templates/common/.nvmrc +1 -0
- package/templates/common/.prettierrc +21 -0
- package/templates/common/.vscode/extensions.json +6 -0
- package/templates/common/README.md +4 -7
- package/templates/common/conf/eslint-general.mjs +26 -0
- package/templates/common/conf/eslint-i18n.mjs +18 -3
- package/templates/dam/package.json +23 -23
- package/templates/gen_ai/README.md +1 -40
- package/templates/gen_ai/backend/routers/image.ts +3 -3
- package/templates/gen_ai/backend/server.ts +0 -7
- package/templates/gen_ai/eslint.config.mjs +0 -2
- package/templates/gen_ai/package.json +24 -24
- package/templates/gen_ai/src/api/api.ts +24 -79
- package/templates/gen_ai/src/components/footer.messages.ts +0 -5
- package/templates/gen_ai/src/components/footer.tsx +7 -25
- package/templates/gen_ai/src/components/index.ts +0 -1
- package/templates/gen_ai/src/components/loading_results.tsx +4 -8
- package/templates/gen_ai/src/context/app_context.tsx +5 -33
- package/templates/gen_ai/src/context/context.messages.ts +1 -12
- package/templates/hello_world/eslint.config.mjs +0 -2
- package/templates/hello_world/package.json +18 -18
- package/templates/gen_ai/backend/routers/oauth.ts +0 -393
- package/templates/gen_ai/src/components/logged_in_status.tsx +0 -44
- package/templates/gen_ai/src/services/auth.tsx +0 -26
- package/templates/gen_ai/src/services/index.ts +0 -1
package/package.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"author": "Canva Pty Ltd.",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@canva/app-ui-kit": "^4.
|
|
10
|
-
"@canva/asset": "^
|
|
11
|
-
"@canva/design": "^1.
|
|
12
|
-
"@canva/error": "^
|
|
13
|
-
"@canva/platform": "^
|
|
14
|
-
"@canva/user": "^
|
|
15
|
-
"cookie-parser": "1.4.
|
|
9
|
+
"@canva/app-ui-kit": "^4.2.0",
|
|
10
|
+
"@canva/asset": "^2.0.0",
|
|
11
|
+
"@canva/design": "^2.1.0",
|
|
12
|
+
"@canva/error": "^2.0.0",
|
|
13
|
+
"@canva/platform": "^2.0.0",
|
|
14
|
+
"@canva/user": "^2.0.0",
|
|
15
|
+
"cookie-parser": "1.4.7",
|
|
16
16
|
"react": "18.3.1",
|
|
17
17
|
"react-dom": "18.3.1"
|
|
18
18
|
},
|
|
@@ -21,26 +21,26 @@
|
|
|
21
21
|
"@svgr/webpack": "8.1.0",
|
|
22
22
|
"@types/debug": "4.1.12",
|
|
23
23
|
"@types/express": "4.17.21",
|
|
24
|
-
"@types/express-serve-static-core": "4.19.
|
|
25
|
-
"@types/jest": "29.5.
|
|
26
|
-
"@types/jsonwebtoken": "9.0.
|
|
24
|
+
"@types/express-serve-static-core": "4.19.6",
|
|
25
|
+
"@types/jest": "29.5.13",
|
|
26
|
+
"@types/jsonwebtoken": "9.0.7",
|
|
27
27
|
"@types/node": "20.10.0",
|
|
28
28
|
"@types/node-fetch": "2.6.11",
|
|
29
29
|
"@types/node-forge": "1.3.11",
|
|
30
30
|
"@types/nodemon": "1.19.6",
|
|
31
31
|
"@types/prompts": "2.4.9",
|
|
32
|
-
"@types/react": "18.3.
|
|
33
|
-
"@types/react-dom": "18.3.
|
|
32
|
+
"@types/react": "18.3.11",
|
|
33
|
+
"@types/react-dom": "18.3.1",
|
|
34
34
|
"@types/webpack-env": "1.18.5",
|
|
35
35
|
"chalk": "4.1.2",
|
|
36
36
|
"cli-table3": "0.6.5",
|
|
37
37
|
"css-loader": "7.1.2",
|
|
38
38
|
"css-modules-typescript-loader": "4.0.1",
|
|
39
|
-
"cssnano": "7.0.
|
|
40
|
-
"debug": "4.3.
|
|
39
|
+
"cssnano": "7.0.6",
|
|
40
|
+
"debug": "4.3.7",
|
|
41
41
|
"dotenv": "16.4.5",
|
|
42
42
|
"exponential-backoff": "3.1.1",
|
|
43
|
-
"express": "4.
|
|
43
|
+
"express": "4.21.1",
|
|
44
44
|
"express-basic-auth": "1.2.1",
|
|
45
45
|
"jest": "29.7.0",
|
|
46
46
|
"jsonwebtoken": "9.0.2",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"prompts": "2.4.2",
|
|
55
55
|
"style-loader": "4.0.0",
|
|
56
56
|
"terser-webpack-plugin": "5.3.10",
|
|
57
|
-
"ts-jest": "29.2.
|
|
57
|
+
"ts-jest": "29.2.5",
|
|
58
58
|
"ts-loader": "9.5.1",
|
|
59
59
|
"ts-node": "10.9.2",
|
|
60
60
|
"typescript": "5.5.4",
|
|
61
61
|
"url-loader": "4.1.1",
|
|
62
|
-
"webpack": "5.
|
|
62
|
+
"webpack": "5.95.0",
|
|
63
63
|
"webpack-cli": "5.1.4",
|
|
64
|
-
"webpack-dev-server": "5.0
|
|
64
|
+
"webpack-dev-server": "5.1.0",
|
|
65
65
|
"yargs": "17.7.2"
|
|
66
66
|
},
|
|
67
67
|
"keywords": [
|
|
@@ -72,7 +72,10 @@
|
|
|
72
72
|
"npm": "^9 || ^10"
|
|
73
73
|
},
|
|
74
74
|
"canvaCliMetadata": {
|
|
75
|
-
"
|
|
75
|
+
"metaFields": [
|
|
76
|
+
"name",
|
|
77
|
+
"version"
|
|
78
|
+
],
|
|
76
79
|
"inheritable": [
|
|
77
80
|
"author",
|
|
78
81
|
"license",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20.10.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"arrowParens": "always",
|
|
3
|
+
"bracketSpacing": true,
|
|
4
|
+
"endOfLine": "lf",
|
|
5
|
+
"htmlWhitespaceSensitivity": "css",
|
|
6
|
+
"insertPragma": false,
|
|
7
|
+
"singleAttributePerLine": false,
|
|
8
|
+
"bracketSameLine": false,
|
|
9
|
+
"jsxSingleQuote": false,
|
|
10
|
+
"printWidth": 80,
|
|
11
|
+
"proseWrap": "preserve",
|
|
12
|
+
"quoteProps": "as-needed",
|
|
13
|
+
"requirePragma": false,
|
|
14
|
+
"semi": true,
|
|
15
|
+
"singleQuote": false,
|
|
16
|
+
"tabWidth": 2,
|
|
17
|
+
"trailingComma": "all",
|
|
18
|
+
"useTabs": false,
|
|
19
|
+
"embeddedLanguageFormatting": "auto",
|
|
20
|
+
"experimentalTernaries": false
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For developers using vscode we recommend the following extensions. Following
|
|
3
|
+
// and listening to the formatting and linting guidelines can help with
|
|
4
|
+
// implementation quality and in some instances reduce app review timelines.
|
|
5
|
+
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
|
|
6
|
+
}
|
|
@@ -63,18 +63,15 @@ To preview apps in Safari:
|
|
|
63
63
|
1. Start the development server with HTTPS enabled:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
# Run the main app
|
|
67
66
|
npm start --use-https
|
|
68
|
-
|
|
69
|
-
# Run an example
|
|
70
|
-
npm start <example-name> --use-https
|
|
71
67
|
```
|
|
72
68
|
|
|
73
69
|
2. Navigate to <https://localhost:8080>.
|
|
74
70
|
3. Bypass the invalid security certificate warning:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
1. Click **Show details**.
|
|
72
|
+
2. Click **Visit website**.
|
|
73
|
+
4. In the Developer Portal, set the app's **Development URL** to <https://localhost:8080>.
|
|
74
|
+
5. Click preview (or refresh your app if it's already open).
|
|
78
75
|
|
|
79
76
|
You need to bypass the invalid security certificate warning every time you start the local server. A similar warning will appear in other browsers (and will need to be bypassed) whenever HTTPS is enabled.
|
|
80
77
|
|
|
@@ -179,6 +179,32 @@ export default [
|
|
|
179
179
|
"Apps are currently not allowed to open popups, or new tabs via browser APIs. Please use `requestOpenExternalUrl` from `@canva/platform` to link to external URLs. To learn more, see https://www.canva.dev/docs/apps/api/platform-request-open-external-url/",
|
|
180
180
|
},
|
|
181
181
|
],
|
|
182
|
+
"no-restricted-imports": [
|
|
183
|
+
"warn",
|
|
184
|
+
{
|
|
185
|
+
// Warn when importing static assets that increase bundle size
|
|
186
|
+
patterns: [
|
|
187
|
+
// Images
|
|
188
|
+
{
|
|
189
|
+
group: ["*.png", "*.jpg", "*.jpeg", "*.gif"],
|
|
190
|
+
message:
|
|
191
|
+
"Inline images increase app bundle size and degrade app performance. Wherever possible, please use a CDN or external hosting service to dynamically load assets.",
|
|
192
|
+
},
|
|
193
|
+
// Videos
|
|
194
|
+
{
|
|
195
|
+
group: ["*.mp4", "*.webm", "*.ogg"],
|
|
196
|
+
message:
|
|
197
|
+
"Inline videos increase app bundle size and degrade app performance. Wherever possible, please use a CDN or external hosting service to dynamically load assets.",
|
|
198
|
+
},
|
|
199
|
+
// Audio
|
|
200
|
+
{
|
|
201
|
+
group: ["*.mp3", "*.wav", "*.ogg"],
|
|
202
|
+
message:
|
|
203
|
+
"Inline audio files increase app bundle size and degrade app performance. Wherever possible, please use a CDN or external hosting service to dynamically load assets.",
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
],
|
|
182
208
|
"no-return-await": "error",
|
|
183
209
|
"no-throw-literal": "error",
|
|
184
210
|
"no-undef-init": "error",
|
|
@@ -7,7 +7,22 @@ export default [
|
|
|
7
7
|
},
|
|
8
8
|
rules: {
|
|
9
9
|
"formatjs/no-invalid-icu": "error",
|
|
10
|
-
"formatjs/no-literal-string-in-jsx":
|
|
10
|
+
"formatjs/no-literal-string-in-jsx": [
|
|
11
|
+
2,
|
|
12
|
+
{
|
|
13
|
+
props: {
|
|
14
|
+
// These rules are for @canva/app-ui-kit components.
|
|
15
|
+
// For your own components, suppress any false positives using eslint ignore comments.
|
|
16
|
+
include: [
|
|
17
|
+
["*", "(*Label|label|alt)"],
|
|
18
|
+
["*", "(title|description|name|text)"],
|
|
19
|
+
["*", "(placeholder|additionalPlaceholder|defaultValue)"],
|
|
20
|
+
["FormField", "error"],
|
|
21
|
+
],
|
|
22
|
+
exclude: [["FormattedMessage", "description"]],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
11
26
|
"formatjs/enforce-description": "error",
|
|
12
27
|
"formatjs/enforce-default-message": "error",
|
|
13
28
|
"formatjs/enforce-placeholders": "error",
|
|
@@ -18,6 +33,6 @@ export default [
|
|
|
18
33
|
"formatjs/no-offset": "error",
|
|
19
34
|
"formatjs/blocklist-elements": [2, ["selectordinal"]],
|
|
20
35
|
"formatjs/no-complex-selectors": "error",
|
|
21
|
-
}
|
|
22
|
-
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
23
38
|
];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "digital_asset_management",
|
|
4
4
|
"description": "An example app leveraging @canva/app-components to develop a digital asset management (DAM) app.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"extract": "formatjs extract
|
|
6
|
+
"extract": "formatjs extract src/**/*.{ts,tsx} --out-file dist/messages_en.json",
|
|
7
7
|
"build": "webpack --config webpack.config.cjs --mode production && npm run extract",
|
|
8
8
|
"format": "prettier '**/*.{css,ts,tsx}' --no-config --write",
|
|
9
9
|
"format:check": "prettier '**/*.{css,ts,tsx}' --no-config --check --ignore-path",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"test:watch": "jest --watchAll"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@canva/app-components": "^1.0.0-beta.
|
|
20
|
-
"@canva/app-i18n-kit": "^0.0
|
|
21
|
-
"@canva/app-ui-kit": "^4.
|
|
19
|
+
"@canva/app-components": "^1.0.0-beta.29",
|
|
20
|
+
"@canva/app-i18n-kit": "^1.0.0",
|
|
21
|
+
"@canva/app-ui-kit": "^4.2.0",
|
|
22
22
|
"@canva/asset": "^2.0.0",
|
|
23
23
|
"@canva/design": "^2.1.0",
|
|
24
24
|
"@canva/platform": "^2.0.0",
|
|
25
25
|
"@canva/user": "^2.0.0",
|
|
26
|
-
"cookie-parser": "1.4.
|
|
26
|
+
"cookie-parser": "1.4.7",
|
|
27
27
|
"cors": "2.8.5",
|
|
28
28
|
"react": "18.3.1",
|
|
29
29
|
"react-dom": "18.3.1",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@eslint/eslintrc": "3.1.0",
|
|
34
|
-
"@eslint/js": "9.
|
|
34
|
+
"@eslint/js": "9.12.0",
|
|
35
35
|
"@formatjs/cli": "6.2.12",
|
|
36
36
|
"@formatjs/ts-transformer": "3.13.14",
|
|
37
37
|
"@ngrok/ngrok": "1.4.1",
|
|
@@ -39,32 +39,32 @@
|
|
|
39
39
|
"@types/cors": "2.8.17",
|
|
40
40
|
"@types/debug": "4.1.12",
|
|
41
41
|
"@types/express": "4.17.21",
|
|
42
|
-
"@types/express-serve-static-core": "4.19.
|
|
43
|
-
"@types/jest": "29.5.
|
|
44
|
-
"@types/jsonwebtoken": "9.0.
|
|
42
|
+
"@types/express-serve-static-core": "4.19.6",
|
|
43
|
+
"@types/jest": "29.5.13",
|
|
44
|
+
"@types/jsonwebtoken": "9.0.7",
|
|
45
45
|
"@types/node": "20.10.0",
|
|
46
46
|
"@types/node-fetch": "2.6.11",
|
|
47
47
|
"@types/node-forge": "1.3.11",
|
|
48
48
|
"@types/nodemon": "1.19.6",
|
|
49
49
|
"@types/prompts": "2.4.9",
|
|
50
|
-
"@types/react": "18.3.
|
|
51
|
-
"@types/react-dom": "18.3.
|
|
50
|
+
"@types/react": "18.3.11",
|
|
51
|
+
"@types/react-dom": "18.3.1",
|
|
52
52
|
"@types/webpack-env": "1.18.5",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
54
|
-
"@typescript-eslint/parser": "8.
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "8.9.0",
|
|
54
|
+
"@typescript-eslint/parser": "8.9.0",
|
|
55
55
|
"chalk": "4.1.2",
|
|
56
56
|
"cli-table3": "0.6.5",
|
|
57
57
|
"css-loader": "7.1.2",
|
|
58
58
|
"css-modules-typescript-loader": "4.0.1",
|
|
59
|
-
"cssnano": "7.0.
|
|
60
|
-
"debug": "4.3.
|
|
59
|
+
"cssnano": "7.0.6",
|
|
60
|
+
"debug": "4.3.7",
|
|
61
61
|
"dotenv": "16.4.5",
|
|
62
|
-
"eslint": "
|
|
63
|
-
"eslint-plugin-formatjs": "
|
|
64
|
-
"eslint-plugin-jest": "28.8.
|
|
65
|
-
"eslint-plugin-react": "7.
|
|
62
|
+
"eslint": "9.12.0",
|
|
63
|
+
"eslint-plugin-formatjs": "5.0.0",
|
|
64
|
+
"eslint-plugin-jest": "28.8.3",
|
|
65
|
+
"eslint-plugin-react": "7.37.1",
|
|
66
66
|
"exponential-backoff": "3.1.1",
|
|
67
|
-
"express": "4.
|
|
67
|
+
"express": "4.21.1",
|
|
68
68
|
"express-basic-auth": "1.2.1",
|
|
69
69
|
"jest": "29.7.0",
|
|
70
70
|
"jsonwebtoken": "9.0.2",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
"prompts": "2.4.2",
|
|
79
79
|
"style-loader": "4.0.0",
|
|
80
80
|
"terser-webpack-plugin": "5.3.10",
|
|
81
|
-
"ts-jest": "29.2.
|
|
81
|
+
"ts-jest": "29.2.5",
|
|
82
82
|
"ts-loader": "9.5.1",
|
|
83
83
|
"ts-node": "10.9.2",
|
|
84
84
|
"typescript": "5.5.4",
|
|
85
85
|
"url-loader": "4.1.1",
|
|
86
|
-
"webpack": "5.
|
|
86
|
+
"webpack": "5.95.0",
|
|
87
87
|
"webpack-cli": "5.1.4",
|
|
88
|
-
"webpack-dev-server": "5.0
|
|
88
|
+
"webpack-dev-server": "5.1.0",
|
|
89
89
|
"yargs": "17.7.2"
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
## Run the development server with ngrok to use authentication with the app
|
|
2
|
-
|
|
3
|
-
These steps demonstrate how to start the local development server with ngrok and https.
|
|
4
|
-
|
|
5
|
-
From your app's root directory
|
|
6
|
-
|
|
7
|
-
1. Stop any running scripts, and run the following command to launch the backend and frontend development servers. The `--ngrok` parameter exposes the backend server via a publicly accessible URL.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm start --ngrok
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
2. After ngrok is running, copy your ngrok url
|
|
14
|
-
(e.g. `https://0000-0000.ngrok-free.app`) to the clipboard.
|
|
15
|
-
|
|
16
|
-
1. Go to your app in the [Developer Portal](https://www.canva.com/developers/apps).
|
|
17
|
-
2. Navigate to the "Authentication" section of your app.
|
|
18
|
-
3. Click the "Add provider" button under the "OAuth 2.0" tab
|
|
19
|
-
4. Configure the provider as follows:
|
|
20
|
-
- Provider: local (or name of your choice)
|
|
21
|
-
- Client ID: `client_id` (exactly this string, in a real app you'd have some opaque identifier)
|
|
22
|
-
- Client Secret: `client_secret` (same here)
|
|
23
|
-
- Authorization server URL: Your ngrok url followed by `/auth/authorize` e.g. `https://0000-0000.ngrok-free.app/auth/authorize`
|
|
24
|
-
- Token exchange URL: Your ngrok url followed by `/auth/token` e.g. `https://0000-0000.ngrok-free.app/auth/token`
|
|
25
|
-
- Revocation exchange URL: (leave blank)
|
|
26
|
-
- Proof of Key for Code Exchange (PKCE): off
|
|
27
|
-
Note: Your ngrok URL changes each time you restart ngrok. Keep these fields up to
|
|
28
|
-
date to ensure your example authentication step will run.
|
|
29
|
-
|
|
30
|
-
3. Navigate to your app at `https://www.canva.com/developers/apps` and make sure that under Configuration, App source is pointing to your localhost url.
|
|
31
|
-
|
|
32
|
-
4. Navigate to your app at `https://www.canva.com/developers/apps`, and click **Preview** to preview the app.
|
|
33
|
-
1. A new screen will appear asking if you want to authenticate.
|
|
34
|
-
Press **Connect** to start the authentication flow.
|
|
35
|
-
2. A ngrok screen may appear. If it does, select **Visit Site**
|
|
36
|
-
3. An authentication popup will appear. For the username, enter `username`, and
|
|
37
|
-
for the password enter `password`.
|
|
38
|
-
4. If successful, you will be redirected back to your app.
|
|
39
|
-
|
|
40
1
|
## Generative AI Template
|
|
41
2
|
|
|
42
3
|
This template captures best practices for improving user experience in your application.
|
|
@@ -59,7 +20,7 @@ In this template, we've included a basic obscenity filter to stop users from cre
|
|
|
59
20
|
|
|
60
21
|
### Backend
|
|
61
22
|
|
|
62
|
-
This template includes a simple Express server as a sample backend. Please note that this server is not production-ready, and we advise using it solely for instructional purposes to demonstrate API calls.
|
|
23
|
+
This template includes a simple Express server as a sample backend. Please note that this server is not production-ready, and we advise using it solely for instructional purposes to demonstrate API calls. If you require authentication for your app, we recommend looking at the authentication example provided in the [starter kit](https://github.com/canva-sdks/canva-apps-sdk-starter-kit).
|
|
63
24
|
|
|
64
25
|
### Thumbnails
|
|
65
26
|
|
|
@@ -93,7 +93,7 @@ export const createImageRouter = () => {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* GET endpoint to retrieve user credits.
|
|
96
|
-
*
|
|
96
|
+
* Returns the current number of credits available to the user.
|
|
97
97
|
*/
|
|
98
98
|
router.get(Routes.CREDITS, async (req, res) => {
|
|
99
99
|
res.status(200).send({
|
|
@@ -103,7 +103,7 @@ export const createImageRouter = () => {
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* POST endpoint to purchase credits.
|
|
106
|
-
*
|
|
106
|
+
* Increments the user's credits by the number of credits in a bundle.
|
|
107
107
|
* This endpoint should be backed by proper input validation to prevent misuse.
|
|
108
108
|
*/
|
|
109
109
|
router.post(Routes.PURCHASE_CREDITS, async (req, res) => {
|
|
@@ -115,7 +115,7 @@ export const createImageRouter = () => {
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* GET endpoint to generate images based on a prompt.
|
|
118
|
-
*
|
|
118
|
+
* Generates images based on the provided prompt and adds a job to the processing queue.
|
|
119
119
|
* If there are not enough credits, it returns a 403 error.
|
|
120
120
|
* If the prompt parameter is missing, it returns a 400 error.
|
|
121
121
|
* Once the job is added to the queue, it returns a jobId that can be used to check the job status.
|
|
@@ -2,7 +2,6 @@ import * as express from "express";
|
|
|
2
2
|
import * as cors from "cors";
|
|
3
3
|
import { createBaseServer } from "../utils/backend/base_backend/create";
|
|
4
4
|
import { createImageRouter } from "./routers/image";
|
|
5
|
-
import { createAuthRouter } from "./routers/oauth";
|
|
6
5
|
|
|
7
6
|
async function main() {
|
|
8
7
|
const router = express.Router();
|
|
@@ -37,12 +36,6 @@ async function main() {
|
|
|
37
36
|
*/
|
|
38
37
|
router.use(cors());
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
* Add routes for authorisation.
|
|
42
|
-
*/
|
|
43
|
-
const authRouter = createAuthRouter();
|
|
44
|
-
router.use(authRouter);
|
|
45
|
-
|
|
46
39
|
/**
|
|
47
40
|
* Add routes for image generation.
|
|
48
41
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "gen_ai",
|
|
4
4
|
"description": "An example app demonstrating common patterns that you might use in a generative AI app.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"extract": "formatjs extract
|
|
6
|
+
"extract": "formatjs extract src/**/*.{ts,tsx} --out-file dist/messages_en.json",
|
|
7
7
|
"build": "webpack --config webpack.config.cjs --mode production && npm run extract",
|
|
8
8
|
"format": "prettier '**/*.{css,ts,tsx}' --no-config --write",
|
|
9
9
|
"format:check": "prettier '**/*.{css,ts,tsx}' --no-config --check --ignore-path",
|
|
@@ -16,57 +16,57 @@
|
|
|
16
16
|
"test:watch": "jest --watchAll"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@canva/app-i18n-kit": "^0.0
|
|
20
|
-
"@canva/app-ui-kit": "^4.
|
|
19
|
+
"@canva/app-i18n-kit": "^1.0.0",
|
|
20
|
+
"@canva/app-ui-kit": "^4.2.0",
|
|
21
21
|
"@canva/asset": "^2.0.0",
|
|
22
22
|
"@canva/design": "^2.1.0",
|
|
23
23
|
"@canva/platform": "^2.0.0",
|
|
24
24
|
"@canva/user": "^2.0.0",
|
|
25
|
-
"cookie-parser": "1.4.
|
|
25
|
+
"cookie-parser": "1.4.7",
|
|
26
26
|
"cors": "2.8.5",
|
|
27
|
-
"html-react-parser": "5.1.
|
|
27
|
+
"html-react-parser": "5.1.18",
|
|
28
28
|
"obscenity": "0.4.0",
|
|
29
29
|
"react": "18.3.1",
|
|
30
30
|
"react-dom": "18.3.1",
|
|
31
31
|
"react-error-boundary": "4.0.13",
|
|
32
32
|
"react-intl": "6.6.8",
|
|
33
|
-
"react-router-dom": "6.
|
|
33
|
+
"react-router-dom": "6.27.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@eslint/eslintrc": "3.1.0",
|
|
37
|
-
"@eslint/js": "9.
|
|
37
|
+
"@eslint/js": "9.12.0",
|
|
38
38
|
"@formatjs/cli": "6.2.12",
|
|
39
39
|
"@formatjs/ts-transformer": "3.13.14",
|
|
40
40
|
"@ngrok/ngrok": "1.4.1",
|
|
41
41
|
"@svgr/webpack": "8.1.0",
|
|
42
42
|
"@types/debug": "4.1.12",
|
|
43
43
|
"@types/express": "4.17.21",
|
|
44
|
-
"@types/express-serve-static-core": "4.19.
|
|
45
|
-
"@types/jest": "29.5.
|
|
46
|
-
"@types/jsonwebtoken": "9.0.
|
|
44
|
+
"@types/express-serve-static-core": "4.19.6",
|
|
45
|
+
"@types/jest": "29.5.13",
|
|
46
|
+
"@types/jsonwebtoken": "9.0.7",
|
|
47
47
|
"@types/node": "20.10.0",
|
|
48
48
|
"@types/node-fetch": "2.6.11",
|
|
49
49
|
"@types/node-forge": "1.3.11",
|
|
50
50
|
"@types/nodemon": "1.19.6",
|
|
51
51
|
"@types/prompts": "2.4.9",
|
|
52
|
-
"@types/react": "18.3.
|
|
53
|
-
"@types/react-dom": "18.3.
|
|
52
|
+
"@types/react": "18.3.11",
|
|
53
|
+
"@types/react-dom": "18.3.1",
|
|
54
54
|
"@types/webpack-env": "1.18.5",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
56
|
-
"@typescript-eslint/parser": "8.
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "8.9.0",
|
|
56
|
+
"@typescript-eslint/parser": "8.9.0",
|
|
57
57
|
"chalk": "4.1.2",
|
|
58
58
|
"cli-table3": "0.6.5",
|
|
59
59
|
"css-loader": "7.1.2",
|
|
60
60
|
"css-modules-typescript-loader": "4.0.1",
|
|
61
|
-
"cssnano": "7.0.
|
|
62
|
-
"debug": "4.3.
|
|
61
|
+
"cssnano": "7.0.6",
|
|
62
|
+
"debug": "4.3.7",
|
|
63
63
|
"dotenv": "16.4.5",
|
|
64
|
-
"eslint": "
|
|
65
|
-
"eslint-plugin-formatjs": "
|
|
66
|
-
"eslint-plugin-jest": "28.8.
|
|
67
|
-
"eslint-plugin-react": "7.
|
|
64
|
+
"eslint": "9.12.0",
|
|
65
|
+
"eslint-plugin-formatjs": "5.0.0",
|
|
66
|
+
"eslint-plugin-jest": "28.8.3",
|
|
67
|
+
"eslint-plugin-react": "7.37.1",
|
|
68
68
|
"exponential-backoff": "3.1.1",
|
|
69
|
-
"express": "4.
|
|
69
|
+
"express": "4.21.1",
|
|
70
70
|
"express-basic-auth": "1.2.1",
|
|
71
71
|
"jest": "29.7.0",
|
|
72
72
|
"jsonwebtoken": "9.0.2",
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
"prompts": "2.4.2",
|
|
81
81
|
"style-loader": "4.0.0",
|
|
82
82
|
"terser-webpack-plugin": "5.3.10",
|
|
83
|
-
"ts-jest": "29.2.
|
|
83
|
+
"ts-jest": "29.2.5",
|
|
84
84
|
"ts-loader": "9.5.1",
|
|
85
85
|
"ts-node": "10.9.2",
|
|
86
86
|
"typescript": "5.5.4",
|
|
87
87
|
"url-loader": "4.1.1",
|
|
88
|
-
"webpack": "5.
|
|
88
|
+
"webpack": "5.95.0",
|
|
89
89
|
"webpack-cli": "5.1.4",
|
|
90
|
-
"webpack-dev-server": "5.0
|
|
90
|
+
"webpack-dev-server": "5.1.0",
|
|
91
91
|
"yargs": "17.7.2"
|
|
92
92
|
}
|
|
93
93
|
}
|