create-blocklet 0.9.4 → 0.9.6

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.
Files changed (75) hide show
  1. package/index.js +70 -0
  2. package/package.json +1 -1
  3. package/templates/base-readme.md +103 -0
  4. package/templates/did-wallet-dapp/.eslintrc.js +7 -0
  5. package/templates/did-wallet-dapp/README.md +32 -0
  6. package/templates/did-wallet-dapp/api/dev.js +8 -0
  7. package/templates/did-wallet-dapp/api/functions/app.js +65 -0
  8. package/templates/did-wallet-dapp/api/index.js +13 -0
  9. package/templates/did-wallet-dapp/api/libs/constant.js +1 -0
  10. package/templates/did-wallet-dapp/api/routes/user.js +30 -0
  11. package/templates/did-wallet-dapp/blocklet.md +3 -0
  12. package/templates/did-wallet-dapp/blocklet.yml +59 -0
  13. package/templates/did-wallet-dapp/index.html +16 -0
  14. package/templates/did-wallet-dapp/package.json +84 -0
  15. package/templates/did-wallet-dapp/src/app.jsx +38 -0
  16. package/templates/did-wallet-dapp/src/assets/blocklet.svg +16 -0
  17. package/templates/did-wallet-dapp/src/assets/react.svg +1 -0
  18. package/templates/did-wallet-dapp/src/assets/vite.svg +1 -0
  19. package/templates/did-wallet-dapp/src/assets/wallet.png +0 -0
  20. package/templates/did-wallet-dapp/src/components/layout.jsx +28 -0
  21. package/templates/did-wallet-dapp/src/global.css +79 -0
  22. package/templates/did-wallet-dapp/src/index.jsx +6 -0
  23. package/templates/did-wallet-dapp/src/libs/api.js +7 -0
  24. package/templates/did-wallet-dapp/src/libs/session.js +13 -0
  25. package/templates/did-wallet-dapp/src/locales/en.js +13 -0
  26. package/templates/did-wallet-dapp/src/locales/index.js +4 -0
  27. package/templates/did-wallet-dapp/src/locales/zh.js +13 -0
  28. package/templates/did-wallet-dapp/src/pages/home/index.css +39 -0
  29. package/templates/did-wallet-dapp/src/pages/home/index.jsx +57 -0
  30. package/templates/did-wallet-dapp/src/pages/profile.jsx +136 -0
  31. package/templates/did-wallet-dapp/template-info.json +12 -0
  32. package/templates/did-wallet-dapp/vite.config.js +14 -0
  33. package/templates/did-wallet-dapp/vite.config.server.js +9 -0
  34. package/templates/express-api/README.md +2 -124
  35. package/templates/html-static/README.md +3 -125
  36. package/templates/monorepo/README.md +8 -8
  37. package/templates/nestjs-api/README.md +2 -123
  38. package/templates/nextjs-dapp/README.md +2 -125
  39. package/templates/react-dapp/README.md +2 -124
  40. package/templates/react-dapp/package.json +1 -1
  41. package/templates/react-dapp-ts/README.md +2 -125
  42. package/templates/react-dapp-ts/package.json +1 -1
  43. package/templates/react-gun-dapp/README.md +2 -125
  44. package/templates/react-gun-dapp/package.json +1 -1
  45. package/templates/react-static/README.md +2 -125
  46. package/templates/react-static/package.json +1 -1
  47. package/templates/solidjs-dapp/README.md +2 -125
  48. package/templates/solidjs-dapp/package.json +1 -1
  49. package/templates/solidjs-static/README.md +2 -123
  50. package/templates/solidjs-static/package.json +1 -1
  51. package/templates/svelte-dapp/README.md +2 -124
  52. package/templates/svelte-dapp/package.json +1 -1
  53. package/templates/svelte-static/README.md +2 -125
  54. package/templates/svelte-static/package.json +1 -1
  55. package/templates/todo-list-example/api/src/index.ts +1 -1
  56. package/templates/todo-list-example/api/src/libs/auth.ts +1 -1
  57. package/templates/todo-list-example/api/src/routes/index.ts +1 -0
  58. package/templates/todo-list-example/api/src/routes/todo-list/$get.ts +17 -14
  59. package/templates/todo-list-example/api/src/routes/todo-list/$put.ts +9 -3
  60. package/templates/todo-list-example/api/src/routes/todo-list/index.ts +1 -0
  61. package/templates/todo-list-example/package.json +27 -27
  62. package/templates/todo-list-example/src/app.tsx +3 -2
  63. package/templates/todo-list-example/src/contexts/session.tsx +1 -1
  64. package/templates/todo-list-example/src/pages/required-login.tsx +1 -0
  65. package/templates/todo-list-example/src/pages/todo-list.tsx +16 -6
  66. package/templates/vue-dapp/README.md +2 -125
  67. package/templates/vue-dapp/package.json +1 -1
  68. package/templates/vue-static/README.md +2 -125
  69. package/templates/vue-static/package.json +1 -1
  70. package/templates/vue-ts-static/README.md +2 -124
  71. package/templates/vue-ts-static/package.json +1 -1
  72. package/templates/vue2-dapp/README.md +2 -125
  73. package/templates/vue2-dapp/package.json +1 -1
  74. package/templates/vue2-static/README.md +2 -125
  75. package/templates/vue2-static/package.json +1 -1
