Skip to content

Commit 256a803

Browse files
authored
refactor:更改目录结构 #2
Refactor/dirctory structure
2 parents 973b29b + c429486 commit 256a803

File tree

105 files changed

+6712
-5017
lines changed

Some content is hidden

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

105 files changed

+6712
-5017
lines changed

.commitlintrc.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{ "extends": ["@commitlint/config-conventional"],
2+
"rules": {
3+
"type-enum": [
4+
2,
5+
"always",
6+
[
7+
"feat",
8+
"fix",
9+
"docs",
10+
"style",
11+
"refactor",
12+
"test",
13+
"build",
14+
"chore",
15+
"perf",
16+
"ci",
17+
"revert"
18+
]
19+
],
20+
"type-case": [2, "always", "lower-case"],
21+
"type-empty": [2, "never"],
22+
"subject-full-stop": [2, "never", "."],
23+
"header-max-length": [2, "always", 100],
24+
"subject-case": [
25+
2,
26+
"never",
27+
["sentence-case", "start-case", "pascal-case", "upper-case"]
28+
]
29+
},
30+
"prompt": {
31+
"useEmoji": true,
32+
"allowCustomIssuePrefix": true,
33+
"allowEmptyIssuePrefix": true,
34+
"confirmColorize": true,
35+
"messages": {
36+
"type": "选择你要提交的类型 :",
37+
"scope": "选择一个提交范围(可选):",
38+
"customScope": "请输入自定义的提交范围 :",
39+
"subject": "填写简短精炼的变更描述 :\n",
40+
"body": "填写更加详细的变更描述(可选)。使用 '|' 换行 :\n",
41+
"breaking": "列举非兼容性重大的变更(可选)。使用 '|' 换行 :\n",
42+
"footerPrefixesSelect": "选择关联issue前缀(可选):",
43+
"customFooterPrefix": "输入自定义issue前缀 :",
44+
"footer": "列举关联issue (可选) 例如: #31, #I3244 :\n",
45+
"confirmCommit": "是否提交或修改commit ?"
46+
},
47+
"types": [
48+
{
49+
"value": "feat",
50+
"emoji": "",
51+
"name": "feat: 新增功能 | A new feature"
52+
},
53+
{ "value": "fix", "name": "fix: 修复缺陷 | A bug fix" },
54+
{
55+
"value": "docs",
56+
"emoji": "📚",
57+
"name": "docs: 文档更新 | Documentation only changes"
58+
},
59+
{
60+
"value": "style",
61+
"emoji": "💎",
62+
"name": "style: 代码格式 | Changes that do not affect the meaning of the code"
63+
},
64+
{
65+
"value": "refactor",
66+
"emoji": "📦",
67+
"name": "refactor: 代码重构 | A code change that neither fixes a bug nor adds a feature"
68+
},
69+
{
70+
"value": "perf",
71+
"emoji": "🚀",
72+
"name": "perf: 性能提升 | A code change that improves performance"
73+
},
74+
{
75+
"value": "test",
76+
"emoji": "🚨",
77+
"name": "test: 测试相关 | Adding missing tests or correcting existing tests"
78+
},
79+
{
80+
"value": "build",
81+
"emoji": "🛠",
82+
"name": "build: 构建相关 | Changes that affect the build system or external dependencies"
83+
},
84+
{
85+
"value": "ci",
86+
"emoji": "⚙️",
87+
"name": "ci: 持续集成 | Changes to our CI configuration files and scripts"
88+
},
89+
{
90+
"value": "revert",
91+
"emoji": "🗑",
92+
"name": "revert: 回退代码 | Revert to a commit"
93+
},
94+
{
95+
"value": "chore",
96+
"emoji": "♻️",
97+
"name": "chore: 其他修改 | Other changes that do not modify src or test files"
98+
}
99+
]
100+
} }

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
dist
22
.eslintrc.cjs
3+
.eslintrc.js
34
shims-vue.d.ts
45
webpack-hmr.config.js
6+
commitlint.config.js
7+
packages/**
8+
api-generate.js
9+
components.d.ts
10+
coverage/**

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This configuration only applies to the package manager root.
2+
/** @type {import("eslint").Linter.Config} */
3+
module.exports = {
4+
ignorePatterns: ["packages/**"],
5+
extends: ["@vtiuse/eslint-config/library.js"],
6+
parser: "@typescript-eslint/parser",
7+
parserOptions: {
8+
project: true,
9+
},
10+
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ lerna-debug.log*
3535
!.vscode/tasks.json
3636
!.vscode/launch.json
3737
!.vscode/extensions.json
38+
39+
.turbo

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20
File renamed without changes.

apps/back/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

apps/back/.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
parser: "@typescript-eslint/parser",
5+
extends: ["@vtiuse/eslint-config/nest.js"],
6+
parserOptions: {
7+
project: true,
8+
},
9+
};
File renamed without changes.
File renamed without changes.

