{"id":13597929,"url":"https://github.com/dyb881/nest-serve","last_synced_at":"2025-04-10T05:33:57.930Z","repository":{"id":37639466,"uuid":"222420384","full_name":"dyb881/nest-serve","owner":"dyb881","description":"使用 Nestjs 10.x 开发的基础管理后台服务，极大简约了代码，降低开发成本，支持打包单js文件，无需安装依赖即可部署，并且可基于sea打包成单个可执行文件，无需安装node即可运行。","archived":false,"fork":false,"pushed_at":"2024-12-10T07:45:05.000Z","size":1246,"stargazers_count":119,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-10T08:30:18.890Z","etag":null,"topics":["microservices","nestjs","react","swagger","typeorm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dyb881.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-18T10:17:25.000Z","updated_at":"2024-12-10T07:45:09.000Z","dependencies_parsed_at":"2024-12-10T08:34:45.773Z","dependency_job_id":null,"html_url":"https://github.com/dyb881/nest-serve","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyb881%2Fnest-serve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyb881%2Fnest-serve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyb881%2Fnest-serve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyb881%2Fnest-serve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dyb881","download_url":"https://codeload.github.com/dyb881/nest-serve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248163513,"owners_count":21057956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["microservices","nestjs","react","swagger","typeorm","typescript"],"created_at":"2024-08-01T17:00:43.765Z","updated_at":"2025-04-10T05:33:52.911Z","avatar_url":"https://github.com/dyb881.png","language":"TypeScript","funding_links":[],"categories":["Nestjs"],"sub_categories":[],"readme":"# Nest Serve v3\n\n使用 Nestjs 8.x 以微服务方式开发的基础管理后台服务，并搭配 React 开发的管理后台前端（可自行根据 swagger 的接口开发对应的管理后台前端）\n\n## 旧版本\n\n- [v2 使用 monorepo 模式开发](https://github.com/dyb881/nest-serve/tree/monorepo)\n- [v1 使用 multirepo 模式开发](https://github.com/dyb881/nest-serve/tree/multirepo)\n\n## 使用方法\n\n### 配置\n\n一般情况下可以直接用当前配置，但如果要区分环境的话，就需要在 config 文件夹下添加这两个文件\n\n- development.yaml\n- production.yaml\n\n在运行时会根据环境变量 NODE_ENV=配置文件名 进行选择加载，如\n\n```sh\nNODE_ENV=production yarn start // 加载 production.yaml 覆盖配置\n```\n\n环境变量为空时，默认会尝试加载 development.yaml\n\n### 开发环境\n\n一般情况下需要一个个单独启动服务\n\n```sh\nyarn start:dev account\nyarn start:dev infos\nyarn start:dev admin\n```\n\n### 部署\n\n```sh\nyarn build:all // 打包所有\nyarn pm2 // 用 pm2 运行所有服务\nyarn pm2:pd // 使用 /config/production.yaml + pm2 运行所有服务\n```\n\n## 基础服务\n\n- account 账号管理模块\n  - admin 管理员账号\n  - admin-role 管理员角色\n  - user 用户账号\n- infos 信息管理模块\n  - category 信息分类\n  - article 文章列表\n\n## 网关服务\n\n- admin 管理后台网关\n  - account 账号管理相关接口\n  - infos 信息管理相关接口\n  - auth 鉴权接口\n\n## 自定义库\n\n### public-module 公共模块\n\n主要是将，常用的业务功能抽象成模块\n\n- global 用于初始化的全局模块（除了配置文件外，其他只有配置为 true 时，才会开启）\n  - 配置文件初始化\n  - typeorm 模块初始化\n  - multer 文件模块初始化\n  - 缓存模块初始化\n  - jwt 鉴权模块初始化\n  - 阿里云短信服务模块\n  - files 文件上传模块\n  - 阿里云 oss 对象储存模块\n- logger 日志模块\n\n### public-class 公共类\n\n因为 nestjs 主要是写法都是 class，开发基类可以对开发效率和拓展性都有很大的提升，如\n\n```ts\n/**\n * 公用实体\n * 一条数据必须存在的属性\n */\nexport class CommonEntity {\n  @ApiProperty('ID')\n  @PrimaryGeneratedColumn('uuid')\n  id: string;\n\n  @ApiProperty('创建时间')\n  @CreateDateColumn({ comment: '创建时间', transformer: dateTransformer })\n  create_date: Date;\n\n  @ApiProperty('更新时间')\n  @UpdateDateColumn({ comment: '更新时间', transformer: dateTransformer })\n  update_date: Date;\n}\n\n/**\n * 基础账号实体\n * 一个账号必须存在的属性\n */\nexport class AccountEntity extends CommonEntity {\n  @ApiProperty('用户名')\n  @Column('用户名', 32, { unique: true })\n  username: string;\n\n  // 省略\n}\n```\n\n- controller 常用的控制器类\n- dto 接口参数类型定义，以及对于 swagger 的注解\n- entity 公用的数据库实体类\n- service 公用的服务类，自带 CRUD，继承即可使用（待优化）\n\n### public-decorator 公共装饰器\n\n主要是把一些装饰器，柯里化成一些语义化的函数，如\n\n```ts\n// typeorm api\nColumn('simple-json', { comment: 'json 数据' }) = ColumnJson('json 数据');\n```\n\n- swagger 接口文档标注装饰器\n- transformer 基于 class-transformer 的数据转化装饰器\n- typeorm 基于 typeorm 注册列的装饰器\n- validator 基于 class-validator 的数据验证装饰器\n\n### public-tool 公共工具库\n\n主要封装了全局常用工具\n\n- data 数据处理工具函数\n- bootstrap 服务启动引导程序\n- service 在服务中常用的函数\n- typeorm 针对数据库的数据转化工具\n- http.exception.filter 异常拦截器\n- transform.interceptor 响应参数转化为统一格式\n\n## 配套 UI 效果图（兼容移动端）\n\n在[cra-template-seasoning](https://github.com/dyb881/cra-template-seasoning)中使用 pc-admin 模版\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-1.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-2.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-3.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-4.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-5.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-6.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-7.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-8.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-9.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-10.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-11.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-12.png)\n![效果图](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/github/nest-serve-13.png)\n\n## 如果觉得项目还不错，请打赏一波，您的支持是我最大的动力。\n\n![二维码](https://bittyshowfiles.oss-cn-shenzhen.aliyuncs.com/pay.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyb881%2Fnest-serve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdyb881%2Fnest-serve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyb881%2Fnest-serve/lists"}