create-blocklet 0.2.18 → 0.3.2
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/common/.github/workflows/main.yml +5 -5
- package/common/.husky/pre-commit +4 -0
- package/common/_eslintignore +10 -0
- package/common/_eslintrc.js +1 -0
- package/common/_gitignore +15 -9
- package/common/logo.png +0 -0
- package/common/public/favicon.ico +0 -0
- package/index.js +200 -77
- package/lib/arcblock.js +11 -7
- package/lib/git.js +25 -0
- package/lib/index.js +17 -5
- package/lib/npm.js +7 -9
- package/lib/server.js +26 -20
- package/package.json +18 -16
- package/template-api/express/README.md +146 -0
- package/{template-dapp/react/server → template-api/express/api}/hooks/pre-start.js +0 -0
- package/template-api/express/api/index.js +13 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/auth.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/env.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/logger.js +0 -0
- package/template-api/express/blocklet.md +3 -0
- package/template-api/express/blocklet.yml +57 -0
- package/template-api/express/package.json +26 -0
- package/template-api/express/screenshots/.gitkeep +0 -0
- package/template-dapp/nextjs/.eslintrc.js +4 -0
- package/template-dapp/nextjs/README.md +153 -0
- package/template-dapp/{vue/server → nextjs/api}/hooks/pre-start.js +0 -0
- package/template-dapp/nextjs/api/index.js +24 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/auth.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/env.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/logger.js +0 -0
- package/template-dapp/{vue2/server → nextjs/api}/routes/index.js +1 -1
- package/template-dapp/nextjs/blocklet.md +3 -0
- package/template-dapp/nextjs/blocklet.yml +58 -0
- package/template-dapp/nextjs/next.config.js +6 -0
- package/template-dapp/nextjs/package.json +48 -0
- package/template-dapp/nextjs/pages/_app.js +21 -0
- package/template-dapp/nextjs/pages/api/hello.js +5 -0
- package/template-dapp/nextjs/pages/index.js +69 -0
- package/template-dapp/nextjs/styles/Home.module.css +116 -0
- package/template-dapp/nextjs/styles/globals.css +16 -0
- package/template-dapp/react/README.md +5 -5
- package/template-dapp/{vue2/server → react/api}/hooks/pre-start.js +0 -0
- package/template-dapp/react/{server → api}/index.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/auth.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/env.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/logger.js +0 -0
- package/template-dapp/react/{server → api}/routes/index.js +1 -1
- package/template-dapp/react/blocklet.yml +6 -6
- package/template-dapp/react/package.json +35 -23
- package/template-dapp/react/public/index.html +1 -3
- package/template-dapp/react/src/app.js +8 -8
- package/template-dapp/vue/.browserslistrc +4 -0
- package/template-dapp/vue/.eslintrc.js +25 -0
- package/template-dapp/vue/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue/{server → api}/index.js +0 -0
- package/template-dapp/vue/api/libs/auth.js +22 -0
- package/template-dapp/vue/api/libs/env.js +6 -0
- package/template-dapp/vue/api/libs/logger.js +3 -0
- package/template-dapp/vue/{server → api}/routes/index.js +1 -1
- package/template-dapp/vue/blocklet.yml +6 -5
- package/template-dapp/vue/index.html +2 -3
- package/template-dapp/vue/package.json +39 -21
- package/template-dapp/vue/src/App.vue +4 -2
- package/template-dapp/vue/vite.config.js +10 -6
- package/template-dapp/vue2/.browserslistrc +4 -0
- package/template-dapp/vue2/.eslintrc.js +14 -0
- package/template-dapp/vue2/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue2/{server → api}/index.js +0 -0
- package/template-dapp/vue2/api/libs/auth.js +22 -0
- package/template-dapp/vue2/api/libs/env.js +6 -0
- package/template-dapp/vue2/api/libs/logger.js +3 -0
- package/template-dapp/vue2/api/routes/index.js +6 -0
- package/template-dapp/vue2/blocklet.yml +7 -5
- package/template-dapp/vue2/jsconfig.json +19 -0
- package/template-dapp/vue2/package.json +38 -43
- package/template-dapp/vue2/public/index.html +2 -9
- package/template-dapp/vue2/src/App.vue +17 -1
- package/template-dapp/vue2/src/main.js +0 -2
- package/template-dapp/vue2/vue.config.js +0 -1
- package/template-static/blocklet-page/package.json +5 -5
- package/template-static/react/blocklet.yml +2 -2
- package/template-static/react/package.json +21 -9
- package/template-static/react/public/index.html +1 -3
- package/template-static/react/src/app.js +8 -8
- package/template-static/vue/.browserslistrc +4 -0
- package/template-static/vue/.eslintrc.js +25 -0
- package/template-static/vue/blocklet.yml +2 -2
- package/template-static/vue/index.html +2 -3
- package/template-static/vue/package.json +26 -8
- package/template-static/vue/vite.config.js +10 -6
- package/template-static/vue2/.browserslistrc +4 -0
- package/template-static/vue2/.eslintrc.js +14 -0
- package/template-static/vue2/blocklet.yml +2 -2
- package/template-static/vue2/jsconfig.json +19 -0
- package/template-static/vue2/package.json +25 -30
- package/template-static/vue2/public/index.html +2 -9
- package/template-static/vue2/src/App.vue +7 -1
- package/template-static/vue2/src/main.js +0 -2
- package/template-static/vue2/vue.config.js +0 -3
- package/common/public/favicon.svg +0 -1
- package/template-dapp/vue2/src/pages/About.vue +0 -13
- package/template-dapp/vue2/src/pages/Home.vue +0 -27
- package/template-dapp/vue2/src/router.js +0 -24
- package/template-static/vue2/src/pages/About.vue +0 -13
- package/template-static/vue2/src/pages/Home.vue +0 -20
- package/template-static/vue2/src/router.js +0 -24
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import Head from 'next/head'
|
|
2
|
+
import Image from 'next/image'
|
|
3
|
+
import styles from '../styles/Home.module.css'
|
|
4
|
+
|
|
5
|
+
export default function Home() {
|
|
6
|
+
return (
|
|
7
|
+
<div className={styles.container}>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>Create Next App</title>
|
|
10
|
+
<meta name="description" content="Generated by create next app" />
|
|
11
|
+
<link rel="icon" href="/favicon.ico" />
|
|
12
|
+
</Head>
|
|
13
|
+
|
|
14
|
+
<main className={styles.main}>
|
|
15
|
+
<h1 className={styles.title}>
|
|
16
|
+
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
|
17
|
+
</h1>
|
|
18
|
+
|
|
19
|
+
<p className={styles.description}>
|
|
20
|
+
Get started by editing{' '}
|
|
21
|
+
<code className={styles.code}>pages/index.js</code>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<div className={styles.grid}>
|
|
25
|
+
<a href="https://nextjs.org/docs" className={styles.card}>
|
|
26
|
+
<h2>Documentation →</h2>
|
|
27
|
+
<p>Find in-depth information about Next.js features and API.</p>
|
|
28
|
+
</a>
|
|
29
|
+
|
|
30
|
+
<a href="https://nextjs.org/learn" className={styles.card}>
|
|
31
|
+
<h2>Learn →</h2>
|
|
32
|
+
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
<a
|
|
36
|
+
href="https://github.com/vercel/next.js/tree/canary/examples"
|
|
37
|
+
className={styles.card}
|
|
38
|
+
>
|
|
39
|
+
<h2>Examples →</h2>
|
|
40
|
+
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
|
41
|
+
</a>
|
|
42
|
+
|
|
43
|
+
<a
|
|
44
|
+
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
|
45
|
+
className={styles.card}
|
|
46
|
+
>
|
|
47
|
+
<h2>Deploy →</h2>
|
|
48
|
+
<p>
|
|
49
|
+
Instantly deploy your Next.js site to a public URL with Vercel.
|
|
50
|
+
</p>
|
|
51
|
+
</a>
|
|
52
|
+
</div>
|
|
53
|
+
</main>
|
|
54
|
+
|
|
55
|
+
<footer className={styles.footer}>
|
|
56
|
+
<a
|
|
57
|
+
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
|
58
|
+
target="_blank"
|
|
59
|
+
rel="noopener noreferrer"
|
|
60
|
+
>
|
|
61
|
+
Powered by{' '}
|
|
62
|
+
<span className={styles.logo}>
|
|
63
|
+
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
|
|
64
|
+
</span>
|
|
65
|
+
</a>
|
|
66
|
+
</footer>
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
padding: 0 2rem;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.main {
|
|
6
|
+
min-height: 100vh;
|
|
7
|
+
padding: 4rem 0;
|
|
8
|
+
flex: 1;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.footer {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex: 1;
|
|
18
|
+
padding: 2rem 0;
|
|
19
|
+
border-top: 1px solid #eaeaea;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.footer a {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
flex-grow: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.title a {
|
|
32
|
+
color: #0070f3;
|
|
33
|
+
text-decoration: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.title a:hover,
|
|
37
|
+
.title a:focus,
|
|
38
|
+
.title a:active {
|
|
39
|
+
text-decoration: underline;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.title {
|
|
43
|
+
margin: 0;
|
|
44
|
+
line-height: 1.15;
|
|
45
|
+
font-size: 4rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.title,
|
|
49
|
+
.description {
|
|
50
|
+
text-align: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.description {
|
|
54
|
+
margin: 4rem 0;
|
|
55
|
+
line-height: 1.5;
|
|
56
|
+
font-size: 1.5rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.code {
|
|
60
|
+
background: #fafafa;
|
|
61
|
+
border-radius: 5px;
|
|
62
|
+
padding: 0.75rem;
|
|
63
|
+
font-size: 1.1rem;
|
|
64
|
+
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
|
|
65
|
+
Bitstream Vera Sans Mono, Courier New, monospace;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.grid {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
max-width: 800px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.card {
|
|
77
|
+
margin: 1rem;
|
|
78
|
+
padding: 1.5rem;
|
|
79
|
+
text-align: left;
|
|
80
|
+
color: inherit;
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
border: 1px solid #eaeaea;
|
|
83
|
+
border-radius: 10px;
|
|
84
|
+
transition: color 0.15s ease, border-color 0.15s ease;
|
|
85
|
+
max-width: 300px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.card:hover,
|
|
89
|
+
.card:focus,
|
|
90
|
+
.card:active {
|
|
91
|
+
color: #0070f3;
|
|
92
|
+
border-color: #0070f3;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.card h2 {
|
|
96
|
+
margin: 0 0 1rem 0;
|
|
97
|
+
font-size: 1.5rem;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.card p {
|
|
101
|
+
margin: 0;
|
|
102
|
+
font-size: 1.25rem;
|
|
103
|
+
line-height: 1.5;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.logo {
|
|
107
|
+
height: 1em;
|
|
108
|
+
margin-left: 0.5rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (max-width: 600px) {
|
|
112
|
+
.grid {
|
|
113
|
+
width: 100%;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body {
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: 0;
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
|
6
|
+
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
a {
|
|
10
|
+
color: inherit;
|
|
11
|
+
text-decoration: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
@@ -11,12 +11,12 @@ This blocklet is a dapp project, which means this is a full-stack application. I
|
|
|
11
11
|
- favicon.svg - favicon
|
|
12
12
|
- index.html - main html file, template for react
|
|
13
13
|
- screenshots/ - Screenshots
|
|
14
|
-
-
|
|
14
|
+
- api/ - Api side code
|
|
15
15
|
- hooks/ - blocklet lifecycle hooks
|
|
16
|
-
- libs/ -
|
|
17
|
-
- middlewares/ -
|
|
18
|
-
- routes/ -
|
|
19
|
-
- index.js -
|
|
16
|
+
- libs/ - Api side libraries
|
|
17
|
+
- middlewares/ - Api side middlewares
|
|
18
|
+
- routes/ - Api side routes
|
|
19
|
+
- index.js - Api side entry point
|
|
20
20
|
- src/ - Client side code (A standard react app structure)
|
|
21
21
|
- .env - Environment variables
|
|
22
22
|
- .env.local - Local environment variables
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
2
2
|
const router = require('express').Router();
|
|
3
3
|
|
|
4
|
-
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
4
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
|
|
5
5
|
|
|
6
6
|
module.exports = router;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
name: template-react
|
|
2
2
|
title: Blocklet Template React
|
|
3
|
-
description: A Blocklet
|
|
3
|
+
description: A Blocklet DAPP blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- react
|
|
7
7
|
group: dapp
|
|
8
8
|
did: ''
|
|
9
|
-
main:
|
|
9
|
+
main: api/index.js
|
|
10
10
|
author:
|
|
11
|
-
name:
|
|
12
|
-
email:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
13
|
repository:
|
|
14
14
|
type: git
|
|
15
15
|
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
@@ -22,7 +22,7 @@ files:
|
|
|
22
22
|
- README.md
|
|
23
23
|
- blocklet.md
|
|
24
24
|
- screenshots
|
|
25
|
-
-
|
|
25
|
+
- api/hooks/pre-start.js
|
|
26
26
|
interfaces:
|
|
27
27
|
- type: web
|
|
28
28
|
name: publicUrl
|
|
@@ -45,7 +45,7 @@ requirements:
|
|
|
45
45
|
os: '*'
|
|
46
46
|
cpu: '*'
|
|
47
47
|
scripts:
|
|
48
|
-
preStart: node
|
|
48
|
+
preStart: node api/hooks/pre-start.js
|
|
49
49
|
dev: npm run start
|
|
50
50
|
environments:
|
|
51
51
|
- name: CHAIN_HOST
|
|
@@ -2,19 +2,29 @@
|
|
|
2
2
|
"name": "template-react",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
|
+
"dev": "react-scripts start",
|
|
5
6
|
"build": "react-scripts build",
|
|
6
7
|
"eject": "react-scripts eject",
|
|
7
|
-
"lint": "eslint src
|
|
8
|
-
"dev": "react-scripts start",
|
|
8
|
+
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
9
9
|
"start": "npm-run-all --parallel start:*",
|
|
10
10
|
"start:client": "npm run dev",
|
|
11
|
-
"start:
|
|
11
|
+
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
12
|
"clean": "rm -rf .blocklet",
|
|
13
|
-
"bundle": "npm run bundle:client && npm run bundle:
|
|
13
|
+
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
14
|
"bundle:client": "PUBLIC_URL='/.blocklet/proxy/<%= did %>' npm run build",
|
|
15
|
-
"bundle:
|
|
15
|
+
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
16
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
|
-
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
17
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
18
|
+
"prepare": "husky install"
|
|
19
|
+
},
|
|
20
|
+
"lint-staged": {
|
|
21
|
+
"*.{mjs,js,jsx,ts,tsx}": [
|
|
22
|
+
"prettier --write",
|
|
23
|
+
"eslint"
|
|
24
|
+
],
|
|
25
|
+
"*.{css,less,scss,json,graphql}": [
|
|
26
|
+
"prettier --write"
|
|
27
|
+
]
|
|
18
28
|
},
|
|
19
29
|
"browserslist": {
|
|
20
30
|
"production": [
|
|
@@ -29,40 +39,42 @@
|
|
|
29
39
|
]
|
|
30
40
|
},
|
|
31
41
|
"dependencies": {
|
|
32
|
-
"@arcblock/did-auth": "
|
|
33
|
-
"@arcblock/did-auth-storage-nedb": "
|
|
34
|
-
"@blocklet/sdk": "
|
|
35
|
-
"@ocap/client": "
|
|
36
|
-
"@ocap/mcrypto": "
|
|
37
|
-
"@ocap/wallet": "
|
|
38
|
-
"axios": "^0.
|
|
42
|
+
"@arcblock/did-auth": "^1.15.2",
|
|
43
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
44
|
+
"@blocklet/sdk": "^1.7.0",
|
|
45
|
+
"@ocap/client": "^1.15.2",
|
|
46
|
+
"@ocap/mcrypto": "^1.15.2",
|
|
47
|
+
"@ocap/wallet": "^1.15.2",
|
|
48
|
+
"axios": "^0.26.1",
|
|
39
49
|
"compression": "^1.7.4",
|
|
40
|
-
"cookie-parser": "^1.4.
|
|
50
|
+
"cookie-parser": "^1.4.6",
|
|
41
51
|
"cors": "^2.8.5",
|
|
42
52
|
"dotenv-flow": "^3.2.0",
|
|
43
|
-
"express": "^4.17.
|
|
53
|
+
"express": "^4.17.3",
|
|
44
54
|
"express-async-errors": "^3.1.1",
|
|
45
55
|
"express-history-api-fallback": "^2.2.1",
|
|
46
56
|
"react": "^17.0.2",
|
|
47
57
|
"react-dom": "^17.0.2",
|
|
48
|
-
"react-router-dom": "^
|
|
49
|
-
"react-scripts": "
|
|
58
|
+
"react-router-dom": "^6.2.2",
|
|
59
|
+
"react-scripts": "5.0.0"
|
|
50
60
|
},
|
|
51
61
|
"devDependencies": {
|
|
52
|
-
"@arcblock/eslint-config": "
|
|
62
|
+
"@arcblock/eslint-config": "^0.1.8",
|
|
53
63
|
"babel-eslint": "^10.1.0",
|
|
54
|
-
"eslint": "^7.
|
|
64
|
+
"eslint": "^7.32.0",
|
|
55
65
|
"eslint-config-airbnb": "^18.2.1",
|
|
56
66
|
"eslint-config-prettier": "^8.3.0",
|
|
57
67
|
"eslint-plugin-import": "^2.23.4",
|
|
58
68
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
59
|
-
"eslint-plugin-prettier": "^3.4.
|
|
69
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
60
70
|
"eslint-plugin-react": "^7.24.0",
|
|
61
71
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
62
72
|
"eslint-plugin-unicorn": "^34.0.1",
|
|
63
|
-
"http-proxy-middleware": "^2.0.
|
|
64
|
-
"
|
|
73
|
+
"http-proxy-middleware": "^2.0.4",
|
|
74
|
+
"husky": "^7.0.4",
|
|
75
|
+
"lint-staged": "^12.3.7",
|
|
76
|
+
"nodemon": "^2.0.15",
|
|
65
77
|
"npm-run-all": "^4.1.5",
|
|
66
|
-
"prettier": "^2.
|
|
78
|
+
"prettier": "^2.6.0"
|
|
67
79
|
}
|
|
68
80
|
}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon"
|
|
6
|
-
<link rel="alternate icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
7
|
-
<link rel="mask-icon" href="%PUBLIC_URL%/favicon.svg" color="#4F6AF5" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
8
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
7
|
<meta name="theme-color" content="#4F6AF5" />
|
|
10
8
|
<meta name="description" content="Web site created using create-blocklet" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BrowserRouter as Router,
|
|
2
|
+
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
import './app.css';
|
|
5
5
|
import Home from './pages/home';
|
|
@@ -8,17 +8,17 @@ import About from './pages/about';
|
|
|
8
8
|
function App() {
|
|
9
9
|
return (
|
|
10
10
|
<div className="app">
|
|
11
|
-
<
|
|
12
|
-
<Route exact path="/"
|
|
13
|
-
<Route path="/about"
|
|
14
|
-
<Route path="/home"
|
|
15
|
-
<
|
|
16
|
-
</
|
|
11
|
+
<Routes>
|
|
12
|
+
<Route exact path="/" element={<Home />} />
|
|
13
|
+
<Route path="/about" element={<About />} />
|
|
14
|
+
<Route path="/home" element={<Home />} />
|
|
15
|
+
<Route path="*" element={<Navigate to="/" />} />
|
|
16
|
+
</Routes>
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const WrappedApp =
|
|
21
|
+
const WrappedApp = App;
|
|
22
22
|
|
|
23
23
|
export default () => {
|
|
24
24
|
// While the blocklet is deploy to a sub path, this will be work properly.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:prettier/recommended'],
|
|
7
|
+
globals: {
|
|
8
|
+
// Ref sugar (take 2)
|
|
9
|
+
$: 'readonly',
|
|
10
|
+
$$: 'readonly',
|
|
11
|
+
$ref: 'readonly',
|
|
12
|
+
$shallowRef: 'readonly',
|
|
13
|
+
$computed: 'readonly',
|
|
14
|
+
|
|
15
|
+
// script setup
|
|
16
|
+
defineProps: 'readonly',
|
|
17
|
+
defineEmits: 'readonly',
|
|
18
|
+
defineExpose: 'readonly',
|
|
19
|
+
withDefaults: 'readonly',
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
23
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
2
|
+
require('dotenv-flow').config();
|
|
3
|
+
|
|
4
|
+
const Client = require('@ocap/client');
|
|
5
|
+
|
|
6
|
+
const env = require('../libs/env');
|
|
7
|
+
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
9
|
+
const { name } = require('../../package.json');
|
|
10
|
+
|
|
11
|
+
const ensureAccountDeclared = async () => {
|
|
12
|
+
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
14
|
+
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
|
+
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
|
+
if (!state) {
|
|
18
|
+
const hash = await client.declare({ moniker: name, wallet });
|
|
19
|
+
logger.log(`app account declared on chain ${env.chainHost}`, hash);
|
|
20
|
+
} else {
|
|
21
|
+
logger.log(`app account already declared on chain ${env.chainHost}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
await ensureAccountDeclared();
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
logger.error(`${name} pre-start error`, err.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
4
|
+
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
6
|
+
|
|
7
|
+
const env = require('./env');
|
|
8
|
+
|
|
9
|
+
const wallet = getWallet();
|
|
10
|
+
const authenticator = new WalletAuthenticator();
|
|
11
|
+
const handlers = new WalletHandler({
|
|
12
|
+
authenticator,
|
|
13
|
+
tokenStorage: new AuthStorage({
|
|
14
|
+
dbPath: path.join(env.dataDir, 'auth.db'),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
authenticator,
|
|
20
|
+
handlers,
|
|
21
|
+
wallet,
|
|
22
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
2
2
|
const router = require('express').Router();
|
|
3
3
|
|
|
4
|
-
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
4
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
|
|
5
5
|
|
|
6
6
|
module.exports = router;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
name: template-vue
|
|
2
2
|
title: Blocklet Template Vue
|
|
3
|
-
description: A Blocklet
|
|
3
|
+
description: A Blocklet DAPP blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- vue
|
|
7
7
|
group: dapp
|
|
8
8
|
did: ''
|
|
9
|
-
main:
|
|
9
|
+
main: api/index.js
|
|
10
10
|
author:
|
|
11
|
-
name:
|
|
12
|
-
email:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
13
|
repository:
|
|
14
14
|
type: git
|
|
15
15
|
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
@@ -22,6 +22,7 @@ files:
|
|
|
22
22
|
- README.md
|
|
23
23
|
- blocklet.md
|
|
24
24
|
- screenshots
|
|
25
|
+
- api/hooks/pre-start.js
|
|
25
26
|
interfaces:
|
|
26
27
|
- type: web
|
|
27
28
|
name: publicUrl
|
|
@@ -44,7 +45,7 @@ requirements:
|
|
|
44
45
|
os: '*'
|
|
45
46
|
cpu: '*'
|
|
46
47
|
scripts:
|
|
47
|
-
preStart: node
|
|
48
|
+
preStart: node api/hooks/pre-start.js
|
|
48
49
|
dev: npm run start
|
|
49
50
|
environments:
|
|
50
51
|
- name: CHAIN_HOST
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon"
|
|
6
|
-
<link rel="alternate icon" href="<%- base %>/favicon.ico" />
|
|
7
|
-
<link rel="mask-icon" href="<%- base %>/favicon.svg" color="#4F6AF5" />
|
|
5
|
+
<link rel="icon" href="<%- base %>/favicon.ico" />
|
|
8
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
7
|
<meta name="theme-color" content="#4F6AF5" />
|
|
10
8
|
<meta name="description" content="Web site created using create-blocklet" />
|
|
@@ -12,6 +10,7 @@
|
|
|
12
10
|
<script src="__meta__.js"></script>
|
|
13
11
|
</head>
|
|
14
12
|
<body>
|
|
13
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
15
14
|
<div id="app"></div>
|
|
16
15
|
<script type="module" src="/src/main.js"></script>
|
|
17
16
|
</body>
|