create-blocklet 0.5.11 → 0.5.13

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 (46) hide show
  1. package/index.js +5 -0
  2. package/lib/server.js +12 -5
  3. package/package.json +6 -6
  4. package/templates/docsite/package.json +2 -2
  5. package/templates/express-api/package.json +5 -5
  6. package/templates/monorepo/package.json +2 -2
  7. package/templates/nextjs-dapp/package.json +6 -6
  8. package/templates/react-dapp/package.json +10 -10
  9. package/templates/react-dapp-ts/.eslintrc.js +7 -0
  10. package/templates/react-dapp-ts/README.md +157 -0
  11. package/templates/react-dapp-ts/api/dev.ts +6 -0
  12. package/templates/react-dapp-ts/api/hooks/pre-start.js +12 -0
  13. package/templates/react-dapp-ts/api/src/hooks/pre-start.ts +37 -0
  14. package/templates/react-dapp-ts/api/src/index.ts +50 -0
  15. package/templates/react-dapp-ts/api/src/libs/auth.ts +17 -0
  16. package/templates/react-dapp-ts/api/src/libs/env.ts +6 -0
  17. package/templates/react-dapp-ts/api/src/libs/logger.ts +3 -0
  18. package/templates/react-dapp-ts/api/src/routes/index.ts +8 -0
  19. package/templates/react-dapp-ts/api/third.d.ts +15 -0
  20. package/templates/react-dapp-ts/blocklet.md +3 -0
  21. package/templates/react-dapp-ts/blocklet.yml +50 -0
  22. package/templates/react-dapp-ts/index.html +14 -0
  23. package/templates/react-dapp-ts/package.json +95 -0
  24. package/templates/react-dapp-ts/src/app.css +30 -0
  25. package/templates/react-dapp-ts/src/app.tsx +28 -0
  26. package/templates/react-dapp-ts/src/env.d.ts +3 -0
  27. package/templates/react-dapp-ts/src/index.tsx +5 -0
  28. package/templates/react-dapp-ts/src/libs/api.ts +14 -0
  29. package/templates/react-dapp-ts/src/logo.svg +1 -0
  30. package/templates/react-dapp-ts/src/pages/about.tsx +16 -0
  31. package/templates/react-dapp-ts/src/pages/home.tsx +22 -0
  32. package/templates/react-dapp-ts/template-info.json +12 -0
  33. package/templates/react-dapp-ts/tsconfig.api.json +9 -0
  34. package/templates/react-dapp-ts/tsconfig.json +99 -0
  35. package/templates/react-dapp-ts/vite.config.ts +20 -0
  36. package/templates/react-gun-dapp/package.json +11 -11
  37. package/templates/react-static/package.json +5 -5
  38. package/templates/solidjs-dapp/package.json +11 -11
  39. package/templates/solidjs-static/package.json +6 -6
  40. package/templates/svelte-dapp/package.json +11 -11
  41. package/templates/svelte-static/package.json +6 -6
  42. package/templates/vue-dapp/package.json +11 -11
  43. package/templates/vue-static/package.json +6 -6
  44. package/templates/vue2-dapp/package.json +11 -11
  45. package/templates/vue2-static/package.json +6 -6
  46. package/templates/website/package.json +1 -1
package/index.js CHANGED
@@ -37,6 +37,11 @@ const templates = [
37
37
  display: '[dapp] react + express.js',
38
38
  color: yellow,
39
39
  },