@@ -1,10 +1,7 @@
1
- # Getting Started with Create Blocklet
2
-
3
- This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
4
-
1
+ ## PROJECT_DESCRIPTION
5
2
  This blocklet is a static project, which means this is a frontend application. It's contained `client` code.
6
3
 
7
- ## File Structure
4
+ ## FILE_STRUCTURE
8
5
 
9
6
  - public/ - static files
10
7
  - favicon.ico - favicon
@@ -24,122 +21,3 @@ This blocklet is a static project, which means this is a frontend application. I
24
21
  - README.md - A guide for this blocklet
25
22
  - version - Version file
26
23
 
27
- ## Development
28
-
29
- 1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
30
-
31
- Blocklet needs blocklet server as a dependency. So you need to install it first.
32
- `npm install -g @blocklet/cli`
33
- See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
34
-
35
- 2. Init blocklet server & start blocklet server
36
-
37
- Before starting an blocklet server, you need to init blocklet server.
38
- `blocklet server init --mode=debug`
39
- `blocklet server start`
40
- See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
41
-
42
- 3. Go to the project directory `cd [name]`
43
- 4. Install dependencies: `npm install` or `yarn`
44
- 5. Start development server: `blocklet dev`
45
-
46
- ## Bundle
47
-
48
- After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
49
-
50
- ## Deploy
51
-
52
- - If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
53
- > Or you can simply use `npm run deploy` command.
54
- - If you want to deploy this blocklet to remote blocklet server, you can use the command below.
55
-
56
- ```shell
57
- blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
58
- ```
59
-
60
- > Make sure the blocklet is bundled before deployment.
61
-
62
- ## Upload to blocklet store
63
-
64
- - If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
65
-
66
- Bump version at first.
67
-
68
- ```shell
69
- make bump-version
70
- ```
71
-
72
- Then config blocklet store url.
73
- You can use those store url in below.
74
-
75
- 1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
76
- 2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
77
- 3. A blocklet store started by yourself.
78
- > Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
79
-
80
- ```shell
81
- blocklet config set store {store url}
82
- ```
83
-
84
- Get a `accessToken` from blocklet store.
85
-
86
- > Why we need a `accessToken`?
87
- > A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
88
-
89
- Set `accessToken` to blocklet config
90
-
91
- ```shell
92
- blocklet config set accessToken {accessToken}
93
- ```
94
-
95
- Upload a new version to a store.
96
-
97
- > Make sure the blocklet is bundled before upload.
98
-
99
- ```shell
100
- blocklet upload
101
- ```
102
-
103
- Or you can simply use `npm run upload` command.
104
-
105
- - You also can upload a new version to blocklet store by Github CI.
106
- Bump version at first.
107
-
108
- ```shell
109
- make bump-version
110
- ```
111
-
112
- Push your code to Github main/master branch, or make a pull request to the main/master branch.
113
- The CI workflow will automatically upload a new version to a store.
114
-
115
- ## Q & A
116
-
117
- 1. Q: How to change a blocklet's name?
118
-
119
- A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
120
-
121
- You can also change the `title` field and `description` field in the `blocklet.yml` file.
122
-
123
- Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
124
-
125
- Replace this command `"bundle": "vite build --base /.blocklet/proxy/<%= did %>",` in `package.json`
126
-
127
- Replace `did` field in the `blocklet.yml`
128
-
129
- 2. Q: How to change a blocklet's logo?
130
-
131
- Change the `logo.png` file root folder.
132
-
133
- Or you can change the `logo` field in the `blocklet.yml` file.
134
-
135
- > Make sure you have added the logo path to the `blocklet.yml` file `files` field.
136
-
137
- ## Learn More
138
-
139
- - Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
140
- - Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
141
-
142
- ## License
143
-
144
- The code is licensed under the Apache 2.0 license found in the
145
- [LICENSE](LICENSE) file.
@@ -43,7 +43,7 @@
43
43
  "simple-git-hooks": "^2.11.1",
