create-steedos-app 2.5.17-beta.1 → 2.5.17-beta.10

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 (41) hide show
  1. package/dist/default/README-template.md +61 -38
  2. package/dist/default/moleculer.config.js +1 -1
  3. package/dist/default/package.json +18 -0
  4. package/dist/default/steedos-packages/example-service/package.service.js +86 -0
  5. package/dist/default/{docker-compose.yml → steedos-platform/docker-compose.yml} +10 -18
  6. package/dist/default/steedos-platform/package.json +13 -0
  7. package/dist/default/{steedos.config.js → steedos-platform/steedos.config.js} +10 -3
  8. package/dist/index.js +9 -9
  9. package/package.json +4 -3
  10. package/templates/default/.env +6 -0
  11. package/{dist/default/gitpod.yml → templates/default/.gitpod.yml} +10 -11
  12. package/templates/default/.vscode/extensions.json +5 -0
  13. package/templates/default/.vscode/settings.json +17 -0
  14. package/templates/default/.vscode/tasks.json +20 -0
  15. package/templates/default/README-template.md +87 -0
  16. package/templates/default/README.md +87 -0
  17. package/templates/default/moleculer.config.js +18 -0
  18. package/templates/default/package.json +18 -0
  19. package/templates/default/steedos-packages/example-service/README.md +19 -0
  20. package/templates/default/steedos-packages/example-service/package.json +8 -0
  21. package/templates/default/steedos-packages/example-service/package.service.js +86 -0
  22. package/templates/default/steedos-platform/.env +10 -0
  23. package/templates/default/steedos-platform/README.md +32 -0
  24. package/templates/default/steedos-platform/docker-compose.yml +49 -0
  25. package/templates/default/steedos-platform/package.json +13 -0
  26. package/templates/default/steedos-platform/steedos.config.js +22 -0
  27. package/dist/default/Dockerfile +0 -20
  28. package/dist/default/env +0 -44
  29. package/dist/default/gitignore +0 -19
  30. package/dist/default/lerna.json +0 -7
  31. package/dist/default/nodered.config.js +0 -18
  32. package/dist/default/npmrc +0 -1
  33. package/dist/default/services/example-service/api/graphqlQuerySpaceUsers.js +0 -22
  34. package/dist/default/services/example-service/api/objectqlQuerySpaceUsers.js +0 -18
  35. package/dist/default/services/example-service/package.service.js +0 -31
  36. package/dist/default/services/example-service/triggers/spaceUsersBeforeUpdate.js +0 -6
  37. package/dist/default/services/steedos-app/package.json +0 -8
  38. package/dist/default/services/steedos-app/package.service.js +0 -69
  39. package/dist/default/yarnrc +0 -1
  40. package/dist/gitignore +0 -19
  41. /package/dist/default/{services → steedos-packages}/example-service/package.json +0 -0
@@ -1,64 +1,87 @@
1
- 华炎魔方模版项目
2
- ===
3
1
 
4
- <p align="center">
5
- <a href="./README_en.md">English</a>
6
- <a href="https://www.steedos.cn/docs/"> · 文档</a>
7
- <a href="https://www.steedos.cn/videos/"> · 视频</a>
8
- <a href="https://demo.steedos.cn"> · 试用</a>
9
- </p>
2
+ # Steedos DX Project Template
10
3
 
4
+ Steedos Developer Experience (DX) is a new way to manage and develop apps on the Steedos Low-Code Platform across their entire lifecycle. It brings together the best of the Low-Code Platform to enable source-driven development, team collaboration with governance, and new levels of agility for custom app development on Steedos.
11
5
 