packages/back/package.json renamed to apps/back/package.json

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@vtiuse-full/back",
2+
"name": "service",
33
"version": "0.0.1",
44
"description": "",
55
"author": "CodeGetters",
@@ -16,49 +16,48 @@
1616
"start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch",
1717
"start:debug": "nest start --debug --watch",
1818
"start:prod": "node dist/main",
19-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
19+
"lint": "tsc --noEmit && eslint \"src/**/*.ts\" --ignore-path .eslintignore",
2020
"test": "jest",
2121
"test:watch": "jest --watch",
2222
"test:cov": "jest --coverage",
2323
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
24-
"test:e2e": "jest --config ./test/jest-e2e.json",
25-
"preinstall": "npx only-allow pnpm"
24+
"test:e2e": "jest --config ./test/jest-e2e.json"
2625
},
2726
"dependencies": {
28-
"@nestjs/common": "^10.3.0",
29-
"@nestjs/config": "^3.1.1",
30-
"@nestjs/core": "^10.3.0",
31-
"@nestjs/platform-express": "^10.3.0",
32-
"@nestjs/swagger": "^7.2.0",
27+
"@nestjs/common": "^10.3.3",
28+
"@nestjs/config": "^3.2.0",
29+
"@nestjs/core": "^10.3.3",
30+
"@nestjs/platform-express": "^10.3.3",
31+
"@nestjs/swagger": "^7.3.0",
3332
"class-transformer": "^0.5.1",
3433
"class-validator": "^0.14.1",
3534
"dayjs": "^1.11.10",
3635
"nest-winston": "^1.9.4",
37-
"nestjs-i18n": "^10.4.0",
36+
"nestjs-i18n": "^10.4.5",
3837
"reflect-metadata": "^0.2.1",
3938
"rxjs": "^7.8.1",
40-
"winston": "^3.11.0",
41-
"winston-daily-rotate-file": "^4.7.1"
39+
"winston": "^3.12.0",
40+
"winston-daily-rotate-file": "^5.0.0"
4241
},
4342
"devDependencies": {
44-
"@nestjs/cli": "^10.3.0",
45-
"@nestjs/schematics": "^10.1.0",
46-
"@nestjs/testing": "^10.3.0",
43+
"@nestjs/cli": "^10.3.2",
44+
"@nestjs/schematics": "^10.1.1",
45+
"@nestjs/testing": "^10.3.3",
4746
"@types/express": "^4.17.21",
48-
"@types/jest": "^29.5.11",
49-
"@types/node": "^20.11.5",
47+
"@types/jest": "^29.5.12",
48+
"@types/node": "^20.11.28",
5049
"@types/supertest": "^6.0.2",
5150
"jest": "^29.7.0",
5251
"kolorist": "^1.8.0",
5352
"module-alias": "^2.2.3",
5453
"run-script-webpack-plugin": "^0.2.0",
5554
"source-map-support": "^0.5.21",
5655
"supertest": "^6.3.4",
57-
"ts-jest": "^29.1.1",
56+
"ts-jest": "^29.1.2",
5857
"ts-loader": "^9.5.1",
5958
"ts-node": "^10.9.2",
6059
"tsconfig-paths": "^4.2.0",
61-
"webpack": "^5.89.0",
60+
"webpack": "^5.90.3",
6261
"webpack-cli": "^5.1.4",
6362
"webpack-node-externals": "^3.0.0"
6463
},
@@ -78,5 +77,13 @@
7877
],
7978
"coverageDirectory": "../coverage",
8079
"testEnvironment": "node"
80+
},
81+
"homepage": "https://github.com/CodeGetters/vtiuse-full#readme",
82+
"repository": {
83+
"type": "git",
84+
"url": "git+https://github.com/CodeGetters/vtiuse-full.git"
85+
},
86+
"bugs": {
87+
"url": "https://github.com/CodeGetters/vtiuse-full/issues"
8188
}
8289
}

