Skip to content

Commit

Permalink
chore(create-blocklet): use middlewares.session replace middlewares.u…
Browse files Browse the repository at this point in the history
…ser (#368)
  • Loading branch information
LancelotLewis authored Sep 30, 2024
1 parent 3601bdc commit 336ac66
Show file tree
Hide file tree
Showing 40 changed files with 81 additions and 75 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.11 (2024-9-30)

- chore(deps): update deps
- chore(create-blocklet): use middlewares.session replace middlewares.user

## 0.9.10 (2024-9-29)

- chore(create-blocklet): use onConnect in did-connect-dapp
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-blocklet",
"private": true,
"version": "0.9.10",
"version": "0.9.11",
"description": "",
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-blocklet",
"version": "0.9.10",
"version": "0.9.11",
"exports": "./index.js",
"type": "module",
"repository": "git@github.com:blocklet/create-blocklet.git",
Expand Down
7 changes: 4 additions & 3 deletions packages/create-app/templates/did-connect-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"@iconify/react": "^5.0.2",
"@mui/material": "^5.16.7",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"flat": "^6.0.1",
Expand All @@ -75,8 +75,9 @@
"react": "~18.2.0",
"react-dom": "~18.2.0",
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const authClient = new AuthService();

module.exports = {
init(app) {
// middleware.user() is used to get the user info from the session, see more: https://www.arcblock.io/docs/blocklet-developer/blocklet-sdk#session
app.get('/api/user', middlewares.user(), async (req, res) => {
// middlewares.session() is used to get the user info from the session, see more: https://www.arcblock.io/docs/blocklet-developer/blocklet-sdk#session
app.get('/api/user', middlewares.session(), async (req, res) => {
if (!req.user) {
res.json({ user: null });
return;
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app/templates/did-wallet-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.16.7",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"dayjs": "^1.11.13",
"dotenv-flow": "^4.1.0",
"flat": "^6.0.1",
Expand All @@ -52,7 +52,7 @@
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-node": "^2.1.1",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-require": "^1.2.14",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/templates/express-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"devDependencies": {
"@arcblock/eslint-config-base": "^0.3.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"eslint": "^8.57.1",
"lint-staged": "^15.2.10",
"nodemon": "^3.1.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/templates/html-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"license": "ISC",
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"prettier": "^3.3.3",
"rimraf": "^5.0.10",
"zx": "^8.1.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/templates/monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"@arcblock/eslint-config": "^0.3.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"eslint": "^8.57.1",
"prettier": "^3.3.3",
"simple-git-hooks": "^2.11.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/templates/nestjs-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@types/node": "^20.16.10",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"eslint": "^8.57.1",
"lint-staged": "^15.2.10",
"nodemon": "^3.1.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/nextjs-dapp/api/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewares');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

module.exports = router;
2 changes: 1 addition & 1 deletion packages/create-app/templates/nextjs-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"eslint": "8.57.0",
"eslint-config-next": "14.2.4",
"lint-staged": "^15.2.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import middleware from '@blocklet/sdk/lib/middlewares';
import middlewares from '@blocklet/sdk/lib/middlewares';
import { Router } from 'express';

const router = Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

router.use('/data', (_, res) =>
res.json({
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app/templates/react-dapp-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"@types/node": "^20.16.10",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"import-sort-style-module": "^6.0.0",
Expand All @@ -81,7 +81,7 @@
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/react-dapp/api/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewaress');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

router.use('/data', (req, res) =>
res.json({
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app/templates/react-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"@arcblock/eslint-config": "^0.3.2",
"@blocklet/js-sdk": "^1.16.32",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"lint-staged": "^15.2.10",
Expand All @@ -71,7 +71,7 @@
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewaress');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

module.exports = router;
6 changes: 3 additions & 3 deletions packages/create-app/templates/react-gun-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"devDependencies": {
"@arcblock/eslint-config": "^0.3.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"lint-staged": "^15.2.10",
Expand All @@ -71,7 +71,7 @@
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app/templates/react-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"devDependencies": {
"@arcblock/eslint-config": "^0.3.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"eslint": "^8.57.1",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
Expand All @@ -52,7 +52,7 @@
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewares');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

router.use('/data', (req, res) =>
res.json({
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/solidjs-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@blocklet/js-sdk": "^1.16.32",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -36,7 +36,7 @@
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-solid": "^2.10.2",
"zx": "^8.1.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/solidjs-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"license": "MIT",
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -32,7 +32,7 @@
"simple-git-hooks": "^2.11.1",
"solid-js": "^1.9.1",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-solid": "^2.10.2",
"zx": "^8.1.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/svelte-dapp/api/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewares');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

router.use('/data', (req, res) =>
res.json({
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/svelte-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@blocklet/js-sdk": "^1.16.32",
"@sveltejs/vite-plugin-svelte": "3.1.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"lint-staged": "^15.2.10",
"npm-run-all": "^4.1.5",
Expand All @@ -44,7 +44,7 @@
"simple-git-hooks": "^2.11.1",
"svelte": "^4.2.19",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"zx": "^8.1.8"
},
"lint-staged": {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/svelte-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"bumpp": "^9.5.2",
"bumpp": "^9.6.1",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.7",
"rimraf": "^5.0.10",
"simple-git-hooks": "^2.11.1",
"svelte": "^4.2.19",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"zx": "^8.1.8"
},
"lint-staged": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import middleware from '@blocklet/sdk/lib/middlewares';
import middlewares from '@blocklet/sdk/lib/middlewares';
import { Router } from 'express';

import todoListRouter from './todo-list';

const router = Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/todo-list', middleware.user(), todoListRouter);
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));
router.use('/todo-list', middlewares.session(), todoListRouter);

export default router;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import middleware from '@blocklet/sdk/lib/middlewares';
import middlewares from '@blocklet/sdk/lib/middlewares';
import { Router } from 'express';

import $get from './$get';
Expand All @@ -7,7 +7,7 @@ import $put from './$put';
const todoListRouter = Router();

// Step 2: the function of reading and writing DID Space is implemented
todoListRouter.get('/', middleware.user(), $get);
todoListRouter.put('/', middleware.user(), $put);
todoListRouter.get('/', middlewares.session(), $get);
todoListRouter.put('/', middlewares.session(), $put);

export default todoListRouter;
6 changes: 3 additions & 3 deletions packages/create-app/templates/todo-list-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@types/react-toastify": "^4.1.0",
"@vitejs/plugin-react": "^4.3.1",
"bumpp": "^9.5.2",
"@vitejs/plugin-react": "^4.3.2",
"bumpp": "^9.6.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -96,7 +96,7 @@
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vite": "^5.4.8",
"vite-plugin-blocklet": "^0.9.10",
"vite-plugin-blocklet": "^0.9.11",
"vite-plugin-svgr": "^4.2.0",
"zx": "^8.1.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/templates/vue-dapp/api/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const middleware = require('@blocklet/sdk/lib/middlewares');
const middlewares = require('@blocklet/sdk/lib/middlewares');
const router = require('express').Router();

router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
router.use('/user', middlewares.session(), (req, res) => res.json(req.user || {}));

router.use('/data', (req, res) =>
res.json({
Expand Down
Loading

0 comments on commit 336ac66

Please sign in to comment.