40
+ {
41
+ name: 'react-dapp-ts',
42
+ display: '[dapp] react + express + typescript',
43
+ color: yellow,
44
+ },
40
45
  {
41
46
  name: 'solidjs-dapp',
42
47
  display: '[dapp] solid + express.js',
package/lib/server.js CHANGED
@@ -3,8 +3,14 @@ import semver from 'semver';
3
3
 
4
4
  $.verbose = false;
5
5
 
6
- function trimServerOutputVersion(output = '') {
7
- return output?.replace(/blocklet \S+ v\d+\.\d+\.\d+\n+/g, '');
6
+ async function trimServerOutputVersion(output = '', command) {
7
+ // 调用 blocklet 命令时,都会在第一行先打印一个 blocklet [command] [version] 的信息,需要把这个信息 trim 掉
8
+ const version = await getServerVersion();
9
+ if (command) {
10
+ return output?.replace(`blocklet ${command} v${version}\n`, '');
11
+ }
12
+ const reg = new RegExp(`blocklet \\S+ v${version}\\n+`, 'g');
13
+ return output?.replace(reg, '');
8
14
  }
9
15
 
10
16
  export async function checkServerInstalled() {
@@ -42,7 +48,8 @@ export async function checkServerRunning() {
42
48
 
43
49
  export async function checkSatisfiedVersion() {
44
50
  const version = await getServerVersion();
45
- return semver.satisfies(version, '>= 1.7.0');
51
+ const cleanVersion = semver.valid(semver.coerce(version));
52
+ return semver.satisfies(cleanVersion, '>= 1.7.0');
46
53
  }
47
54
 
48
55
  export async function getServerDirectory() {
@@ -63,8 +70,8 @@ export async function getUserInfo() {
63
70
  const { stdout: name } = await $`blocklet config get name`;
64
71
  const { stdout: email } = await $`blocklet config get email`;
65
72
  return {
66
- name: trimServerOutputVersion(name?.trim()),
67
- email: trimServerOutputVersion(email?.trim()),
73
+ name: await trimServerOutputVersion(name?.trim()),
74
+ email: await trimServerOutputVersion(email?.trim()),
68
75
  };
69
76
  } catch {
70
77
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -29,9 +29,9 @@
29
29
  "test:run": "vitest run"
30
30
  },
31
31
  "dependencies": {
32
- "@arcblock/did": "^1.18.31",
33
- "@ocap/mcrypto": "^1.18.31",
34
- "@ocap/util": "^1.18.31",
32
+ "@arcblock/did": "^1.18.36",
33
+ "@ocap/mcrypto": "^1.18.36",
34
+ "@ocap/util": "^1.18.36",
35
35
  "boxen": "^6.2.1",
36
36
  "ejs": "^3.1.8",
37
37
  "envfile": "^6.18.0",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@arcblock/eslint-config-base": "0.2.2",
49
- "eslint": "^8.29.0",
50
- "prettier": "^2.8.1",
49
+ "eslint": "^8.33.0",
50
+ "prettier": "^2.8.3",
51
51
  "vitest": "^0.19.1"
52
52
  }
53
53
  }
@@ -15,8 +15,8 @@
15
15
  "bump-version": "zx scripts/bump-version.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@xmark/cli": "^2.4.87",
19
- "@xmark/theme-docs": "^2.4.87",
18
+ "@xmark/cli": "^2.4.90",
19
+ "@xmark/theme-docs": "^2.4.90",
20
20
  "bumpp": "^8.2.1",
21
21
  "rimraf": "^3.0.2",
22
22
  "zx": "^7.1.1"
@@ -31,19 +31,19 @@
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
33
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
34
- "@blocklet/sdk": "^1.8.45",
35
- "@ocap/client": "^1.18.31",
34
+ "@blocklet/sdk": "^1.8.62",
35
+ "@ocap/client": "^1.18.36",
36
36
  "dotenv-flow": "^3.2.0",
37
37
  "express": "^4.18.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arcblock/eslint-config-base": "^0.2.3",
41
41
  "bumpp": "^8.2.1",
42
- "eslint": "^8.29.0",
43
- "husky": "^8.0.2",
42
+ "eslint": "^8.33.0",
43
+ "husky": "^8.0.3",
44
44
  "lint-staged": "^12.5.0",
45
45
  "nodemon": "^2.0.20",
46
- "prettier": "^2.8.1",
46
+ "prettier": "^2.8.3",
47
47
  "rimraf": "^3.0.2",
48
48
  "zx": "^7.1.1"
49
49
  }
@@ -25,9 +25,9 @@
25
25
  "devDependencies": {
26
26
  "@arcblock/eslint-config": "0.2.2",
27
27
  "bumpp": "^7.2.0",
28
- "eslint": "^8.29.0",
28
+ "eslint": "^8.33.0",
29
29
  "husky": "^4.3.8",
30
- "prettier": "^2.8.1",
30
+ "prettier": "^2.8.3",
31
31
  "zx": "^7.1.1"
32
32
  }
33
33
  }
@@ -28,12 +28,12 @@
28
28
  ]
29
29
  },