12
- <p align="center" style="border-top: solid 1px #cccccc">
13
- 华炎魔方是 <a href="https://developer.salesforce.com/developer-centers/developer-experience" target="_blank">Salesforce Developer Experience (DX)</a> 的开源替代方案,将低代码技术与 <a href="https://www.steedos.cn/docs/deploy/devops"> DevOps 工具</a> 结合,实现敏捷开发的新高度。
14
- </p>
6
+ - [What is Steedos DX](https://docs.steedos.com/developer/setup/steedos-dx)
7
+ - [What is Steedos Package](https://docs.steedos.com/developer/package/overview)
15
8
 
16
- <h3 align="center">
17
- 🤖 🎨 🚀
18
- </h3>
9
+ # Getting Started
19
10
 
11
+ ## Run Steedos Platform
20
12
 
21
- # 快速向导
13
+ First, you must run Steedos Platform. You can follow the [Self Hosting Tutorial](/deploy/deploy-docker) to deploy Steedos on a server, or launch a local Steedos Platform.
22
14
 
23
- ## 启动华炎魔方
15
+ ```bash
16
+ cd steedos-platform
17
+ docker-compose up
18
+ ```
19
+
20
+ You can also refer to the instructions in the `./steedos-platform` dir to run Steedos Platform with Node.js.
21
+
22
+ ### Register Admin Account
23
+
24
+ Upon its first launch, the system will prompt you to register an account and create an organization. This account will also become the administrator account for the organization.
24
25
 
25
- 开发软件包之前,先启动花华炎魔方服务。
26
+ ### Create an API Key
26
27
 
27
- 1. .env 复制为 .env.local,并修改相关配置参数。
28
- 2. 使用 docker 启动华炎魔方。
28
+ You can log in to the Steedos server with administrator credentials, go to the settings app, select the API Key menu, and create a new API Key.
29
+
30
+ ## Setup Environment Variable
31
+
32
+ ### Setup TRANSPORTER
33
+
34
+ The Steedos package operates using the [Moleculer](https://moleculer.services/docs) microservices framework, connecting microservices through the configuration of a unified Transporter.
35
+
36
+ [Moleculer Transporter](https://moleculer.services/docs/0.14/networking) is an important module if you are running services on multiple nodes. Transporter communicates with other nodes. It transfers events, calls requests and processes responses …etc. If multiple instances of a service are running on different nodes then the requests will be load-balanced among them.
29
37
 
30
38
  ```bash
31
- docker-compose up
39
+ TRANSPORTER=redis://127.0.0.1:6379
32
40
  ```
41
+ :::tip
42
+ Please make sure the TRANSPORTER you configured matches the Steedos server you wish to connect to and that the network is interconnected.
43
+ :::
33
44
 
34
- ## 访问华炎魔方
45
+ :::danger
46
+ For running in a production environment, be sure to configure the Redis password.
47
+ :::
35
48
 
36
- 打开浏览器,访问 http://127.0.0.1:5000,进入华炎魔方。
49
+ ### Setup Metadata Server
37
50
 
38
- 进入设置应用,可以:
39
- - 创建自定义对象
40
- - 创建应用
41
- - 创建微页面
51
+ Setup environment variables required for metadata synchronization.
42
52
 
43
- ## 开发软件包
53
+ ```bash
54
+ steedos source:config
55
+ ```
56
+
57
+ - Metadata Server: METADATA_SERVER is the ROOT_URL of the Steedos server you wish to connect to.
58
+ - Metadata API Key: METADATA_APIKEY is used to authenticate your identity.
44
59
 
45
- 可以使用微服务的方式扩展华炎魔方。可以参考 services 文件夹下的例子。
60
+ This command writes environment variables into the .env.local file,
46
61
 
47
62
  ```bash
48
- yarn
49
- yarn start
63
+ METADATA_SERVER=
64
+ METADATA_APIKEY=
50
65
  ```
51
66
 
52
- ## 使用 Node-RED
67
+ You can also set the above environment variables directly without running the command.
53
68
 
54
- [Node-Red](https://nodered.org/) IBM 开源的服务端低代码开发工具,提供了可视化的开发环境,开发华炎魔方微服务。
69
+ ## Run Steedos Packages
55
70
 
56
- - 创建定时任务
57
- - 自定义微服务
58
- - 自定义API
59
- - 自定义触发器
60
- - 接收和推送消息
71
+ ### Install Dependences
61
72
 
62
73
  ```bash
63
- yarn nodered
74
+ yarn
64
75
  ```
76
+
77
+ ### Run Packages
78
+
79
+ You can use the [moleculer-runner](https://moleculer.services/docs/0.14/runner) command to launch the steedos packages.
80
+
81
+ ```bash
82
+ yarn moleculer-runner steedos-packages/*/package.service.js --hot --repl
83
+ ```
84
+
85
+ :::tip
86
+ Please note that the Steedos DX project supports multi-package development, and the above command simultaneously launches all packages under the steedos-packages folder.
87
+ :::
@@ -15,4 +15,4 @@ module.exports = {
15
15
  started(broker) {
16
16
  },
17
17
 
18
- };
18
+ };
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": "0.0.1",
3
+ "private": true,
4
+ "workspaces": [
5
+ "steedos-packages/*"
6
+ ],
7
+ "repository": "git://github.com/steedos/steedos-project-template.git",
8
+ "scripts": {
9
+ "start": "moleculer-runner steedos-packages/*/package.service.js --hot --repl",
10
+ "repl": "moleculer-runner --repl"
11
+ },
12
+ "dependencies": {
13
+ "@steedos/service-package-loader": "^2.5"
14
+ },
15
+ "devDependencies": {
16
+ "moleculer-repl": "^0.7.4"
17
+ }
18
+ }
@@ -0,0 +1,86 @@
1
+ const project = require('./package.json');
2
+ const packageLoader = require('@steedos/service-package-loader');
3
+
4
+ module.exports = {
5
+ name: "example-service",
6
+
7
+ mixins: [packageLoader],
8
+
9
+ metadata: {
10
+ $package: {
11
+ name: project.name,
12
+ version: project.version,
13
+ path: __dirname,
14
+ isPackage: true
15
+ }
16
+ },
17
+
18
+ actions: {
19
+ hello: {
20
+ // 使用微服务方式定义 API 接口。
21
+ // 访问地址: GET /service/api/example-service/hello/:name
22
+ rest: { method: 'GET', path: '/hello/:name' },
23
+ handler(ctx) {
24
+ return {
25
+ data: 'Welcome ' + ctx.params.name
26
+ }
27
+ }
28
+ },
29
+ me: {
30
+ rest: { method: 'GET', path: '/me' },
31
+ // 在微服务中获取当前登录的用户信息
32
+ async handler(ctx) {
33
+ return ctx.meta.user
34
+ }
35
+ },
36
+ // 在微服务中调用graphql查询数据库
37
+ graphqlQuerySpaceUsers: {
38
+ rest: { method: 'GET', path: '/graphql' },
39
+ async handler(ctx) {
40
+ return await this.broker.call('api.graphql', {
41
+ query: `
42
+ query {
43
+ space_users(filters: ["user", "=", "${ctx.meta.user.userId}"]) {
44
+ name
45
+ organization__expand {
46
+ name
47
+ }
48
+ }
49
+ }
50
+ `},
51
+ // 如果查询 GraphQL 需要带上当前用户的权限,需要传入 user 属性。
52
+ {
53
+ user: ctx.meta.user
54
+ }
55
+ )
56
+ },
57
+ },
58
+ // 在微服务中调用objectql查询数据库, 需要 mixins: [require('@steedos/service-object-mixin')],
59
+ objectqlQuerySpaceUsers: {
60
+ rest: { method: 'GET', path: '/objectql' },
61
+ async handler(ctx) {
62
+ return await this.getObject('space_users').find(
63
+ {
64
+ filters: ['user', '=', ctx.meta.user.userId]
65
+ },
66
+ ctx.meta.user
67
+ )
68
+ }
69
+ },
70
+ // 使用微服务定义触发器
71
+ spaceUsersBeforeUpdate: {
72
+ trigger: { listenTo: 'space_users', when: ['beforeUpdate', 'beforeInsert']},
73
+ async handler(ctx) {
74
+ this.broker.logger.info('spaceUsersBeforeUpdate', ctx)
75
+ }
76
+ }
77
+ },
78
+ events: {
79
+ "@space_users.updated": {
80
+ handler(payload) {
81
+ // 监听人员修改事件
82
+ this.broker.logger.info(payload);
83
+ }
84
+ }
85
+ }
86
+ }
@@ -6,20 +6,23 @@ services:
6
6
  image: steedos/steedos-community:2.5
7
7
  ports:
8
8
  - "5000:5000"
9
- env_file:
10
- - .env.local
11
9
  environment:
12
10
  - PORT=5000
11
+ - ROOT_URL=http://127.0.0.1:5000
13
12
  - MONGO_URL=mongodb://mongodb:27017/steedos
14
13
  - MONGO_OPLOG_URL=mongodb://mongodb:27017/local
15
- - TRANSPORTER=nats://nats:4222
16
- - CACHER=redis://redis:6379
14
+ - TRANSPORTER=redis://redis:6379
15
+ - CACHER=redis://redis:6379/1
16
+ - STEEDOS_STORAGE_DIR=./steedos-storage
17
+ volumes:
18
+ - "./steedos-storage:/steedos-storage"
17
19
  depends_on:
18
20
  mongodb:
19
21
  condition: service_healthy
20
22
 
21
23
  redis:
22
- image: redis:6.2
24
+ image: redis:6.2.10
25
+ command: "redis-server --save \"\" --appendonly no --loglevel warning"
23
26
  ports:
24
27
  - "6379:6379"
25
28
 
@@ -27,14 +30,14 @@ services:
27
30
  image: mongo:4.4
28
31
  ports:
29
32
  - 27017:27017
30
- entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "steedos" ]
33
+ command: "--bind_ip_all --replSet steedos --logpath /var/log/mongodb/mongod.log"
31
34
  healthcheck:
32
35
  test: echo 'db.runCommand("ping").ok' | mongo --quiet | grep 1
33
36
  interval: 10s
34
37
  timeout: 10s
35
38
  retries: 5
36
39
  volumes:
37
- - 'steedos-mongo-data:/data/db'
40
+ - './steedos-storage-mongodb:/data/db'
38
41
 
39
42
  mongodb-init:
40
43
  image: mongo:4.4
@@ -44,14 +47,3 @@ services:
44
47
  condition: service_healthy
45
48
  command: >
46
49
  mongo --host mongodb:27017 --eval "rs.initiate({ _id: 'steedos', members: [{_id: 0, host: 'mongodb:27017'}]})"
47
-
48
- # Micro Service Transporter
49
- nats:
50
- image: bitnami/nats
51
- ports:
52
- - "4222:4222"
53
- - "8222:8222" # monitor port
54
-
55
- volumes:
56
- steedos-mongo-data:
57
- driver: local
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "steedos-platform",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "license": "MIT",
6
+ "scripts": {
7
+ "start": "steedos start"
8
+ },
9
+ "dependencies": {
10
+ "@steedos/service-community": "^2.5"
11
+ }
12
+ }
13
+
@@ -1,5 +1,10 @@
1
- require('dotenv-flow').config();
1
+ const path = require('path');
2
+ require('dotenv-flow').config({
3
+ path: path.join(__dirname, '.')
4
+ });
2
5
 
6
+ // Moleculer Configuration
7
+ // https://moleculer.services/docs/0.14/configuration.html
3
8
  module.exports = {
4
9
  // Namespace of nodes to segment your nodes on the same network.
5
10
  namespace: "steedos",
@@ -7,9 +12,11 @@ module.exports = {
7
12
  // Available values: trace, debug, info, warn, error, fatal
8
13
  logLevel: "warn",
9
14
 
15
+ transporter: process.env.TRANSPORTER,
16
+
10
17
  // Called after broker started.
11
18
  started(broker) {
12
19
  broker.createService(require("@steedos/service-community"));
13
- },
14
-
20
+ }
21
+
15
22
  };