tiny-engine/dl-flow-backend
GaoNeng dbb8365f35
feat: 花岗岩小队作品提交 (#414)
* fix:修复资源管理工具类型切换 (#239)

* fix:修复资源管理工具类型切换

* fix: 左右两侧面板宽度固定为280px (#230)

* fix(styles-spacing): 增大物料设置内外边距时点击区域 #134 (#184)

* fix(styles-spacing): 增大物料设置内外边距时点击区域 #134

* fix:预览引入builtin组件依赖,built组件样式文件注入js (#251)

* add config (#262)

* add config

* update config

* fix: 修复由于物料边框引起的左侧面板样式问题 (#247)

* fix: 设计器构建后使用vue runtime prod build(本地开发保持development, preview预览保持development) (#254)

* fix(canvas-renderer): 修复 isNative component 判断失效的 bug (#241)

* feat: js panel add jsx support  (#253)

* feat: JS面板支持JSX语法

* fix: 画布解析JS表达式时支持JSX语法

* fix: 修复画布解析JSX表达式时会返回undefined

* feat: 添加Tree和Tooltip的自定义渲染函数属性

* fix: 修改变量名

* feat: algo node

* fix: 修复报错

* fix: fix overflow

* feat: add node

* feat(setting): property

* feat: property setting

* feat(layer): bundle schema

* feat: useMonaco hook

* feat(code): monaco editor

* feat: code editor

* refactor: monaco editor

* feat: useVisitor

* feat(front-end): save layer

* init: backend project init

* refactor: move dl-flow-front repository to dl-flow

* chore: move dl-flow-backend to dl-flow

* chore: 重构仓库结构

* ci: fix ci

* feat(backend): unit test

* chore: update ci

* ci: 手动触发

* fix: ci error

* feat: hot load & minifiy

* fix: ci error

* feat(back): refactor to nest.js

* feat: expose port in docker-compose.yaml

* release: v0.0.2

* release: v0.0.3 release

* release: v0.0.4

* fix: ci fix

* fix: ci

* fix: ci

* fix: ci

* fix: ci

* fix: ci

* fix: ci

* fix: fix import

* fix: fix import

* feat(backend): layer controller

* feat(bakend): material

* fix: fix layer unit test error

* release: version 0.0.7 release

* fix(front-end): fix warning

* feat: save layer

* fix(backend): if property is undefined will no longer throw server error

* feat: remove memory server in dev env

* fix(front): delete tab item lazy load

fix(front): label i18n

* feat: remove cache when install dependencies

* fix: ci

* styled(front): delete console.log

* feat(frontend): context menu

* feat(front): group

* feat(front): group layout

* feat(front): group auto size & auto position

* feat(front): update schema

* feat(front): schema plugin

* feat(front): schema editor

* feat(front): schema field change

* feat(front): schema dynamic change

* feat(frontend): export button

* feat(backend): should add layer identifier when save

* feat(backend): code-generate service

* feat(backend): code generate

* test(backend): base unit test

* test(ast): ast base unit test

* feat(frontend): emit createCodeGenerate event

* feat(bakend): generate python code

* feat(backend): file download

* feat(front): download file

* test(backend): remove code-generate gateway unit test

* feat(frontend): add layer

You can use your existing network to build a lenet now

* feat(backend): remove generate res

* fix(frontend): retry

* fix: group generate code fail

* fix: build error

* 🐳 chore: frontend image

* chore: add packaging strategy

* fix: expose 9000-9900 ports

* chore: ignore all conf file when docker build

* feat: deploy example

* feat: expose bundle.json

* feat(backend): get material

* feat(frontend): unexpose bundle.json

* test: skip ast

* feat(frontend): get material

* feat: README.md

* feat(bundle): bundle data

* feat: update css

* feat: ref schema

* feat(font): list data sturct support

* feat(backend): support list data-struct

* feat(bundle): upsample, SpectralNorm Unflatten

* test(back): ast unit test

* feat(back): user api

* feat: use secret at test

* feat: Add environment variables to dockerfile

* fix: ci error

* feat(back): auth guard

* feat(user): register

* feat(front): login & register

* feat(backend): auth at code generate

* feat: remove dashboard

* refactor: group generate

* styled: clean comment code

* feat: build sequential

* feat(backend): Sequential

* feat(backend): auto load bundle.json

* feat: update example bundle.json

* doc: update readme

* doc: update readme & docker-compose

* fix(backend): jwt token expire

* fix: data will never is empty

* fix: force get schema

* feat: Improve link logic

* fix(backend): stack overflow at sequencingNode

* feat: Fix the issue of untraceable child nodes

* feat: Nested groups are not allowed

* feat: completion bundle.json

* fix(backend): bcrypt error

* fix(backend): restore auth in gateway

* feat(backend): ws exception

* feat(frontend): error retry

* feat: salt len

* fix: ci error

* fix: when process.env.PWD_SALT is undefined

* fix(backend): salt error

* refactor(addons): clean toolbars

* refactor(canvas): remove Unused components

* doc: perfect document

* docs: Discussion on the Commutability of Function Combinations

* docs: complete the images in the document

* doc: refinish documents

* 更新 README.md

* doc: improve documentation and annotations

* docs: improve documentation

* refactor: repo sturct

* fix: dry run

* fix: build error

* fix: build err

* fix(example): docker compose up -d can run

* feat: all in one start

* feat(dashboard): backend

* fix(backend): project:counter loss

* feat(frontend): infinity scroll load project

* feat(frontend): navigator

* feat(frontend): save schema

* feat(backend): add data field when return project info

* feat(backend): should take graphData when save

* feat(frontend): save and import data

* feat: welcome will take nick name

* fix: return data at create

* fix(front): edge loss

* fix: build error

* fix: build error

* fix: build error

* feat(front): rename

* feat(front): update state

* fix(rename): import style

* feat(frontend): menu

* feat(frontend): menu

* fix: add loss entry

* fix: add loss dep

* fix: prettier error

* fix: collapse error

* fix: do not use jsx

* feat: menu take style

* fix(backend):when paramattr name is empty, use uuid

* feat(backend): expose example volume

* fix: add padding property

*  feat(example): add example

* docs: update README

* fix: mirror error

---------

Co-authored-by: yaoyun8 <142570291+yaoyun8@users.noreply.github.com>
Co-authored-by: lizhijie429 <632163606@qq.com>
Co-authored-by: wenmine <wwmmail@foxmail.com>
Co-authored-by: Lu17301156525 <128358973+Lu17301156525@users.noreply.github.com>
Co-authored-by: rhlin <r.h.lin@163.com>
Co-authored-by: chilingling <26962197+chilingling@users.noreply.github.com>
Co-authored-by: Gene <Pacify.98@gmail.com>
2024-05-09 15:27:21 +08:00
..
data feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
examples feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
libs feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
proof feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
src feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
test feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.dockerignore feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.editorconfig feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.env feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.eslintrc.js feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.gitignore feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
.prettierrc feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
README.md feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
docker-compose.yaml feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
dockerfile feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
global.d.ts feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
group-nest-test-case.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
nest-cli.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
node-undefined-test-case.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
package.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
tsconfig.build.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
tsconfig.json feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00
webpack.config.js feat: 花岗岩小队作品提交 (#414) 2024-05-09 15:27:21 +08:00

README.md

dl-flow backend

目录结构

├── README.md
├── docker-compose.yaml // 快速启动 compose示例
├── dockerfile          // docker构建文件
├── global.d.ts
├── libs
│   ├── database        // 数据库模块
│   ├── redis           // 缓存模块
│   └── shared          // 共用文件
├── src
│   ├── app.module.ts   // 主文件
│   ├── auth-guard      // token校验门禁 (可以理解为中间件, 不过nest的分类更加细致)
│   ├── code-generate
│   │   ├── ast
│   │   ├── ast.service.ts                      // ast生成服务
│   │   ├── code-generate.controller.ts         // code-generate路由
│   │   ├── code-generate.gateway.ts            // code-generate的websocket路由, 不过在nest中叫做gateway
│   │   ├── code-generate.module.ts             // code-generate的module
│   │   ├── code-generate.schema.ts             // code-generate的schema
│   │   └── code-generate.service.ts            // code-generate的服务
│   ├── layer                                   // layer获取与存储的http接口 (没什么技术含量全是CRUD)
│   ├── main.ts
│   ├── material                                // 物料的获取 (没什么技术含量全是CRUD)
│   ├── user                                    // 用户的登陆注册
│   └── ws-exception                            // websocket的错误捕获, 主要用于捕获Exception和Runtime Error
├── tsconfig.build.json
├── tsconfig.json
└── webpack.config.js                           // 打包的配置文件, 主要是定义全局变量

global.d.ts

declare global {
  namespace NodeJS {
    // 为了让process.env.xxx的时候有类型提示
    interface ProcessEnv {
      DB_URL: string;
      REDIS_HOST: string;
      REDIS_PORT: number;
      REDIS_DB: number;
      REDIS_PASSWORD: string;
      JWT_EXPIRE_IN: string;
      JWT_SIGN_ALGORITHM: JwtSignOptions['algorithm'];
      JWT_PUB_KEY: string;
      JWT_PRI_KEY: string;
      /**
       * @deprecated
       */
      PWD_SALT: string; // used for bcrypt
      PWD_SALT_LEN: string;
    }
  }
  // 开发环境标志
  declare const __DEV__: boolean;
  // 测试环境标志
  declare const __TEST__: boolean;
}
export {};

QA

为什么使用的是全局变量而不是环境变量?

__DEV____TEST__主要是用于测试环境与开发环境。如果一段代码只是测试环境需要(例如准备内存数据库),那么我们可以这么写

if (__TEST__){
  // do sth
}

之后我们只需要在jest的配置文件里的global配置项中中,将__TEST__定义为true就可以了。详细参考packages.json L94 而在打包时侯,webpack会将__DEV____TEST__占位符替换为false, 这样一来所有的测试代码与开发调试代码都将会被标记为dead code. 最后会被webpack自动剔除 (详细参考 webpack.config.js L12-)

为什么使用内存数据库而不是MOCK

mock一组数据是人来mock, 工作量是其次,最主要的问题是难以靠近实战. 之所以选择使用内存数据库而不是手动mock, 我给出如下原因

  1. 不需要手动mock数据避免因为人脑无法达到完全理性而造成的数据结构问题
  2. 内存数据库的可维护性很高
  3. 数据的销毁简单,不需要本地启动复杂的环境