|
|
<p align="center">
|
|
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
|
|
</p>
|
|
|
|
|
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
|
|
|
|
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
|
|
<p align="center">
|
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
|
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
|
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
|
|
</p>
|
|
|
<!--[](https://opencollective.com/nest#backer)
|
|
|
[](https://opencollective.com/nest#sponsor)-->
|
|
|
|
|
|
## Description
|
|
|
|
|
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
|
|
|
|
## node version
|
|
|
```js
|
|
|
>=16.15
|
|
|
```
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
```bash
|
|
|
$ yarn install
|
|
|
```
|
|
|
|
|
|
## Running the app
|
|
|
|
|
|
```bash
|
|
|
# development
|
|
|
$ yarn run start
|
|
|
|
|
|
# watch mode
|
|
|
$ yarn run start:dev
|
|
|
|
|
|
# production mode
|
|
|
$ yarn run start:prod
|
|
|
```
|
|
|
## 运行迁移文件
|
|
|
```bash
|
|
|
$ yarn run migration:run
|
|
|
```
|
|
|
## Test
|
|
|
|
|
|
```bash
|
|
|
# unit tests
|
|
|
$ yarn run test
|
|
|
|
|
|
# e2e tests
|
|
|
$ yarn run test:e2e
|
|
|
|
|
|
# test coverage
|
|
|
$ yarn run test:cov
|
|
|
```
|
|
|
|
|
|
## migration 迁移
|
|
|
1. 创建迁移文件
|
|
|
```bash
|
|
|
$ yarn run migration:create ./migrations/fileName # fileName 就是要创建的文件名,成功后会在migrations文件夹下生成${timestamp}-fileName.ts的迁移文件
|
|
|
```
|
|
|
2. 运行迁移文件
|
|
|
```bash
|
|
|
$ yarn run migration:run #该命令会运行所有的迁移文件,运行过的不会运行
|
|
|
```
|
|
|
3. 回退迁移
|
|
|
```bash
|
|
|
$ yarn run migration:revert #该命令会回退最近一个迁移,如果要退回到某个版本必须多次运行
|
|
|
```
|
|
|
|
|
|
## questions
|
|
|
|
|
|
1. 想Joi、dotenv等包应该是升级到最新版本了,es6导入方式请使用
|
|
|
```js
|
|
|
import * as Joi from 'Joi'
|
|
|
```
|
|
|
### 迁移问题
|
|
|
开发环境中可以使用synchronize: true,实时同步数据库中字段,但在生产环境中请禁用该配置,如果在开发环境中使用该配置修改数据库字段类型时可能导致数据丢失,请使migrations
|
|
|
|
|
|
#### migrations
|
|
|
使用migration迁移时可能报
|
|
|
```bash
|
|
|
con not find module '../xxx'
|
|
|
```
|
|
|
解决方案:项目中请使用相对路径导入例如:'import xxx from '../../xxx',当然migration只涉及到entity文件和migrations中的迁移文件,所以请保证这些文件使用相对路径导入的方式
|
|
|
|
|
|
### 目录结构
|
|
|
```bash
|
|
|
api
|
|
|
├─ .drone.yml
|
|
|
├─ .eslintrc.js
|
|
|
├─ .prettierrc
|
|
|
├─ Dockerfile
|
|
|
├─ README.md
|
|
|
├─ development.env # 开发环境配置文件
|
|
|
├─ dump.rdb
|
|
|
├─ migrations # 迁移文件
|
|
|
├─ nest-cli.json
|
|
|
├─ package-lock.json
|
|
|
├─ package.json
|
|
|
├─ patches
|
|
|
│ └─ co-wechat-api+3.11.0.patch
|
|
|
├─ production.env # 生产环境配置文件
|
|
|
├─ src #主程序
|
|
|
│ ├─ ali-apy # 阿里云支付
|
|
|
│ │ ├─ ali-pay-api.ts
|
|
|
│ │ └─ index.ts
|
|
|
│ ├─ app.controller.spec.ts
|
|
|
│ ├─ app.controller.ts
|
|
|
│ ├─ app.module.ts
|
|
|
│ ├─ app.service.ts
|
|
|
│ ├─ auth # 用户鉴权和登录
|
|
|
│ ├─ comment # 测试者测试项目的留言模块
|
|
|
│ ├─ common # 一些公用模块
|
|
|
│ ├─ config # 数据库等配置文件
|
|
|
│ ├─ file # 文件上传模块
|
|
|
│ ├─ industry # 系统配置中行业选项
|
|
|
│ ├─ invoicing # 开发票记录
|
|
|
│ ├─ job # 系统配置 职业经历配置
|
|
|
│ ├─ lib
|
|
|
│ ├─ main.ts
|
|
|
│ ├─ project # 企业端项目模块
|
|
|
│ ├─ project-module # 项目组件
|
|
|
│ ├─ project-module-templage # 系统配置项目模版组件
|
|
|
│ ├─ project-template # 系统配置项目模版,包含测试者模拟测试项目及企业端创建项目时选择的模版
|
|
|
│ ├─ question # 系统配置测试者问题模块
|
|
|
│ ├─ recharge-give-count-history # 企业充值或者赠送点数给企业的记录
|
|
|
│ ├─ recharge-order # 企业充值订单
|
|
|
│ ├─ recruit-tester # 招募测试者
|
|
|
│ ├─ redis # redis
|
|
|
│ ├─ simulate-result # 测试者模拟测试回答组件模块
|
|
|
├─ simulate-result # 测试者模拟测试项目
|
|
|
│ ├─ statics
|
|
|
│ ├─ team # 团队模块
|
|
|
│ ├─ team-member # 团队成员
|
|
|
│ ├─ tester # 测试者接受测试项目
|
|
|
│ ├─ tester-account # 测试者账户模块
|
|
|
│ ├─ tester-anwser # 测试者正是式测试回答组件
|
|
|
│ ├─ tester-project # 推送给测试者的项目列表
|
|
|
│ ├─ user # 系统用户
|
|
|
│ └─ wechat # 微信支付
|
|
|
├─ swagger-spec.json
|
|
|
├─ test # 集成测试
|
|
|
│ ├─ app.e2e-spec.ts
|
|
|
│ └─ jest-e2e.json
|
|
|
├─ test.env
|
|
|
├─ tsconfig.build.json
|
|
|
├─ tsconfig.json
|
|
|
├─ upload # 上传的文件
|
|
|
│ └─ file
|
|
|
└─ yarn.lock
|
|
|
|
|
|
``` |