30
30
  "dependencies": {
31
- "@arcblock/did-auth": "^1.18.31",
31
+ "@arcblock/did-auth": "^1.18.36",
32
32
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
33
- "@blocklet/sdk": "^1.8.45",
34
- "@ocap/client": "^1.18.31",
35
- "@ocap/mcrypto": "^1.18.31",
36
- "@ocap/wallet": "^1.18.31",
33
+ "@blocklet/sdk": "^1.8.62",
34
+ "@ocap/client": "^1.18.36",
35
+ "@ocap/mcrypto": "^1.18.36",
36
+ "@ocap/wallet": "^1.18.36",
37
37
  "dotenv-flow": "^3.2.0",
38
38
  "express": "^4.18.2",
39
39
  "next": "12.2.3",
@@ -44,7 +44,7 @@
44
44
  "bumpp": "^8.2.1",
45
45
  "eslint": "8.20.0",
46
46
  "eslint-config-next": "12.2.3",
47
- "husky": "^8.0.2",
47
+ "husky": "^8.0.3",
48
48
  "lint-staged": "^12.5.0",
49
49
  "nodemon": "^2.0.20",
50
50
  "npm-run-all": "^4.1.5",
@@ -40,12 +40,12 @@
40
40
  ]
41
41
  },
42
42
  "dependencies": {
43
- "@arcblock/did-auth": "^1.18.31",
43
+ "@arcblock/did-auth": "^1.18.36",
44
44
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
45
- "@blocklet/sdk": "^1.8.45",
46
- "@ocap/client": "^1.18.31",
47
- "@ocap/mcrypto": "^1.18.31",
48
- "@ocap/wallet": "^1.18.31",
45
+ "@blocklet/sdk": "^1.8.62",
46
+ "@ocap/client": "^1.18.36",
47
+ "@ocap/mcrypto": "^1.18.36",
48
+ "@ocap/wallet": "^1.18.36",
49
49
  "axios": "^0.27.2",
50
50
  "compression": "^1.7.4",
51
51
  "cookie-parser": "^1.4.6",
@@ -56,7 +56,7 @@
56
56
  "express-history-api-fallback": "^2.2.1",
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.2.0",
59
- "react-router-dom": "^6.4.5",
59
+ "react-router-dom": "^6.8.0",
60
60
  "rimraf": "^3.0.2"
61
61
  },
62
62
  "devDependencies": {
@@ -64,14 +64,14 @@
64
64
  "@vitejs/plugin-react": "^2.2.0",
65
65
  "bumpp": "^8.2.1",
66
66
  "cross-env": "^7.0.3",
67
- "eslint": "^8.29.0",
68
- "husky": "^8.0.2",
67
+ "eslint": "^8.33.0",
68
+ "husky": "^8.0.3",
69
69
  "lint-staged": "^12.5.0",
70
70
  "nodemon": "^2.0.20",
71
71
  "npm-run-all": "^4.1.5",
72
- "prettier": "^2.8.1",
72
+ "prettier": "^2.8.3",
73
73
  "vite": "^3.2.5",
74
- "vite-plugin-blocklet": "^0.5.11",
74
+ "vite-plugin-blocklet": "^0.5.13",
75
75
  "vite-plugin-svgr": "^2.4.0",
76
76
  "zx": "^7.1.1"
77
77
  }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: '@arcblock/eslint-config-ts',