packages/back/src/common/filters/http-exception.filter.ts renamed to apps/back/src/common/filters/http-exception.filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface IResponse {
2525
@Catch(HttpException)
2626
export default class HttpExceptionFilter implements ExceptionFilter {
2727
constructor(
28+
// eslint-disable-next-line no-unused-vars
2829
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
2930
) {}
3031

@@ -48,8 +49,7 @@ export default class HttpExceptionFilter implements ExceptionFilter {
4849
) {
4950
msg = response.message;
5051
}
51-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
52-
const { query, headers, url, method, body } = req;
52+
// const { query, headers, url, method, body } = req;
5353

5454
this.logger.error(msg, {
5555
status,

packages/back/src/common/interceptor/response.interceptor.ts renamed to apps/back/src/common/interceptor/response.interceptor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line import/order
12
import {
23
CallHandler,
34
ExecutionContext,
@@ -21,13 +22,14 @@ import { getReqMainInfo } from "~/common/utils/logger";
2122
@Injectable()
2223
export default class ResponseInterceptor implements NestInterceptor {
2324
constructor(
25+
// eslint-disable-next-line no-unused-vars
2426
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
2527
) {}
2628

2729
intercept(
2830
context: ExecutionContext,
29-
next: CallHandler<any>,
30-
): Observable<any> | Promise<Observable<any>> {
31+
next: CallHandler<unknown>,
32+
): Observable<unknown> | Promise<Observable<unknown>> {
3133
const ctx = context.switchToHttp();
3234
const req = ctx.getRequest<Request>();
3335

packages/back/src/common/middleware/logger.middler.ts renamed to apps/back/src/common/middleware/logger.middler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-unused-vars */
1+
/* eslint-disable no-console */
22
import { Logger } from "winston";
33
import { bgGreen, green, cyan } from "kolorist";
44
import { WINSTON_MODULE_PROVIDER } from "nest-winston";
@@ -14,11 +14,9 @@ export default class LoggerMiddleware implements NestMiddleware {
1414

1515
use(req: Request, res: Response, next: NextFunction) {
1616
const {
17-
query,
1817
headers: { host },
1918
url,
2019
method,
21-
body,
2220
baseUrl,
2321
} = req;
2422

packages/back/src/common/utils/logger.ts renamed to apps/back/src/common/utils/logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { Request } from "express";
44
* 获取请求头信息
55
* @param req
66
*/
7+
// eslint-disable-next-line no-unused-vars
78
export const getReqMainInfo: (req: Request) => {
8-
[prop: string]: any;
9+
[prop: string]: unknown;
910
} = (req) => {
1011
const { query, headers, url, method, body, connection, baseUrl } = req;
1112

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export default {
2+
// eslint-disable-next-line turbo/no-undeclared-env-vars
23
port: parseInt(process.env.NEST_PORT, 10) || 3000,
34
};

packages/back/src/controllers/app.controller.ts renamed to apps/back/src/controllers/app.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ResponseInterceptor from "~/common/interceptor/response.interceptor";
1111
@Controller("example")
1212
@UseInterceptors(ResponseInterceptor)
1313
export class AppController {
14+
// eslint-disable-next-line no-unused-vars
1415
constructor(private readonly appService: AppService) {}
1516

1617
@Get()
File renamed without changes.
File renamed without changes.

packages/back/src/main.ts renamed to apps/back/src/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-nocheck
3+
14
import "module-alias";
25
import { blue } from "kolorist";
36
import overallConfig from "./config";
@@ -6,7 +9,7 @@ import { AppModule } from "~/modules/app.module";
69
import { ValidationPipe } from "@nestjs/common";
710
import type { OpenAPIObject } from "@nestjs/swagger";
811
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
9-
declare const module: any;
12+
declare const module: unknown;
1013

1114
/**
1215
*
@@ -38,7 +41,9 @@ async function bootstrap() {
3841
}
3942

4043
await app.listen(overallConfig.port);
44+
// eslint-disable-next-line no-console
4145
console.log(blue(`[API Docs]${await app.getUrl()}/docs`));
46+
// eslint-disable-next-line no-console
4247
console.log(blue(`[Test API]${await app.getUrl()}/back/example`));
4348
}
4449
bootstrap();

packages/back/src/services/app.service.ts renamed to apps/back/src/services/app.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
/* eslint-disable no-console */
12
import { blue } from "kolorist";
23
import { Injectable } from "@nestjs/common";
34
import { I18nLang, I18nService } from "nestjs-i18n";
45

56
@Injectable()
67
export class AppService {
8+
// eslint-disable-next-line no-unused-vars
79
constructor(private readonly i18n: I18nService) {}
810

911
getHello(@I18nLang() lang: string) {
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// eslint-disable-next-line no-undef
12
describe("AppController", () => {});

packages/back/test/app.e2e-spec.ts renamed to apps/back/test/app.e2e-spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
import { Test, TestingModule } from "@nestjs/testing";
23
import { INestApplication } from "@nestjs/common";
34
import * as request from "supertest";
File renamed without changes.

apps/back/tsconfig.build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["node_modules", "test", "dist", "**/*spec.ts","src/metadata.ts"]
4+
}

packages/back/tsconfig.json renamed to apps/back/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
"~/*": ["./src/*"]
2424
}
2525
}
26-
}
26+
}
File renamed without changes.

apps/web/.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
extends: ["@vtiuse/eslint-config/web.js"],
5+
parser: "@typescript-eslint/parser",
6+
extends: [".eslintrc-auto-import.json"],
7+
parserOptions: {
8+
project: true,
9+
},
10+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)