Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit c30081d

Browse files
authored
Merge pull request #183 from AprilNEA/ENG-56
2 parents 41eecd8 + 7c9daa6 commit c30081d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1599
-265
lines changed

.github/workflows/frontend-bundle-analysis.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ defaults:
1212

1313
jobs:
1414
analyze:
15+
name: Frontend Analyze Bundle
1516
runs-on: ubuntu-latest
17+
env:
18+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
19+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
20+
1621
steps:
1722
- name: Cancel Previous Runs
1823
uses: styfle/[email protected]
@@ -21,6 +26,14 @@ jobs:
2126

2227
- uses: actions/checkout@v4
2328

29+
- name: Cache turbo build setup
30+
uses: actions/cache@v3
31+
with:
32+
path: .turbo
33+
key: ${{ runner.os }}-turbo-${{ github.sha }}
34+
restore-keys: |
35+
${{ runner.os }}-turbo-
36+
2437
- uses: pnpm/[email protected]
2538

2639
- name: Install Node.js
@@ -30,7 +43,7 @@ jobs:
3043
cache: 'pnpm'
3144

3245
- name: Install Dependencies
33-
run: pnpm i
46+
run: pnpm install
3447

3548
- name: Restore Next.js Build
3649
uses: actions/cache@v3
@@ -46,7 +59,7 @@ jobs:
4659

4760
- name: Build Next.js App
4861
# change this if your site requires a custom build command
49-
run: cd packages/frontend && ./node_modules/.bin/next build
62+
run: pnpm run build:frontend
5063

5164
# Here's the first place where next-bundle-analysis' own script is used
5265
# This step pulls the raw bundle stats for the current bundle

.github/workflows/test-suite.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches: ["v3","v3-dev"]
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
name: Build and Test
12+
timeout-minutes: 15
13+
runs-on: ubuntu-latest
14+
# To use Remote Caching, uncomment the next lines and follow the steps below.
15+
env:
16+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
17+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
18+
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Cache turbo build setup
26+
uses: actions/cache@v3
27+
with:
28+
path: .turbo
29+
key: ${{ runner.os }}-turbo-${{ github.sha }}
30+
restore-keys: |
31+
${{ runner.os }}-turbo-
32+
33+
- uses: pnpm/[email protected]
34+
with:
35+
version: 6.32.2
36+
37+
- name: Setup Node.js environment
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 18
41+
cache: 'pnpm'
42+
43+
- name: Install dependencies
44+
run: pnpm install
45+
46+
- name: Build
47+
run: pnpm build
48+
49+
- name: Test
50+
run: pnpm test

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ English</a></h4>
1515
<a href="https://github.com/AprilNEA/ChatGPT-Admin-Web/issues?q=is%3Aissue+is%3Aclosed" target="_blank">
1616
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/AprilNEA/ChatGPT-Admin-Web.svg?style=flat-square"></a>
1717
<br/>
18-
<img src="https://hits-app.vercel.app/hits?url=https%3A%2F%2Fgithub.com%2FAprilNEA%2FChatGPT-Admin-Web" />
18+
<img src="https://hits.siyue.best/v1/hits?url=https://github.com/AprilNEA/ChatGPT-Admin-Web&bgRight=000&bgLeft=000&border=square" />
1919

2020
</div>
2121
<div align="left">CAW 是一个自托管网络应用程序,提供开箱即用的用户管理,包括后台界面以及可配置的支付计划和相关支付界面。</div>
@@ -35,7 +35,7 @@ English</a></h4>
3535

3636
| | |
3737
|---------------------------------------------------------------------------|---------------------------------------------------------------------------|
38-
| <img src=https://s2.loli.net/2023/11/10/53Q4ZodyIhvmaHt.png width="500"/> | |
38+
| <img src=https://s2.loli.net/2023/11/10/53Q4ZodyIhvmaHt.png width="500"/> | |
3939
| <img src=https://s2.loli.net/2023/11/10/KoieRB9jnTxgCuz.png width="500"/> | <img src=https://s2.loli.net/2023/11/10/kI8z2auXcnFGwTe.png width="500"/> |
4040