44
44
  "svelte": "^4.2.18",
45
45
  "vite": "^5.3.5",
46
- "vite-plugin-blocklet": "^0.9.4",
46
+ "vite-plugin-blocklet": "^0.9.6",
47
47
  "zx": "^8.1.4"
48
48
  },
49
49
  "lint-staged": {
@@ -1,10 +1,7 @@
1
- # Getting Started with Create Blocklet
2
-
3
- This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
4
-
1
+ ## PROJECT_DESCRIPTION
5
2
  This blocklet is a static project, which means this is a frontend application. It's contained `client` code.
6
3
 
7
- ## File Structure
4
+ ## FILE_STRUCTURE
8
5
 
9
6
  - public/ - static files
10
7
  - favicon.ico - favicon
@@ -23,123 +20,3 @@ This blocklet is a static project, which means this is a frontend application. I
23
20
  - package.json - Npm package file
24
21
  - README.md - A guide for this blocklet
25
22
  - version - Version file
26
-
27
- ## Development
28
-
29
- 1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
30
-
31
- Blocklet needs blocklet server as a dependency. So you need to install it first.
32
- `npm install -g @blocklet/cli`
33
- See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
34
-
35
- 2. Init blocklet server & start blocklet server
36
-
37
- Before starting an blocklet server, you need to init blocklet server.
38
- `blocklet server init --mode=debug`
39
- `blocklet server start`
40
- See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
41
-
42
- 3. Go to the project directory `cd [name]`
43
- 4. Install dependencies: `npm install` or `yarn`
44
- 5. Start development server: `blocklet dev`
45
-
46
- ## Bundle
47
-
48
- After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
49
-
50
- ## Deploy
51
-
52
- - If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
53
- > Or you can simply use `npm run deploy` command.
54
- - If you want to deploy this blocklet to remote blocklet server, you can use the command below.
55
-
56
- ```shell
57
- blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
58
- ```
59
-
60
- > Make sure the blocklet is bundled before deployment.
61
-
62
- ## Upload to blocklet store
63
-
64
- - If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
65
-
66
- Bump version at first.
67
-
68
- ```shell
69
- make bump-version
70
- ```
71
-
72
- Then config blocklet store url.
73
- You can use those store url in below.
74
-
75
- 1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
76
- 2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
77
- 3. A blocklet store started by yourself.
78
- > Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
79
-
80
- ```shell
81
- blocklet config set store {store url}
82
- ```
83
-
84
- Get a `accessToken` from blocklet store.
85
-
86
- > Why we need a `accessToken`?
87
- > A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
88
-
89
- Set `accessToken` to blocklet config
90
-
91
- ```shell
92
- blocklet config set accessToken {accessToken}
93
- ```
94
-
95
- Upload a new version to a store.
96
-
97
- > Make sure the blocklet is bundled before upload.
98
-
99
- ```shell
100
- blocklet upload
101
- ```
102
-
103
- Or you can simply use `npm run upload` command.
104
-
105
- - You also can upload a new version to blocklet store by Github CI.
106
- Bump version at first.
107
-
108
- ```shell
109
- make bump-version
110
- ```
111
-
112
- Push your code to Github main/master branch, or make a pull request to the main/master branch.
113
- The CI workflow will automatically upload a new version to a store.
114
-
115
- ## Q & A
116
-
117
- 1. Q: How to change a blocklet's name?
118
-
119
- A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
120
-
121
- You can also change the `title` field and `description` field in the `blocklet.yml` file.
122
-
123
- Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
124
-
125
- Replace this command `"bundle": "vite build --base /.blocklet/proxy/<%= did %>",` in `package.json`
126
-
127
- Replace `did` field in the `blocklet.yml`
128
-
129
- 2. Q: How to change a blocklet's logo?
130
-
131
- Change the `logo.png` file root folder.
132
-
133
- Or you can change the `logo` field in the `blocklet.yml` file.
134
-
135
- > Make sure you have added the logo path to the `blocklet.yml` file `files` field.
136
-
137
- ## Learn More
138
-
139
- - Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
140
- - Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
141
-
142
- ## License
143
-
144
- The code is licensed under the Apache 2.0 license found in the
145
- [LICENSE](LICENSE) file.
@@ -24,7 +24,7 @@
24
24
  "simple-git-hooks": "^2.11.1",
25
25
  "svelte": "^4.2.18",
26
26
  "vite": "^5.3.5",
27
- "vite-plugin-blocklet": "^0.9.4",
27
+ "vite-plugin-blocklet": "^0.9.6",
28
28
  "zx": "^8.1.4"
29
29
  },
