create-blocklet 0.9.3 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -70,7 +70,7 @@
70
70
  "rimraf": "^5.0.7",
71
71
  "simple-git-hooks": "^2.11.1",
72
72
  "vite": "^5.3.5",
73
- "vite-plugin-blocklet": "^0.9.3",
73
+ "vite-plugin-blocklet": "^0.9.5",
74
74
  "vite-plugin-svgr": "^4.2.0",
75
75
  "zx": "^8.1.4"
76
76
  },
@@ -80,7 +80,7 @@
80
80
  "ts-node": "^10.9.2",
81
81
  "typescript": "^5.5.2",
82
82
  "vite": "^5.3.5",
83
- "vite-plugin-blocklet": "^0.9.3",
83
+ "vite-plugin-blocklet": "^0.9.5",
84
84
  "vite-plugin-svgr": "^4.2.0",
85
85
  "zx": "^8.1.4"
86
86
  },
@@ -70,7 +70,7 @@
70
70
  "rimraf": "^5.0.7",
71
71
  "simple-git-hooks": "^2.11.1",
72
72
  "vite": "^5.3.5",
73
- "vite-plugin-blocklet": "^0.9.3",
73
+ "vite-plugin-blocklet": "^0.9.5",
74
74
  "vite-plugin-svgr": "^4.2.0",
75
75
  "zx": "^8.1.4"
76
76
  },
@@ -51,7 +51,7 @@
51
51
  "rimraf": "^5.0.7",
52
52
  "simple-git-hooks": "^2.11.1",
53
53
  "vite": "^5.3.5",
54
- "vite-plugin-blocklet": "^0.9.3",
54
+ "vite-plugin-blocklet": "^0.9.5",
55
55
  "vite-plugin-svgr": "^4.2.0",
56
56
  "zx": "^8.1.4"
57
57
  },
@@ -35,7 +35,7 @@
35
35
  "rimraf": "^5.0.7",
36
36
  "simple-git-hooks": "^2.11.1",
37
37
  "vite": "^5.3.5",
38
- "vite-plugin-blocklet": "^0.9.3",
38
+ "vite-plugin-blocklet": "^0.9.5",
39
39
  "vite-plugin-solid": "^2.10.2",
40
40
  "zx": "^8.1.4"
41
41
  },
@@ -31,7 +31,7 @@
31
31
  "simple-git-hooks": "^2.11.1",
32
32
  "solid-js": "^1.8.18",
33
33
  "vite": "^5.3.5",
34
- "vite-plugin-blocklet": "^0.9.3",
34
+ "vite-plugin-blocklet": "^0.9.5",
35
35
  "vite-plugin-solid": "^2.10.2",
36
36
  "zx": "^8.1.4"
37
37
  },
@@ -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.3",
46
+ "vite-plugin-blocklet": "^0.9.5",
47
47
  "zx": "^8.1.4"
48
48
  },
49
49
  "lint-staged": {
@@ -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.3",
27
+ "vite-plugin-blocklet": "^0.9.5",
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.25",
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.25",
63
- "@blocklet/js-sdk": "^1.16.30",
64
- "@blocklet/ui-react": "^2.10.25",
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.3",
96
+ "typescript": "^5.6.2",
97
+ "vite": "^5.4.7",
98
+ "vite-plugin-blocklet": "^0.9.5",
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
@@ -48,7 +48,7 @@
48
48
  "rimraf": "^5.0.7",
49
49
  "simple-git-hooks": "^2.11.1",
50
50
  "vite": "^5.3.5",
51
- "vite-plugin-blocklet": "^0.9.3",
51
+ "vite-plugin-blocklet": "^0.9.5",
52
52
  "vue": "^3.4.31",
53
53
  "zx": "^8.1.4"
54
54
  },
@@ -29,7 +29,7 @@
29
29
  "rimraf": "^5.0.7",
30
30
  "simple-git-hooks": "^2.11.1",
31
31
  "vite": "^5.3.5",
32
- "vite-plugin-blocklet": "^0.9.3",
32
+ "vite-plugin-blocklet": "^0.9.5",
33
33
  "vue": "^3.4.31",
34
34
  "zx": "^8.1.4"
35
35
  },
@@ -39,7 +39,7 @@
39
39
  "taze": "^0.16.3",
40
40
  "typescript": "^5.5.4",
41
41
  "vite": "^5.3.5",
42
- "vite-plugin-blocklet": "^0.9.3",
42
+ "vite-plugin-blocklet": "^0.9.5",
43
43
  "vue-tsc": "^2.0.29",
44
44
  "zx": "^8.1.4"
45
45
  },
@@ -47,7 +47,7 @@
47
47
  "rimraf": "^5.0.7",
48
48
  "simple-git-hooks": "^2.11.1",
49
49
  "vite": "^5.3.5",
50
- "vite-plugin-blocklet": "^0.9.3",
50
+ "vite-plugin-blocklet": "^0.9.5",
51
51
  "vue": "^2.7.16",
52
52
  "zx": "^8.1.4"
53
53
  },
@@ -29,7 +29,7 @@
29
29
  "rimraf": "^5.0.7",
30
30
  "simple-git-hooks": "^2.11.1",
31
31
  "vite": "^5.3.5",
32
- "vite-plugin-blocklet": "^0.9.3",
32
+ "vite-plugin-blocklet": "^0.9.5",
33
33
  "vue": "^2.7.16",
34
34
  "zx": "^8.1.4"
35
35
  },