4141
## 开始
@@ -50,6 +50,18 @@ English</a></h4>
5050
| [V2](https://github.com/AprilNEA/ChatGPT-Admin-Web/tree/v2) | 弃用 | 存在设计缺陷 |
5151
| [V1](https://github.com/AprilNEA/ChatGPT-Admin-Web/tree/main) | 不再更新 | Redis数据库,可拓展性较差 |
5252

53+
[更新日志](https://manual.sku.moe/project/chatgpt-admin-web/update-log)
54+
55+
## 技术栈
56+
57+
| Part | Tech |
58+
|:---------|:-------------------|
59+
| Frontend | Next.js |
60+
| Backend | Nest.js |
61+
| Database | PostgreSQL & Redis |
62+
63+
更多技术细节:[开发手册](https://manual.sku.moe/project/chatgpt-admin-web/development)
64+
5365
## 项目动态
5466

5567
![Alt](https://repobeats.axiom.co/api/embed/67fc3464887e0956a6225b4c5c6579c2699d8363.svg "Repobeats analytics image")
@@ -62,7 +74,6 @@ English</a></h4>
6274
<img src="https://contrib.rocks/image?repo=AprilNEA/ChatGPT-Admin-Web" />
6375
</a>
6476

65-
6677
## 捐赠
6778

6879
感谢您的激励,能让该项目持续发展。

README_EN.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<a href="https://github.com/AprilNEA/ChatGPT-Admin-Web/issues?q=is%3Aissue+is%3Aclosed" target="_blank">
1616
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/AprilNEA/ChatGPT-Admin-Web.svg?style=flat-square"></a>
1717
<br/>
18-
<img src="https://hits-app.vercel.app/hits?url=https%3A%2F%2Fgithub.com%2FAprilNEA%2FChatGPT-Admin-Web" />
18+
<img src="https://hits.siyue.best/v1/hits?url=https://github.com/AprilNEA/ChatGPT-Admin-Web&bgRight=000&bgLeft=000&border=square" />
1919

2020
</div>
2121
<div align="left">CAW(ChatGPT-Admin-Web) is a self-hosted web application that provides out-of-the-box user management including a back-end interface as well as configurable payment plans and related payment interfaces.</div>
@@ -51,6 +51,19 @@ For configuration and installation, see [documentation](https://manual.sku.moe/p
5151
| [V2](https://github.com/AprilNEA/ChatGPT-Admin-Web/tree/v2) | :x: Deprecated | Flawed design |
5252
| [V1](https://github.com/AprilNEA/ChatGPT-Admin-Web/tree/main) | :o: No longer updated | Redis database, less scalable |
5353

54+
[Update Log](https://manual.sku.moe/project/chatgpt-admin-web/update-log)
55+
56+
57+
## 技术栈
58+
59+
| Part | Tech |
60+
|:---------|:-------------------|
61+
| Frontend | Next.js |
62+
| Backend | Nest.js |
63+
| Database | PostgreSQL & Redis |
64+
65+
You can go to [Developer Manual](https://manual.sku.moe/project/chatgpt-admin-web/development) for more technical details.
66+
5467
## Project Status
5568

5669
![Alt](https://repobeats.axiom.co/api/embed/67fc3464887e0956a6225b4c5c6579c2699d8363.svg "Repobeats analytics image")

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
],
1616
"scripts": {
1717
"build": "turbo run build",
18+
"build:frontend": "turbo run build --filter frontend",
1819
"dev": "turbo run dev --parallel",
1920
"start": "turbo run start",
2021
"lint": "turbo run lint",
22+
"test": "vitest run",
2123
"prettier": "prettier --write .",
2224
"db:init": "prisma db push && prisma db seed",
2325
"db:generate": "prisma generate"
@@ -26,10 +28,14 @@
2628
"@trivago/prettier-plugin-sort-imports": "latest",
2729
"@types/node": "latest",
2830
"prettier": "latest",
31+
"prisma": "5.6.0",
2932
"ts-node": "latest",
3033
"turbo": "latest",
3134
"typescript": "latest",
32-
"prisma": "5.6.0"
35+
"vite": "^5.0.7",
36+
"vite-tsconfig-paths": "^4.2.2",
37+
"vitest": "^1.0.2",
38+
"zod": "latest"
3339
},
3440
"prisma": {
3541
"schema": "prisma/schema.prisma",

packages/backend/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
"dev": "nest start --watch",
1111
"start:debug": "nest start --debug --watch",
1212
"start:prod": "node dist/main",
13-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
14-
"test": "jest",
15-
"test:watch": "jest --watch",
16-
"test:cov": "jest --coverage",
17-
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
18-
"test:e2e": "jest --config test/jest-e2e.json"
13+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
1914
},
2015
"dependencies": {
2116
"@liaoliaots/nestjs-redis": "^9.0.5",
@@ -38,7 +33,8 @@
3833
"prisma-extension-pagination": "^0.5.0",
3934
"reflect-metadata": "^0.1.13",
4035
"rxjs": "^7.8.1",
41-
"spark-md5": "^3.0.2"
36+
"spark-md5": "^3.0.2",
37+
"zod": "*"
4238
},
4339
"devDependencies": {
4440
"@nestjs/cli": "^10.2.1",

packages/backend/src/common/config/config.service.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,26 @@ export class ConfigService {
101101
fs.writeFileSync(this.configFilePath, jsonData, 'utf8');
102102
this.loadConfig();
103103
}
104+
105+
checkEmailEnable() {
106+
return (
107+
this.get('email') &&
108+
this.get('email').use &&
109+
this.get('email').use !== 'disable'
110+
);
111+
}
112+
113+
checkSMSEnable() {
114+
return (
115+
this.get('sms') &&
116+
this.get('sms').use &&
117+
this.get('sms').use !== 'disable'
118+
);
119+
}
120+
121+
checkNotifierEnable(all = false) {
122+
return all
123+
? this.checkEmailEnable() && this.checkSMSEnable()
124+
: this.checkEmailEnable() || this.checkSMSEnable();
125+
}
104126
}

packages/backend/src/common/exceptions/biz.exception.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ export const ErrorCode = Object.freeze<
9292
});
9393

9494
export class BizException extends HttpException {
95+
code: ErrorCodeEnum;
96+
9597
constructor(code: ErrorCodeEnum) {
9698
const [message, chMessage, statusCode] = ErrorCode[code];
9799
super(
98100
HttpException.createBody({ success: false, code, message, chMessage }),
99101
statusCode,
100102
);
103+
104+
this.code = code;
101105
}
102106
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ZodObject } from 'zod';
2+
3+
import { ArgumentMetadata, PipeTransform } from '@nestjs/common';
4+
5+
import { BizException } from '@/common/exceptions/biz.exception';
6+
7+
import { ErrorCodeEnum } from 'shared';
8+
9+
export class ZodValidationPipe implements PipeTransform {
10+
constructor(private schema: ZodObject<any>) {}
11+
12+
transform(value: unknown, metadata: ArgumentMetadata) {
13+
try {
14+
return this.schema.parse(value);
15+
} catch (error) {
16+
throw new BizException(ErrorCodeEnum.ValidationError);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)