30
30
  "lint-staged": {
@@ -2,11 +2,11 @@ import 'express-async-errors';
2
2
 
3
3
  import path from 'path';
4
4
 
5
+ import fallback from '@blocklet/sdk/lib/middlewares/fallback';
5
6
  import cookieParser from 'cookie-parser';
6
7
  import cors from 'cors';
7
8
  import dotenv from 'dotenv-flow';
8
9
  import express, { ErrorRequestHandler } from 'express';
9
- import fallback from '@blocklet/sdk/lib/middlewares/fallback';
10
10
 
11
11
  import logger from './libs/logger';
12
12
  import routes from './routes';
@@ -1,11 +1,11 @@
1
1
  import path from 'path';
2
2
 
3
3
  import AuthStorage from '@arcblock/did-auth-storage-nedb';
4
+ import { AuthService } from '@blocklet/sdk';
4
5
  import getWallet from '@blocklet/sdk/lib/wallet';
5
6
  import WalletAuthenticator from '@blocklet/sdk/lib/wallet-authenticator';
6
7
  import WalletHandler from '@blocklet/sdk/lib/wallet-handler';
7
8
 
8
- import { AuthService } from '@blocklet/sdk';
9
9
  import env from './env';
10
10
 
11
11
  export const wallet = getWallet();
@@ -1,5 +1,6 @@
1
1
  import middleware from '@blocklet/sdk/lib/middlewares';
2
2
  import { Router } from 'express';
3
+
3
4
  import todoListRouter from './todo-list';
4
5
 
5
6
  const router = Router();
@@ -1,6 +1,7 @@
1
- import type { Request, Response } from 'express';
2
1
  import { GetObjectCommand, SpaceClient } from '@did-space/client';
3
2
  import { streamToString } from '@did-space/core';
3
+ import type { Request, Response } from 'express';
4
+
4
5
  import { authService, wallet } from '../../libs/auth';
5
6
 
6
7
  export default async function $get(req: Request, res: Response) {
@@ -14,18 +15,20 @@ export default async function $get(req: Request, res: Response) {
14
15
  // @ts-ignore
15
16
  endpoint: user.didSpace.endpoint,
16
17
  });
17
- try {
18
- const { data } = await spaceClient.send(
19
- new GetObjectCommand({
20
- key: 'todo-list.json',
21
- }),
22
- );
23
- return res.json({ todoList: JSON.parse(await streamToString(data)) });
24
- } catch (error) {
25
- if (error.message.includes('404')) {
26
- return res.json({ todoList: [] });
27
- }
28
- console.error(error);
29
- return res.status(400).send(error.message);
18
+
19
+ const output = await spaceClient.send(
20
+ new GetObjectCommand({
21
+ key: 'todo-list.json',
22
+ }),
23
+ );
24
+
25
+ if (output.statusCode === 200) {
26
+ return res.json({ todoList: JSON.parse(await streamToString(output.data)) });
27
+ }
28
+
29
+ if (output.statusCode === 404) {
30
+ return res.json({ todoList: [] });
30
31
  }
32
+
33
+ return res.status(output.statusCode).send(output.statusMessage);
31
34
  }
@@ -1,14 +1,15 @@
1
1
  import { PutObjectCommand, SpaceClient } from '@did-space/client';
2
2
  import type { Request, Response } from 'express';
3
3
  import isArray from 'lodash/isArray';
4
+
4
5
  import { authService, wallet } from '../../libs/auth';
5
6
 
6
7
  export default async function $put(req: Request, res: Response) {
7
8
  if (!isArray(req.body.todoList)) {
8
- throw new Error('TodoList must be an array');
9
+ return res.status(400).send('TodoList must be an array');
9
10
  }
10
11
 
11
- const { user } = await authService.getUser(req.user?.did as string);
12
+ const { user } = await authService.getUser(req.user!.did as string);
12
13
  if (!user?.didSpace?.endpoint) {
13
14
  return res.status(404).send('DID Spaces endpoint does not exist. Log in again to complete the authorization');
14
15
  }
@@ -18,12 +19,17 @@ export default async function $put(req: Request, res: Response) {
18
19
  // @ts-ignore
19
20
  endpoint: user.didSpace.endpoint,
20
21
  });
21
- await spaceClient.send(
22
+
23
+ const output = await spaceClient.send(
22
24
  new PutObjectCommand({
23
25
  key: 'todo-list.json',
24
26
  data: JSON.stringify(req.body.todoList),
25
27
  }),
26
28
  );
27
29
 
30
+ if (output.statusCode !== 200) {
31
+ return res.status(output.statusCode).send(output.statusMessage);
32
+ }
33
+
28
34
  return res.send();
29
35
  }
@@ -1,5 +1,6 @@
1
1
  import middleware from '@blocklet/sdk/lib/middlewares';
2
2
  import { Router } from 'express';
3
+
3
4
  import $get from './$get';
4
5
  import $put from './$put';
5
6
 
@@ -40,64 +40,64 @@
40
40
  "dependencies": {
41
41
  "@arcblock/did-auth": "^1.18.135",
42
42
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
43
- "@blocklet/sdk": "^1.16.30",
44
- "@did-space/client": "^0.5.11",
45
- "@did-space/core": "^0.5.11",
43
+ "@blocklet/sdk": "^1.16.31",
44
+ "@did-space/client": "^0.5.44",
45
+ "@did-space/core": "^0.5.44",
46
46
  "@ocap/client": "^1.18.135",
47
47
  "@ocap/mcrypto": "^1.18.135",
48
48
  "@ocap/wallet": "^1.18.135",
49
- "axios": "^1.7.2",
49
+ "axios": "^1.7.7",
50
50
  "cookie-parser": "^1.4.6",
51
51
  "cors": "^2.8.5",
52
52
  "dotenv-flow": "^4.1.0",
53
- "express": "^4.19.2",
53
+ "express": "^4.21.0",
54
54
  "express-async-errors": "^3.1.1",
55
55
  "lodash": "^4.17.21",
56
56
  "nanoid": "^5.0.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@arcblock/did-connect": "^2.10.26",
59
+ "@arcblock/did-connect": "^2.10.33",
60
60
  "@arcblock/eslint-config": "^0.3.2",
61
61
  "@arcblock/eslint-config-ts": "^0.3.2",
62
- "@arcblock/ux": "^2.10.26",
63
- "@blocklet/js-sdk": "^1.16.30",
64
- "@blocklet/ui-react": "^2.10.26",
65
- "@emotion/react": "^11.13.0",
62
+ "@arcblock/ux": "^2.10.33",
63
+ "@blocklet/js-sdk": "^1.16.31",
64
+ "@blocklet/ui-react": "^2.10.33",
65
+ "@emotion/react": "^11.13.3",
66
66
  "@emotion/styled": "^11.13.0",
67
- "@mui/icons-material": "^5.15.21",
68
- "@mui/material": "^5.15.21",
67
+ "@mui/icons-material": "^5.16.7",
68
+ "@mui/material": "^5.16.7",
69
69
  "@types/cookie-parser": "^1.4.7",
70
70
  "@types/cors": "^2.8.17",
71
71
  "@types/dotenv-flow": "^3.3.3",
72
72
  "@types/express": "^4.17.21",
73
73
  "@types/lodash": "^4.17.7",
74
- "@types/node": "^20.14.13",
75
- "@types/react": "^18.3.3",
74
+ "@types/node": "^20.16.5",
75
+ "@types/react": "^18.3.8",
76
76
  "@types/react-dom": "^18.3.0",
77
77
  "@types/react-toastify": "^4.1.0",
78
78
  "@vitejs/plugin-react": "^4.3.1",
79
- "bumpp": "^9.4.1",
79
+ "bumpp": "^9.5.2",
80
80
  "cross-env": "^7.0.3",
81
- "eslint": "^8.57.0",
81
+ "eslint": "^8.57.1",
82
82
  "eslint-plugin-prettier": "^5.2.1",
83
83
  "import-sort-style-module": "^6.0.0",
84
- "lint-staged": "^15.2.7",
85
- "nodemon": "^3.1.4",
84
+ "lint-staged": "^15.2.10",
85
+ "nodemon": "^3.1.7",
86
86
  "prettier": "^3.3.3",
87
87
  "prettier-plugin-import-sort": "^0.0.7",
88
- "react": "^18.2.0",
89
- "react-dom": "^18.2.0",
90
- "react-icons": "^5.2.1",
91
- "react-router-dom": "^6.24.0",
88
+ "react": "^18.3.1",
89
+ "react-dom": "^18.3.1",
90
+ "react-icons": "^5.3.0",
91
+ "react-router-dom": "^6.26.2",
92
92
  "react-toastify": "^10.0.5",
93
- "rimraf": "^5.0.7",
93
+ "rimraf": "^5.0.10",
94
94
  "simple-git-hooks": "^2.11.1",
95
95
  "ts-node": "^10.9.2",
96
- "typescript": "^5.5.2",
97
- "vite": "^5.3.5",
98
- "vite-plugin-blocklet": "^0.9.4",
96
+ "typescript": "^5.6.2",
97
+ "vite": "^5.4.7",
98
+ "vite-plugin-blocklet": "^0.9.6",
99
99
  "vite-plugin-svgr": "^4.2.0",
100
- "zx": "^8.1.4"
100
+ "zx": "^8.1.8"
101
101
  },
102
102
  "importSort": {
103
103
  ".js, .jsx, .mjs": {
@@ -1,8 +1,9 @@
1
- import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
2
1
  import { LocaleProvider } from '@arcblock/ux/lib/Locale/context';
3
- import TodoList from './pages/todo-list';
2
+ import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
3
+
4
4
  import Layout from './components/layout';
5
5
  import { SessionProvider } from './contexts/session';
6
+ import TodoList from './pages/todo-list';
6
7
 
7
8
  function App() {
8
9
  return (
@@ -1,5 +1,5 @@
1
- import { useContext } from 'react';
2
1
  import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
2
+ import { useContext } from 'react';
3
3
 
4
4
  const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
5
5
 
@@ -1,6 +1,7 @@
1
1
  import { Alert, Button, Grid } from '@mui/material';
2
2
  import { useEffect } from 'react';
3
3
  import { useNavigate } from 'react-router-dom';
4
+
4
5
  import { useSessionContext } from '../contexts/session';
5
6
 
6
7
  type RequiredLoginProps = {
@@ -1,14 +1,16 @@
1
- import { useState, useEffect } from 'react';
2
- import { ToastContainer, toast } from 'react-toastify';
3
1
  import 'react-toastify/dist/ReactToastify.css';
4
- import { nanoid } from 'nanoid';
5
- import isEmpty from 'lodash/isEmpty';
6
- import type { AxiosResponse } from 'axios';
7
2
 
8
3
  import './todo-list.css';
4
+
5
+ import type { AxiosResponse } from 'axios';
6
+ import isEmpty from 'lodash/isEmpty';
7
+ import { nanoid } from 'nanoid';
8
+ import { useEffect, useState } from 'react';
9
+ import { ToastContainer, toast } from 'react-toastify';
10
+
9
11
  import { useSessionContext } from '../contexts/session';
10
- import RequiredLogin from './required-login';
11
12
  import axios from '../libs/api';
13
+ import RequiredLogin from './required-login';
12
14
 
13
15
  type Todo = {
14
16
  id: string;
@@ -30,11 +32,18 @@ function TodoList() {
30
32
  const fetchTodoList = async () => {
31
33
  try {
32
34
  setLoading(true);
35
+
36
+ if (!session.user) {
37
+ setTodoList([]);
38
+ return;
39
+ }
40
+
33
41
  const response: AxiosResponse<{ todoList: [] }, any> = await axios.get('/api/todo-list');
34
42
  setTodoList(response.data.todoList);
35
43
  } catch (error) {
36
44
  console.error(error);
37
45
  setTodoList([]);
46
+ toast.error(error.message);
38
47
  } finally {
39
48
  setLoading(false);
40
49
  }
@@ -42,6 +51,7 @@ function TodoList() {
42
51
 
43
52
  useEffect(() => {
44
53
  fetchTodoList();
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
55
  }, []);
46
56
 
47
57
  // Step 4: write data to DID Spaces