create-blocklet 0.7.5 → 0.7.7
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/index.js +5 -0
- package/package.json +1 -1
- package/templates/react-dapp/package.json +1 -1
- package/templates/react-dapp-ts/package.json +1 -1
- package/templates/react-gun-dapp/package.json +1 -1
- package/templates/react-static/package.json +1 -1
- package/templates/solidjs-dapp/package.json +1 -1
- package/templates/solidjs-static/package.json +1 -1
- package/templates/svelte-dapp/package.json +1 -1
- package/templates/svelte-static/package.json +1 -1
- package/templates/todo-list-example/.editorconfig +23 -0
- package/templates/todo-list-example/.eslintrc.js +13 -0
- package/templates/todo-list-example/.github/workflows/main.yml +36 -0
- package/templates/todo-list-example/.github/workflows/pr-title.yml +21 -0
- package/templates/todo-list-example/.github/workflows/version-check.yml +20 -0
- package/templates/todo-list-example/.husky/pre-commit +4 -0
- package/templates/todo-list-example/.prettierrc +9 -0
- package/templates/todo-list-example/LICENSE +13 -0
- package/templates/todo-list-example/README.md +28 -0
- package/templates/todo-list-example/README.zh.md +28 -0
- package/templates/todo-list-example/api/dev.ts +5 -0
- package/templates/todo-list-example/api/hooks/pre-start.js +12 -0
- package/templates/todo-list-example/api/src/hooks/pre-start.ts +37 -0
- package/templates/todo-list-example/api/src/index.ts +49 -0
- package/templates/todo-list-example/api/src/libs/auth.ts +19 -0
- package/templates/todo-list-example/api/src/libs/env.ts +6 -0
- package/templates/todo-list-example/api/src/libs/logger.ts +3 -0
- package/templates/todo-list-example/api/src/routes/index.ts +10 -0
- package/templates/todo-list-example/api/src/routes/todo-list/$get.ts +31 -0
- package/templates/todo-list-example/api/src/routes/todo-list/$put.ts +29 -0
- package/templates/todo-list-example/api/src/routes/todo-list/index.ts +12 -0
- package/templates/todo-list-example/api/third.d.ts +17 -0
- package/templates/todo-list-example/blocklet.md +3 -0
- package/templates/todo-list-example/blocklet.yml +51 -0
- package/templates/todo-list-example/index.html +14 -0
- package/templates/todo-list-example/logo.png +0 -0
- package/templates/todo-list-example/package.json +109 -0
- package/templates/todo-list-example/public/.gitkeep +0 -0
- package/templates/todo-list-example/screenshots/.gitkeep +0 -0
- package/templates/todo-list-example/screenshots/1-login.png +0 -0
- package/templates/todo-list-example/screenshots/2-ui.png +0 -0
- package/templates/todo-list-example/scripts/build-clean.js +5 -0
- package/templates/todo-list-example/scripts/bump-version.mjs +35 -0
- package/templates/todo-list-example/src/app.css +30 -0
- package/templates/todo-list-example/src/app.tsx +32 -0
- package/templates/todo-list-example/src/components/layout.tsx +12 -0
- package/templates/todo-list-example/src/contexts/session.tsx +11 -0
- package/templates/todo-list-example/src/env.d.ts +5 -0
- package/templates/todo-list-example/src/index.tsx +6 -0
- package/templates/todo-list-example/src/libs/api.ts +14 -0
- package/templates/todo-list-example/src/logo.svg +1 -0
- package/templates/todo-list-example/src/pages/required-login.tsx +48 -0
- package/templates/todo-list-example/src/pages/todo-list.css +260 -0
- package/templates/todo-list-example/src/pages/todo-list.tsx +266 -0
- package/templates/todo-list-example/template-info.json +12 -0
- package/templates/todo-list-example/tsconfig.api.json +9 -0
- package/templates/todo-list-example/tsconfig.eslint.json +7 -0
- package/templates/todo-list-example/tsconfig.json +102 -0
- package/templates/todo-list-example/version +1 -0
- package/templates/todo-list-example/vite.config.mts +18 -0
- package/templates/vue-dapp/package.json +1 -1
- package/templates/vue-static/package.json +1 -1
- package/templates/vue2-dapp/package.json +1 -1
- package/templates/vue2-static/package.json +1 -1
package/index.js
CHANGED
|
@@ -43,6 +43,11 @@ const templates = [
|
|
|
43
43
|
display: '[dapp] react + express + typescript',
|
|
44
44
|
color: yellow,
|
|
45
45
|
},
|
|
46
|
+
{
|
|
47
|
+
name: 'todo-list-example',
|
|
48
|
+
display: '[dapp: todo-list] react + express + typescript + DID Spaces',
|
|
49
|
+
color: yellow,
|
|
50
|
+
},
|
|
46
51
|
{
|
|
47
52
|
name: 'solidjs-dapp',
|
|
48
53
|
display: '[dapp] solid + express.js',
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# For more information about the properties used in
|
|
2
|
+
# this file, please see the EditorConfig documentation:
|
|
3
|
+
# http://editorconfig.org/
|
|
4
|
+
#
|
|
5
|
+
# Sensible EditorConfig defaults
|
|
6
|
+
# https://gist.github.com/matijs/662bf45dd4ec37b3a068
|
|
7
|
+
root = true
|
|
8
|
+
|
|
9
|
+
[*]
|
|
10
|
+
charset = utf-8
|
|
11
|
+
end_of_line = lf
|
|
12
|
+
indent_size = 2
|
|
13
|
+
indent_style = space
|
|
14
|
+
insert_final_newline = true
|
|
15
|
+
trim_trailing_whitespace = true
|
|
16
|
+
|
|
17
|
+
# Make sure package.json always uses 2 spaces to indent
|
|
18
|
+
[{package.json}]
|
|
19
|
+
indent_size = 2
|
|
20
|
+
indent_style = space
|
|
21
|
+
|
|
22
|
+
[{makefile, Makefile}]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { join } = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
extends: '@arcblock/eslint-config-ts',
|
|
6
|
+
parser: '@typescript-eslint/parser',
|
|
7
|
+
parserOptions: {
|
|
8
|
+
project: [join(__dirname, 'tsconfig.eslint.json'), join(__dirname, 'tsconfig.json')],
|
|
9
|
+
},
|
|
10
|
+
rules: {
|
|
11
|
+
'@typescript-eslint/comma-dangle': 'off',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Deploy
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
Deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
if: "! contains(github.event.head_commit.message, '[skip ci]')"
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout repo
|
|
16
|
+
uses: actions/checkout@v2
|
|
17
|
+
|
|
18
|
+
- name: Set yarn cache
|
|
19
|
+
uses: c-hive/gha-yarn-cache@v2
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: yarn
|
|
23
|
+
|
|
24
|
+
- name: Blocklet workflow
|
|
25
|
+
uses: blocklet/action-workflow@v1
|
|
26
|
+
with:
|
|
27
|
+
skip-upload: false
|
|
28
|
+
skip-deploy: false
|
|
29
|
+
bundle-command: yarn bundle
|
|
30
|
+
store-endpoint: ${{ secrets.STORE_ENDPOINT }}
|
|
31
|
+
store-access-token: ${{ secrets.STORE_ACCESS_TOKEN }}
|
|
32
|
+
server-endpoint: ${{ secrets.SERVER_ENDPOINT }}
|
|
33
|
+
server-access-key: ${{ secrets.SERVER_ACCESS_KEY }}
|
|
34
|
+
server-access-secret: ${{ secrets.SERVER_ACCESS_SECRET }}
|
|
35
|
+
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
|
36
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: 'Lint PR Title'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- reopened
|
|
8
|
+
- edited
|
|
9
|
+
- synchronize
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- dev
|
|
13
|
+
- master
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint-title:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: ArcBlock/action-lint-pull-request-title@master
|
|
20
|
+
env:
|
|
21
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: 'Version Check'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- reopened
|
|
8
|
+
- edited
|
|
9
|
+
- synchronize
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- master
|
|
13
|
+
jobs:
|
|
14
|
+
main:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: action-version-check
|
|
18
|
+
uses: arcblock/action-version-check@master
|
|
19
|
+
env:
|
|
20
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018-2020 ArcBlock
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# todo-list-example
|
|
2
|
+
|
|
3
|
+
## How to start
|
|
4
|
+
|
|
5
|
+
### Install dependencies
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pnpm install
|
|
9
|
+
# or npm install
|
|
10
|
+
# or yarn install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Start
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
yarn dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## How to connect with DID Spaces
|
|
20
|
+
|
|
21
|
+
- Step 1: Set the 'capabilities.didSpace' field in blocklet.yml to 'requiredOnConnect', see 'blocklet.yml#capabilities'
|
|
22
|
+
- Step 2: To read and write the DID Space, see api/src/routes/todo-list/index.ts#9
|
|
23
|
+
- Step 3: Get data from DID Spaces, see 'src/pages/todo-list.tsx#33'
|
|
24
|
+
- Step 4: Write data to DID Spaces, see 'src/pages/todo-list.tsx#51'
|
|
25
|
+
|
|
26
|
+
## Get help
|
|
27
|
+
|
|
28
|
+
If you want to learn more about the development of DID Spaces, You can also refer to [DID Spaces development documentation] (https://www.arcblock.io/docs/did-spaces/en/did-spaces-how-to-guides). No matter what you encounter a problem, we welcome you in our official BBS (https://community.arcblock.io/) initiated discussions.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# todo-list-example
|
|
2
|
+
|
|
3
|
+
## 如何启动
|
|
4
|
+
|
|
5
|
+
### 安装依赖
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pnpm install
|
|
9
|
+
# or npm install
|
|
10
|
+
# or yarn install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 启动
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
yarn dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 如何与 DID Spaces 对接的
|
|
20
|
+
|
|
21
|
+
- 步骤 1:将blocklet.yml 中的 `capabilities.didSpace` 字段设置为 `requiredOnConnect`,请参阅 `blocklet.yml#capabilities`
|
|
22
|
+
- 步骤 2:实现读写 DID Space 的功能,请参阅 `api/src/routes/todo-list/index.ts#9`
|
|
23
|
+
- 步骤 3:从 DID Spaces 获取数据,请参阅 `src/pages/todo-list.tsx#33`
|
|
24
|
+
- 步骤 4:将数据写入 DID Spaces,请参阅 `src/pages/todo-list.tsx#51`
|
|
25
|
+
|
|
26
|
+
## 获得帮助
|
|
27
|
+
|
|
28
|
+
如果你想了解更多有关 DID Spaces 的开发细节,你还可以参考[DID Spaces 的开发文档](https://www.arcblock.io/docs/did-spaces/en/did-spaces-how-to-guides)。不论你遇到什么问题,我们随时欢迎你在我们的[官方论坛](https://community.arcblock.io/)发起讨论。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable global-require */
|
|
2
|
+
|
|
3
|
+
const isDevelopment = process.env.BLOCKLET_MODE === 'development';
|
|
4
|
+
|
|
5
|
+
if (isDevelopment) {
|
|
6
|
+
// rename `require` to skip deps resolve when bundling
|
|
7
|
+
const r = require;
|
|
8
|
+
r('ts-node').register();
|
|
9
|
+
r('../src/hooks/pre-start');
|
|
10
|
+
} else {
|
|
11
|
+
require('../dist/hooks/pre-start');
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import '@blocklet/sdk/lib/error-handler';
|
|
2
|
+
|
|
3
|
+
import Client from '@ocap/client';
|
|
4
|
+
import dotenv from 'dotenv-flow';
|
|
5
|
+
|
|
6
|
+
import { wallet } from '../libs/auth';
|
|
7
|
+
import env from '../libs/env';
|
|
8
|
+
import logger from '../libs/logger';
|
|
9
|
+
|
|
10
|
+
dotenv.config();
|
|
11
|
+
|
|
12
|
+
const { name } = require('../../../package.json');
|
|
13
|
+
|
|
14
|
+
const ensureAccountDeclared = async () => {
|
|
15
|
+
if (env.isComponent) return;
|
|
16
|
+
if (!env.chainHost) return;
|
|
17
|
+
|
|
18
|
+
const client = new Client(env.chainHost);
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
21
|
+
if (!state) {
|
|
22
|
+
const hash = await client.declare({ moniker: name, wallet });
|
|
23
|
+
logger.log(`app account declared on chain ${env.chainHost}`, hash);
|
|
24
|
+
} else {
|
|
25
|
+
logger.log(`app account already declared on chain ${env.chainHost}`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
(async () => {
|
|
30
|
+
try {
|
|
31
|
+
await ensureAccountDeclared();
|
|
32
|
+
process.exit(0);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
logger.error(`${name} pre-start error`, err.message);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import 'express-async-errors';
|
|
2
|
+
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import cookieParser from 'cookie-parser';
|
|
6
|
+
import cors from 'cors';
|
|
7
|
+
import dotenv from 'dotenv-flow';
|
|
8
|
+
import express, { ErrorRequestHandler } from 'express';
|
|
9
|
+
import fallback from '@blocklet/sdk/lib/middlewares/fallback';
|
|
10
|
+
|
|
11
|
+
import logger from './libs/logger';
|
|
12
|
+
import routes from './routes';
|
|
13
|
+
|
|
14
|
+
dotenv.config();
|
|
15
|
+
|
|
16
|
+
const { name, version } = require('../../package.json');
|
|
17
|
+
|
|
18
|
+
export const app = express();
|
|
19
|
+
|
|
20
|
+
app.set('trust proxy', true);
|
|
21
|
+
app.use(cookieParser());
|
|
22
|
+
app.use(express.json({ limit: '1 mb' }));
|
|
23
|
+
app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
|
|
24
|
+
app.use(cors());
|
|
25
|
+
|
|
26
|
+
const router = express.Router();
|
|
27
|
+
router.use('/api', routes);
|
|
28
|
+
app.use(router);
|
|
29
|
+
|
|
30
|
+
const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
|
|
31
|
+
|
|
32
|
+
if (isProduction) {
|
|
33
|
+
const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR!, 'dist');
|
|
34
|
+
app.use(express.static(staticDir, { maxAge: '30d', index: false }));
|
|
35
|
+
app.use(fallback('index.html', { root: staticDir }));
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
+
app.use(<ErrorRequestHandler>((err, _req, res, _next) => {
|
|
39
|
+
logger.error(err.stack);
|
|
40
|
+
res.status(500).send('Something broke!');
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const port = parseInt(process.env.BLOCKLET_PORT!, 10);
|
|
45
|
+
|
|
46
|
+
export const server = app.listen(port, (err?: any) => {
|
|
47
|
+
if (err) throw err;
|
|
48
|
+
logger.info(`> ${name} v${version} ready on ${port}`);
|
|
49
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import AuthStorage from '@arcblock/did-auth-storage-nedb';
|
|
4
|
+
import getWallet from '@blocklet/sdk/lib/wallet';
|
|
5
|
+
import WalletAuthenticator from '@blocklet/sdk/lib/wallet-authenticator';
|
|
6
|
+
import WalletHandler from '@blocklet/sdk/lib/wallet-handler';
|
|
7
|
+
|
|
8
|
+
import { AuthService } from '@blocklet/sdk';
|
|
9
|
+
import env from './env';
|
|
10
|
+
|
|
11
|
+
export const wallet = getWallet();
|
|
12
|
+
export const authenticator = new WalletAuthenticator();
|
|
13
|
+
export const handlers = new WalletHandler({
|
|
14
|
+
authenticator,
|
|
15
|
+
tokenStorage: new AuthStorage({
|
|
16
|
+
dbPath: path.join(env.dataDir, 'auth.db'),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
export const authService = new AuthService();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import middleware from '@blocklet/sdk/lib/middlewares';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import todoListRouter from './todo-list';
|
|
4
|
+
|
|
5
|
+
const router = Router();
|
|
6
|
+
|
|
7
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
|
|
8
|
+
router.use('/todo-list', middleware.user(), todoListRouter);
|
|
9
|
+
|
|
10
|
+
export default router;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import { GetObjectCommand, SpaceClient } from '@did-space/client';
|
|
3
|
+
import { streamToString } from '@did-space/core';
|
|
4
|
+
import { authService, wallet } from '../../libs/auth';
|
|
5
|
+
|
|
6
|
+
export default async function $get(req: Request, res: Response) {
|
|
7
|
+
const { user } = await authService.getUser(req.user?.did as string);
|
|
8
|
+
if (!user?.didSpace?.endpoint) {
|
|
9
|
+
return res.status(404).send('DID Spaces endpoint does not exist. Log in again to complete the authorization');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const spaceClient = new SpaceClient({
|
|
13
|
+
wallet,
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
endpoint: user.didSpace.endpoint,
|
|
16
|
+
});
|
|
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);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PutObjectCommand, SpaceClient } from '@did-space/client';
|
|
2
|
+
import type { Request, Response } from 'express';
|
|
3
|
+
import isArray from 'lodash/isArray';
|
|
4
|
+
import { authService, wallet } from '../../libs/auth';
|
|
5
|
+
|
|
6
|
+
export default async function $put(req: Request, res: Response) {
|
|
7
|
+
if (!isArray(req.body.todoList)) {
|
|
8
|
+
throw new Error('TodoList must be an array');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { user } = await authService.getUser(req.user?.did as string);
|
|
12
|
+
if (!user?.didSpace?.endpoint) {
|
|
13
|
+
return res.status(404).send('DID Spaces endpoint does not exist. Log in again to complete the authorization');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const spaceClient = new SpaceClient({
|
|
17
|
+
wallet,
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
endpoint: user.didSpace.endpoint,
|
|
20
|
+
});
|
|
21
|
+
await spaceClient.send(
|
|
22
|
+
new PutObjectCommand({
|
|
23
|
+
key: 'todo-list.json',
|
|
24
|
+
data: JSON.stringify(req.body.todoList),
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return res.send();
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import middleware from '@blocklet/sdk/lib/middlewares';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import $get from './$get';
|
|
4
|
+
import $put from './$put';
|
|
5
|
+
|
|
6
|
+
const todoListRouter = Router();
|
|
7
|
+
|
|
8
|
+
// Step 2: the function of reading and writing DID Space is implemented
|
|
9
|
+
todoListRouter.get('/', middleware.user(), $get);
|
|
10
|
+
todoListRouter.put('/', middleware.user(), $put);
|
|
11
|
+
|
|
12
|
+
export default todoListRouter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'vite-plugin-blocklet';
|
|
2
|
+
|
|
3
|
+
declare module 'express-history-api-fallback';
|
|
4
|
+
|
|
5
|
+
declare module 'express-async-errors';
|
|
6
|
+
|
|
7
|
+
namespace Express {
|
|
8
|
+
interface Request {
|
|
9
|
+
user?: {
|
|
10
|
+
did: string;
|
|
11
|
+
role: string;
|
|
12
|
+
fullName: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
walletOS: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: template-todo-list
|
|
2
|
+
title: Blocklet Template todo-list
|
|
3
|
+
description: A Blocklet Server blocklet
|
|
4
|
+
keywords:
|
|
5
|
+
- blocklet
|
|
6
|
+
- svelte
|
|
7
|
+
group: static
|
|
8
|
+
did: ''
|
|
9
|
+
main: dist
|
|
10
|
+
author:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
|
+
repository:
|
|
14
|
+
type: git
|
|
15
|
+
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
16
|
+
specVersion: 1.1.1
|
|
17
|
+
version: 0.1.0
|
|
18
|
+
logo: logo.png
|
|
19
|
+
files:
|
|
20
|
+
- logo.png
|
|
21
|
+
- screenshots
|
|
22
|
+
interfaces:
|
|
23
|
+
- type: web
|
|
24
|
+
name: publicUrl
|
|
25
|
+
path: /
|
|
26
|
+
prefix: '*'
|
|
27
|
+
port: BLOCKLET_PORT
|
|
28
|
+
protocol: http
|
|
29
|
+
community: ''
|
|
30
|
+
documentation: ''
|
|
31
|
+
homepage: ''
|
|
32
|
+
license: ''
|
|
33
|
+
payment:
|
|
34
|
+
price: []
|
|
35
|
+
share: []
|
|
36
|
+
timeout:
|
|
37
|
+
start: 60
|
|
38
|
+
requirements:
|
|
39
|
+
server: '>=1.6.29'
|
|
40
|
+
os: '*'
|
|
41
|
+
cpu: '*'
|
|
42
|
+
scripts:
|
|
43
|
+
dev: npm run start
|
|
44
|
+
environments: []
|
|
45
|
+
capabilities:
|
|
46
|
+
# Step 1: set capabilities.didSpace to requiredOnConnect
|
|
47
|
+
didSpace: requiredOnConnect
|
|
48
|
+
screenshots:
|
|
49
|
+
- 1-login.png
|
|
50
|
+
- 2-ui.png
|
|
51
|
+
components: []
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico?imageFilter=convert&f=png&w=32" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
7
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
Binary file
|