4
+ parserOptions: {
5
+ project: 'tsconfig.json',
6
+ },
7
+ };
@@ -0,0 +1,157 @@
1
+ # Getting Started with Create Blocklet
2
+
3
+ This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
4
+
5
+ This blocklet is a dapp project, which means this is a full-stack application. It's contained both `server` and `client` code.
6
+
7
+ ## Launch on Blocklet Server
8
+
9
+ [![Launch on Blocklet Server](https://assets.arcblock.io/icons/launch_on_blocklet_server.svg)](https://install.arcblock.io/launch?action=blocklet-install&meta_url=https%3A%2F%2Fgithub.com%2Fblocklet%2Fpages-kit%2Freleases%2Fdownload%2Fv0.1.33%2Fblocklet.json)
10
+
11
+ ## File Structure
12
+
13
+ - public/ - static files
14
+ - favicon.ico - favicon
15
+ - favicon.svg - favicon
16
+ - index.html - main html file, template for react
17
+ - screenshots/ - Screenshots
18
+ - api/
19
+ - src/ - Api side code
20
+ - hooks/ - blocklet lifecycle hooks
21
+ - libs/ - Api side libraries
22
+ - middlewares/ - Api side middlewares
23
+ - routes/ - Api side routes
24
+ - index.ts - Api side entry point
25
+ - src/ - Client side code (A standard react app structure)
26
+ - .env - Environment variables
27
+ - .env.local - Local environment variables
28
+ - .eslintrc.js - ESLint configuration
29
+ - .gitignore - Git ignore file
30
+ - .prettierrc - Prettier configuration
31
+ - blocklet.md - Blocklet README
32
+ - blocklet.yml - Blocklet configuration
33
+ - LICENSE - License file
34
+ - logo.png - Blocklet logo file
35
+ - package.json - Npm package file
36
+ - README.md - A guide for this blocklet
37
+ - version - Version file
38
+
39
+ ## Development
40
+
41
+ 1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
42
+
43
+ Blocklet needs blocklet server as a dependency. So you need to install it first.
44
+ `npm install -g @blocklet/cli`
45
+ See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
46
+
47
+ 2. Init blocklet server & start blocklet server
48
+
49
+ Before starting an blocklet server, you need to init blocklet server.
50
+ `blocklet server init --mode=debug`
51
+ `blocklet server start`
52
+ See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
53
+
54
+ 3. Go to the project directory `cd [name]`
55
+ 4. Install dependencies: `npm install` or `yarn`
56
+ 5. Start development server: `blocklet dev`
57
+
58
+ ## Bundle
59
+
60
+ After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
61
+
62
+ ## Deploy
63
+
64
+ - 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).
65
+ > Or you can simply use `npm run deploy` command.
66
+ - If you want to deploy this blocklet to remote blocklet server, you can use the command below.
67
+
68
+ ```shell
69
+ blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
70
+ ```
71
+
72
+ > Make sure the blocklet is bundled before deployment.
73
+
74
+ ## Upload to blocklet store
75
+
76
+ - If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
77
+
78
+ Bump version at first.
79
+
80
+ ```shell
81
+ npm run bump-version
82
+ ```
83
+
84
+ Then config blocklet store url.
85
+ You can use those store url in below.
86
+
87
+ 1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
88
+ 2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
89
+ 3. A blocklet store started by yourself.
90
+ > 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)
91
+
92
+ ```shell
93
+ blocklet config set store {store url}
94
+ ```
95
+
96
+ Get a `accessToken` by using this command.
97
+
98
+ > Why we need a `accessToken`?
99
+ > A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
100
+
101
+ Set `accessToken` to blocklet config
102
+
103
+ ```shell
104
+ blocklet config set accessToken {accessToken}
105
+ ```
106
+
107
+ Upload a new version to a store.
108
+
109
+ > Make sure the blocklet is bundled before upload.
110
+
111
+ ```shell
112
+ blocklet upload
113
+ ```
114
+
115
+ Or you can simply use `npm run upload` command.
116
+
117
+ - You also can upload a new version to a store by Github CI.
118
+ Bump version at first.
119
+
120
+ ```shell
121
+ npm run bump-version
122
+ ```
123
+
124
+ Push your code to Github main/master branch, or make a pull request to the main/master branch.
125
+ The CI workflow will automatically upload a new version to a store.
126
+
127
+ ## Q & A
128
+
129
+ 1. Q: How to change a blocklet's name?
130
+
131
+ A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
132
+
133
+ You can also change the `title` field and `description` field in the `blocklet.yml` file.
134
+
135
+ Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
136
+
137
+ Replace this command `"bundle:client": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
138
+
139
+ Replace `did` field in the `blocklet.yml`
140
+
141
+ 2. Q: How to change a blocklet's logo?
142
+
143
+ Change the `logo.png` file root folder.
144
+
145
+ Or you can change the `logo` field in the `blocklet.yml` file.
146
+
147
+ > Make sure you have added the logo path to the `blocklet.yml` file `files` field.
148
+
149
+ ## Learn More
150
+
151
+ - 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)
152
+ - Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
153
+
154
+ ## License
155
+
156
+ The code is licensed under the Apache 2.0 license found in the
157
+ [LICENSE](LICENSE) file.
@@ -0,0 +1,6 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { setupClient } from 'vite-plugin-blocklet';
3
+
4
+ import { app } from './src';
5
+
6
+ setupClient(app);
@@ -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,50 @@
1
+ import 'express-async-errors';
2
+
3
+ import path from 'path';
4
+
5
+ import compression from 'compression';
6
+ import cookieParser from 'cookie-parser';
7
+ import cors from 'cors';
8
+ import dotenv from 'dotenv-flow';
9
+ import express, { ErrorRequestHandler } from 'express';
10
+ import fallback from 'express-history-api-fallback';
11
+
12
+ import logger from './libs/logger';
13
+ import routes from './routes';
14
+
15
+ dotenv.config();
16
+
17
+ const { name, version } = require('../../package.json');
18
+
19
+ export const app = express();
20
+
21
+ app.set('trust proxy', true);
22
+ app.use(cookieParser());
23
+ app.use(express.json({ limit: '1 mb' }));
24
+ app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
25
+ app.use(cors());
26
+
27
+ const router = express.Router();
28
+ router.use('/api', routes);
29
+ app.use(router);
30
+
31
+ const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
32
+
33
+ if (isProduction) {
34
+ const staticDir = path.resolve(process.env.BLOCKLET_APP_DIR!, 'dist');
35
+ app.use(compression());
36
+ app.use(express.static(staticDir, { maxAge: '30d', index: false }));
37
+ app.use(fallback('index.html', { root: staticDir }));
38
+
39
+ app.use(<ErrorRequestHandler>((err, _, res) => {
40
+ logger.error(err.stack);
41
+ res.status(500).send('Something broke!');
42
+ }));
43
+ }
44
+
45
+ const port = parseInt(process.env.BLOCKLET_PORT!, 10);
46
+
47
+ export const server = app.listen(port, (err?: any) => {
48
+ if (err) throw err;
49
+ logger.info(`> ${name} v${version} ready on ${port}`);
50
+ });
@@ -0,0 +1,17 @@
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 env from './env';
9
+
10
+ export const wallet = getWallet();
11
+ export const authenticator = new WalletAuthenticator();
12
+ export const handlers = new WalletHandler({
13
+ authenticator,
14
+ tokenStorage: new AuthStorage({
15
+ dbPath: path.join(env.dataDir, 'auth.db'),
16
+ }),
17
+ });
@@ -0,0 +1,6 @@
1
+ import env from '@blocklet/sdk/lib/env';
2
+
3
+ export default {
4
+ ...env,
5
+ chainHost: process.env.CHAIN_HOST || '',
6
+ };
@@ -0,0 +1,3 @@
1
+ const logger = console;
2
+
3
+ export default logger;
@@ -0,0 +1,8 @@
1
+ import middleware from '@blocklet/sdk/lib/middlewares';
2
+ import { Router } from 'express';
3
+
4
+ const router = Router();
5
+
6
+ router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
7
+
8
+ export default router;
@@ -0,0 +1,15 @@
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
+ };
14
+ }
15
+ }
@@ -0,0 +1,3 @@
1
+ # template-react
2
+
3
+ A react template for creating a new blocklet project.
@@ -0,0 +1,50 @@
1
+ name: template-react-dapp-ts
2
+ title: Blocklet Template React
3
+ description: A Blocklet DAPP blocklet
4
+ keywords:
5
+ - blocklet
6
+ - react
7
+ group: dapp
8
+ did: ''
9
+ main: api/dist/index.js
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
+ - dist
21
+ - logo.png
22
+ - screenshots
23
+ - api/hooks/pre-start.js
24
+ interfaces:
25
+ - type: web
26
+ name: publicUrl
27
+ path: /
28
+ prefix: '*'
29
+ port: BLOCKLET_PORT
30
+ protocol: http
31
+ community: ''
32
+ documentation: ''
33
+ homepage: ''
34
+ license: ''
35
+ payment:
36
+ price: []
37
+ share: []
38
+ timeout:
39
+ start: 60
40
+ requirements:
41
+ server: '>=1.6.29'
42
+ os: '*'
43
+ cpu: '*'
44
+ scripts:
45
+ preStart: node api/hooks/pre-start.js
46
+ dev: npm run start
47
+ environments: []
48
+ capabilities: {}
49
+ screenshots: []
50
+ components: []
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
6
+ <meta name="theme-color" content="#4F6AF5" />
7
+ <meta name="description" content="Web site created using create-blocklet" />
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>