@fecommunity/reactpress-server 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +395 -0
- package/bin/reactpress-server.js +302 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +80 -0
- package/dist/app.module.js.map +1 -0
- package/dist/bootstrap.d.ts +10 -0
- package/dist/bootstrap.js +57 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/filters/http-exception.filter.d.ts +4 -0
- package/dist/filters/http-exception.filter.js +36 -0
- package/dist/filters/http-exception.filter.js.map +1 -0
- package/dist/interceptors/transform.interceptor.d.ts +9 -0
- package/dist/interceptors/transform.interceptor.js +36 -0
- package/dist/interceptors/transform.interceptor.js.map +1 -0
- package/dist/logger/index.d.ts +4 -0
- package/dist/logger/index.js +33 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +44 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/article/article.controller.d.ts +27 -0
- package/dist/modules/article/article.controller.js +198 -0
- package/dist/modules/article/article.controller.js.map +1 -0
- package/dist/modules/article/article.entity.d.ts +23 -0
- package/dist/modules/article/article.entity.js +128 -0
- package/dist/modules/article/article.entity.js.map +1 -0
- package/dist/modules/article/article.module.d.ts +2 -0
- package/dist/modules/article/article.module.js +30 -0
- package/dist/modules/article/article.module.js.map +1 -0
- package/dist/modules/article/article.service.d.ts +30 -0
- package/dist/modules/article/article.service.js +303 -0
- package/dist/modules/article/article.service.js.map +1 -0
- package/dist/modules/article/article.util.d.ts +1 -0
- package/dist/modules/article/article.util.js +9 -0
- package/dist/modules/article/article.util.js.map +1 -0
- package/dist/modules/auth/auth.controller.d.ts +12 -0
- package/dist/modules/auth/auth.controller.js +66 -0
- package/dist/modules/auth/auth.controller.js.map +1 -0
- package/dist/modules/auth/auth.module.d.ts +2 -0
- package/dist/modules/auth/auth.module.js +41 -0
- package/dist/modules/auth/auth.module.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +26 -0
- package/dist/modules/auth/auth.service.js +127 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/auth/jwt-auth.guard.d.ts +7 -0
- package/dist/modules/auth/jwt-auth.guard.js +29 -0
- package/dist/modules/auth/jwt-auth.guard.js.map +1 -0
- package/dist/modules/auth/jwt.strategy.d.ts +9 -0
- package/dist/modules/auth/jwt.strategy.js +38 -0
- package/dist/modules/auth/jwt.strategy.js.map +1 -0
- package/dist/modules/auth/roles.guard.d.ts +10 -0
- package/dist/modules/auth/roles.guard.js +46 -0
- package/dist/modules/auth/roles.guard.js.map +1 -0
- package/dist/modules/category/category.controller.d.ts +11 -0
- package/dist/modules/category/category.controller.js +91 -0
- package/dist/modules/category/category.controller.js.map +1 -0
- package/dist/modules/category/category.entity.d.ts +9 -0
- package/dist/modules/category/category.entity.js +60 -0
- package/dist/modules/category/category.entity.js.map +1 -0
- package/dist/modules/category/category.module.d.ts +2 -0
- package/dist/modules/category/category.module.js +27 -0
- package/dist/modules/category/category.module.js.map +1 -0
- package/dist/modules/category/category.service.d.ts +12 -0
- package/dist/modules/category/category.service.js +89 -0
- package/dist/modules/category/category.service.js.map +1 -0
- package/dist/modules/comment/comment.controller.d.ts +12 -0
- package/dist/modules/comment/comment.controller.js +100 -0
- package/dist/modules/comment/comment.controller.js.map +1 -0
- package/dist/modules/comment/comment.entity.d.ts +17 -0
- package/dist/modules/comment/comment.entity.js +104 -0
- package/dist/modules/comment/comment.entity.js.map +1 -0
- package/dist/modules/comment/comment.module.d.ts +2 -0
- package/dist/modules/comment/comment.module.js +30 -0
- package/dist/modules/comment/comment.module.js.map +1 -0
- package/dist/modules/comment/comment.service.d.ts +24 -0
- package/dist/modules/comment/comment.service.js +172 -0
- package/dist/modules/comment/comment.service.js.map +1 -0
- package/dist/modules/comment/html.d.ts +15 -0
- package/dist/modules/comment/html.js +632 -0
- package/dist/modules/comment/html.js.map +1 -0
- package/dist/modules/file/file.controller.d.ts +10 -0
- package/dist/modules/file/file.controller.js +84 -0
- package/dist/modules/file/file.controller.js.map +1 -0
- package/dist/modules/file/file.entity.d.ts +9 -0
- package/dist/modules/file/file.entity.js +60 -0
- package/dist/modules/file/file.entity.js.map +1 -0
- package/dist/modules/file/file.module.d.ts +2 -0
- package/dist/modules/file/file.module.js +27 -0
- package/dist/modules/file/file.module.js.map +1 -0
- package/dist/modules/file/file.service.d.ts +17 -0
- package/dist/modules/file/file.service.js +111 -0
- package/dist/modules/file/file.service.js.map +1 -0
- package/dist/modules/install/install.controller.d.ts +11 -0
- package/dist/modules/install/install.controller.js +49 -0
- package/dist/modules/install/install.controller.js.map +1 -0
- package/dist/modules/install/install.module.d.ts +2 -0
- package/dist/modules/install/install.module.js +26 -0
- package/dist/modules/install/install.module.js.map +1 -0
- package/dist/modules/install/install.service.d.ts +12 -0
- package/dist/modules/install/install.service.js +63 -0
- package/dist/modules/install/install.service.js.map +1 -0
- package/dist/modules/knowledge/knowledge.controller.d.ts +14 -0
- package/dist/modules/knowledge/knowledge.controller.js +128 -0
- package/dist/modules/knowledge/knowledge.controller.js.map +1 -0
- package/dist/modules/knowledge/knowledge.entity.d.ts +18 -0
- package/dist/modules/knowledge/knowledge.entity.js +109 -0
- package/dist/modules/knowledge/knowledge.entity.js.map +1 -0
- package/dist/modules/knowledge/knowledge.module.d.ts +2 -0
- package/dist/modules/knowledge/knowledge.module.js +27 -0
- package/dist/modules/knowledge/knowledge.module.js.map +1 -0
- package/dist/modules/knowledge/knowledge.service.d.ts +14 -0
- package/dist/modules/knowledge/knowledge.service.js +143 -0
- package/dist/modules/knowledge/knowledge.service.js.map +1 -0
- package/dist/modules/page/page.controller.d.ts +12 -0
- package/dist/modules/page/page.controller.js +102 -0
- package/dist/modules/page/page.controller.js.map +1 -0
- package/dist/modules/page/page.entity.d.ts +15 -0
- package/dist/modules/page/page.entity.js +94 -0
- package/dist/modules/page/page.entity.js.map +1 -0
- package/dist/modules/page/page.module.d.ts +2 -0
- package/dist/modules/page/page.module.js +27 -0
- package/dist/modules/page/page.module.js.map +1 -0
- package/dist/modules/page/page.service.d.ts +12 -0
- package/dist/modules/page/page.service.js +97 -0
- package/dist/modules/page/page.service.js.map +1 -0
- package/dist/modules/search/search.controller.d.ts +8 -0
- package/dist/modules/search/search.controller.js +67 -0
- package/dist/modules/search/search.controller.js.map +1 -0
- package/dist/modules/search/search.entity.d.ts +8 -0
- package/dist/modules/search/search.entity.js +59 -0
- package/dist/modules/search/search.entity.js.map +1 -0
- package/dist/modules/search/search.module.d.ts +2 -0
- package/dist/modules/search/search.module.js +27 -0
- package/dist/modules/search/search.module.js.map +1 -0
- package/dist/modules/search/search.service.d.ts +12 -0
- package/dist/modules/search/search.service.js +84 -0
- package/dist/modules/search/search.service.js.map +1 -0
- package/dist/modules/setting/setting.constant.d.ts +4 -0
- package/dist/modules/setting/setting.constant.js +24 -0
- package/dist/modules/setting/setting.constant.js.map +1 -0
- package/dist/modules/setting/setting.controller.d.ts +12 -0
- package/dist/modules/setting/setting.controller.js +77 -0
- package/dist/modules/setting/setting.controller.js.map +1 -0
- package/dist/modules/setting/setting.entity.d.ts +26 -0
- package/dist/modules/setting/setting.entity.js +149 -0
- package/dist/modules/setting/setting.entity.js.map +1 -0
- package/dist/modules/setting/setting.module.d.ts +2 -0
- package/dist/modules/setting/setting.module.js +28 -0
- package/dist/modules/setting/setting.module.js.map +1 -0
- package/dist/modules/setting/setting.service.d.ts +10 -0
- package/dist/modules/setting/setting.service.js +83 -0
- package/dist/modules/setting/setting.service.js.map +1 -0
- package/dist/modules/smtp/mail.util.d.ts +6 -0
- package/dist/modules/smtp/mail.util.js +33 -0
- package/dist/modules/smtp/mail.util.js.map +1 -0
- package/dist/modules/smtp/smtp.controller.d.ts +9 -0
- package/dist/modules/smtp/smtp.controller.js +69 -0
- package/dist/modules/smtp/smtp.controller.js.map +1 -0
- package/dist/modules/smtp/smtp.entity.d.ts +9 -0
- package/dist/modules/smtp/smtp.entity.js +60 -0
- package/dist/modules/smtp/smtp.entity.js.map +1 -0
- package/dist/modules/smtp/smtp.module.d.ts +2 -0
- package/dist/modules/smtp/smtp.module.js +28 -0
- package/dist/modules/smtp/smtp.module.js.map +1 -0
- package/dist/modules/smtp/smtp.service.d.ts +11 -0
- package/dist/modules/smtp/smtp.service.js +82 -0
- package/dist/modules/smtp/smtp.service.js.map +1 -0
- package/dist/modules/tag/tag.controller.d.ts +12 -0
- package/dist/modules/tag/tag.controller.js +101 -0
- package/dist/modules/tag/tag.controller.js.map +1 -0
- package/dist/modules/tag/tag.entity.d.ts +9 -0
- package/dist/modules/tag/tag.entity.js +59 -0
- package/dist/modules/tag/tag.entity.js.map +1 -0
- package/dist/modules/tag/tag.module.d.ts +2 -0
- package/dist/modules/tag/tag.module.js +27 -0
- package/dist/modules/tag/tag.module.js.map +1 -0
- package/dist/modules/tag/tag.service.d.ts +13 -0
- package/dist/modules/tag/tag.service.js +103 -0
- package/dist/modules/tag/tag.service.js.map +1 -0
- package/dist/modules/user/user.controller.d.ts +13 -0
- package/dist/modules/user/user.controller.js +114 -0
- package/dist/modules/user/user.controller.js.map +1 -0
- package/dist/modules/user/user.entity.d.ts +15 -0
- package/dist/modules/user/user.entity.js +96 -0
- package/dist/modules/user/user.entity.js.map +1 -0
- package/dist/modules/user/user.module.d.ts +2 -0
- package/dist/modules/user/user.module.js +28 -0
- package/dist/modules/user/user.module.js.map +1 -0
- package/dist/modules/user/user.service.d.ts +16 -0
- package/dist/modules/user/user.service.js +151 -0
- package/dist/modules/user/user.service.js.map +1 -0
- package/dist/modules/view/view.controller.d.ts +11 -0
- package/dist/modules/view/view.controller.js +92 -0
- package/dist/modules/view/view.controller.js.map +1 -0
- package/dist/modules/view/view.entity.d.ts +14 -0
- package/dist/modules/view/view.entity.js +88 -0
- package/dist/modules/view/view.entity.js.map +1 -0
- package/dist/modules/view/view.module.d.ts +2 -0
- package/dist/modules/view/view.module.js +27 -0
- package/dist/modules/view/view.module.js.map +1 -0
- package/dist/modules/view/view.service.d.ts +11 -0
- package/dist/modules/view/view.service.js +89 -0
- package/dist/modules/view/view.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +15722 -0
- package/dist/utils/date.util.d.ts +1 -0
- package/dist/utils/date.util.js +13 -0
- package/dist/utils/date.util.js.map +1 -0
- package/dist/utils/ip.util.d.ts +2 -0
- package/dist/utils/ip.util.js +27 -0
- package/dist/utils/ip.util.js.map +1 -0
- package/dist/utils/markdown.util.d.ts +4 -0
- package/dist/utils/markdown.util.js +42 -0
- package/dist/utils/markdown.util.js.map +1 -0
- package/dist/utils/oss/aliyun-oss-client.d.ts +6 -0
- package/dist/utils/oss/aliyun-oss-client.js +28 -0
- package/dist/utils/oss/aliyun-oss-client.js.map +1 -0
- package/dist/utils/oss/oss-client.d.ts +6 -0
- package/dist/utils/oss/oss-client.js +10 -0
- package/dist/utils/oss/oss-client.js.map +1 -0
- package/dist/utils/oss.util.d.ts +13 -0
- package/dist/utils/oss.util.js +48 -0
- package/dist/utils/oss.util.js.map +1 -0
- package/dist/utils/ua.util.d.ts +9 -0
- package/dist/utils/ua.util.js +36 -0
- package/dist/utils/ua.util.js.map +1 -0
- package/dist/utils/uniqueid.util.d.ts +1 -0
- package/dist/utils/uniqueid.util.js +9 -0
- package/dist/utils/uniqueid.util.js.map +1 -0
- package/dist/utils/upload.util.d.ts +5 -0
- package/dist/utils/upload.util.js +34 -0
- package/dist/utils/upload.util.js.map +1 -0
- package/dist/utils/user.util.d.ts +1 -0
- package/dist/utils/user.util.js +18 -0
- package/dist/utils/user.util.js.map +1 -0
- package/package.json +140 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FileController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const platform_express_1 = require("@nestjs/platform-express");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
const jwt_auth_guard_1 = require("../auth/jwt-auth.guard");
|
|
20
|
+
const roles_guard_1 = require("../auth/roles.guard");
|
|
21
|
+
const file_entity_1 = require("./file.entity");
|
|
22
|
+
const file_service_1 = require("./file.service");
|
|
23
|
+
let FileController = class FileController {
|
|
24
|
+
constructor(fileService) {
|
|
25
|
+
this.fileService = fileService;
|
|
26
|
+
}
|
|
27
|
+
uploadFile(file, unique) {
|
|
28
|
+
return this.fileService.uploadFile(file, unique);
|
|
29
|
+
}
|
|
30
|
+
findAll(queryParam) {
|
|
31
|
+
return this.fileService.findAll(queryParam);
|
|
32
|
+
}
|
|
33
|
+
findById(id) {
|
|
34
|
+
return this.fileService.findById(id);
|
|
35
|
+
}
|
|
36
|
+
deleteById(id) {
|
|
37
|
+
return this.fileService.deleteById(id);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
swagger_1.ApiResponse({ status: 200, description: '上传文件', type: [file_entity_1.File] }),
|
|
42
|
+
common_1.Post('upload'),
|
|
43
|
+
common_1.UseInterceptors(platform_express_1.FileInterceptor('file', {
|
|
44
|
+
limits: {
|
|
45
|
+
fieldSize: 5 * 1024 * 1024,
|
|
46
|
+
},
|
|
47
|
+
})),
|
|
48
|
+
common_1.UseGuards(jwt_auth_guard_1.JwtAuthGuard),
|
|
49
|
+
__param(0, common_1.UploadedFile()), __param(1, common_1.Query('unique')),
|
|
50
|
+
__metadata("design:type", Function),
|
|
51
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
52
|
+
__metadata("design:returntype", void 0)
|
|
53
|
+
], FileController.prototype, "uploadFile", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
common_1.Get(),
|
|
56
|
+
__param(0, common_1.Query()),
|
|
57
|
+
__metadata("design:type", Function),
|
|
58
|
+
__metadata("design:paramtypes", [Object]),
|
|
59
|
+
__metadata("design:returntype", void 0)
|
|
60
|
+
], FileController.prototype, "findAll", null);
|
|
61
|
+
__decorate([
|
|
62
|
+
common_1.Get(':id'),
|
|
63
|
+
__param(0, common_1.Param('id')),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", [Object]),
|
|
66
|
+
__metadata("design:returntype", void 0)
|
|
67
|
+
], FileController.prototype, "findById", null);
|
|
68
|
+
__decorate([
|
|
69
|
+
common_1.Delete(':id'),
|
|
70
|
+
roles_guard_1.Roles('admin'),
|
|
71
|
+
common_1.UseGuards(jwt_auth_guard_1.JwtAuthGuard),
|
|
72
|
+
__param(0, common_1.Param('id')),
|
|
73
|
+
__metadata("design:type", Function),
|
|
74
|
+
__metadata("design:paramtypes", [Object]),
|
|
75
|
+
__metadata("design:returntype", void 0)
|
|
76
|
+
], FileController.prototype, "deleteById", null);
|
|
77
|
+
FileController = __decorate([
|
|
78
|
+
swagger_1.ApiTags('File'),
|
|
79
|
+
common_1.Controller('file'),
|
|
80
|
+
common_1.UseGuards(roles_guard_1.RolesGuard),
|
|
81
|
+
__metadata("design:paramtypes", [file_service_1.FileService])
|
|
82
|
+
], FileController);
|
|
83
|
+
exports.FileController = FileController;
|
|
84
|
+
//# sourceMappingURL=file.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../../src/modules/file/file.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuH;AACvH,+DAA2D;AAC3D,6CAAuD;AAEvD,2DAAsD;AACtD,qDAAwD;AACxD,+CAAqC;AACrC,iDAA6C;AAK7C,IAAa,cAAc,GAA3B,MAAa,cAAc;IACzB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAgBzD,UAAU,CAAiB,IAAI,EAAmB,MAAM;QACtD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAMD,OAAO,CAAU,UAAU;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAOD,QAAQ,CAAc,EAAE;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IASD,UAAU,CAAc,EAAE;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AA/BC;IAVC,qBAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,kBAAI,CAAC,EAAE,CAAC;IAC/D,aAAI,CAAC,QAAQ,CAAC;IACd,wBAAe,CACd,kCAAe,CAAC,MAAM,EAAE;QACtB,MAAM,EAAE;YACN,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;SAC3B;KACF,CAAC,CACH;IACA,kBAAS,CAAC,6BAAY,CAAC;IACZ,WAAA,qBAAY,EAAE,CAAA,EAAQ,WAAA,cAAK,CAAC,QAAQ,CAAC,CAAA;;;;gDAEhD;AAMD;IADC,YAAG,EAAE;IACG,WAAA,cAAK,EAAE,CAAA;;;;6CAEf;AAOD;IADC,YAAG,CAAC,KAAK,CAAC;IACD,WAAA,cAAK,CAAC,IAAI,CAAC,CAAA;;;;8CAEpB;AASD;IAHC,eAAM,CAAC,KAAK,CAAC;IACb,mBAAK,CAAC,OAAO,CAAC;IACd,kBAAS,CAAC,6BAAY,CAAC;IACZ,WAAA,cAAK,CAAC,IAAI,CAAC,CAAA;;;;gDAEtB;AA/CU,cAAc;IAH1B,iBAAO,CAAC,MAAM,CAAC;IACf,mBAAU,CAAC,MAAM,CAAC;IAClB,kBAAS,CAAC,wBAAU,CAAC;qCAEsB,0BAAW;GAD1C,cAAc,CAgD1B;AAhDY,wCAAc"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.File = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let File = class File {
|
|
16
|
+
};
|
|
17
|
+
__decorate([
|
|
18
|
+
swagger_1.ApiProperty(),
|
|
19
|
+
typeorm_1.PrimaryGeneratedColumn('uuid'),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], File.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
swagger_1.ApiProperty(),
|
|
24
|
+
typeorm_1.Column(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], File.prototype, "originalname", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
swagger_1.ApiProperty(),
|
|
29
|
+
typeorm_1.Column(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], File.prototype, "filename", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
swagger_1.ApiProperty(),
|
|
34
|
+
typeorm_1.Column(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], File.prototype, "type", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
swagger_1.ApiProperty(),
|
|
39
|
+
typeorm_1.Column(),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], File.prototype, "size", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
swagger_1.ApiProperty(),
|
|
44
|
+
typeorm_1.Column(),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], File.prototype, "url", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
swagger_1.ApiProperty(),
|
|
49
|
+
typeorm_1.CreateDateColumn({
|
|
50
|
+
type: 'datetime',
|
|
51
|
+
comment: '创建时间',
|
|
52
|
+
name: 'create_at',
|
|
53
|
+
}),
|
|
54
|
+
__metadata("design:type", Date)
|
|
55
|
+
], File.prototype, "createAt", void 0);
|
|
56
|
+
File = __decorate([
|
|
57
|
+
typeorm_1.Entity()
|
|
58
|
+
], File);
|
|
59
|
+
exports.File = File;
|
|
60
|
+
//# sourceMappingURL=file.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.entity.js","sourceRoot":"","sources":["../../../src/modules/file/file.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qCAAmF;AAGnF,IAAa,IAAI,GAAjB,MAAa,IAAI;CAgChB,CAAA;AA7BC;IAFC,qBAAW,EAAE;IACb,gCAAsB,CAAC,MAAM,CAAC;;gCACpB;AAIX;IAFC,qBAAW,EAAE;IACb,gBAAM,EAAE;;0CACY;AAIrB;IAFC,qBAAW,EAAE;IACb,gBAAM,EAAE;;sCACQ;AAIjB;IAFC,qBAAW,EAAE;IACb,gBAAM,EAAE;;kCACI;AAIb;IAFC,qBAAW,EAAE;IACb,gBAAM,EAAE;;kCACI;AAIb;IAFC,qBAAW,EAAE;IACb,gBAAM,EAAE;;iCACG;AAQZ;IANC,qBAAW,EAAE;IACb,0BAAgB,CAAC;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,WAAW;KAClB,CAAC;8BACQ,IAAI;sCAAC;AA/BJ,IAAI;IADhB,gBAAM,EAAE;GACI,IAAI,CAgChB;AAhCY,oBAAI"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FileModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const auth_module_1 = require("../auth/auth.module");
|
|
13
|
+
const setting_module_1 = require("../setting/setting.module");
|
|
14
|
+
const file_controller_1 = require("./file.controller");
|
|
15
|
+
const file_entity_1 = require("./file.entity");
|
|
16
|
+
const file_service_1 = require("./file.service");
|
|
17
|
+
let FileModule = class FileModule {
|
|
18
|
+
};
|
|
19
|
+
FileModule = __decorate([
|
|
20
|
+
common_1.Module({
|
|
21
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([file_entity_1.File]), auth_module_1.AuthModule, setting_module_1.SettingModule],
|
|
22
|
+
controllers: [file_controller_1.FileController],
|
|
23
|
+
providers: [file_service_1.FileService],
|
|
24
|
+
})
|
|
25
|
+
], FileModule);
|
|
26
|
+
exports.FileModule = FileModule;
|
|
27
|
+
//# sourceMappingURL=file.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/modules/file/file.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAEhD,qDAAiD;AACjD,8DAA0D;AAC1D,uDAAmD;AACnD,+CAAqC;AACrC,iDAA6C;AAO7C,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IALtB,eAAM,CAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,CAAC,CAAC,EAAE,wBAAU,EAAE,8BAAa,CAAC;QACtE,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,CAAC;KACzB,CAAC;GACW,UAAU,CAAG;AAAb,gCAAU"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { SettingService } from '../setting/setting.service';
|
|
4
|
+
import { File } from './file.entity';
|
|
5
|
+
export declare class FileService {
|
|
6
|
+
private readonly fileRepository;
|
|
7
|
+
private readonly settingService;
|
|
8
|
+
private readonly configService;
|
|
9
|
+
private oss;
|
|
10
|
+
private localUpload;
|
|
11
|
+
constructor(fileRepository: Repository<File>, settingService: SettingService, configService: ConfigService);
|
|
12
|
+
uploadFile(file: any, unique: any): Promise<File>;
|
|
13
|
+
findAll(queryParams: any): Promise<[File[], number]>;
|
|
14
|
+
findById(id: any): Promise<File>;
|
|
15
|
+
findByIds(ids: any): Promise<Array<File>>;
|
|
16
|
+
deleteById(id: any): Promise<File>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
21
|
+
t[p[i]] = s[p[i]];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.FileService = void 0;
|
|
27
|
+
const common_1 = require("@nestjs/common");
|
|
28
|
+
const config_1 = require("@nestjs/config");
|
|
29
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
30
|
+
const path = require("path");
|
|
31
|
+
const typeorm_2 = require("typeorm");
|
|
32
|
+
const date_util_1 = require("../../utils/date.util");
|
|
33
|
+
const oss_util_1 = require("../../utils/oss.util");
|
|
34
|
+
const uniqueid_util_1 = require("../../utils/uniqueid.util");
|
|
35
|
+
const upload_util_1 = require("../../utils/upload.util");
|
|
36
|
+
const setting_service_1 = require("../setting/setting.service");
|
|
37
|
+
const file_entity_1 = require("./file.entity");
|
|
38
|
+
let FileService = class FileService {
|
|
39
|
+
constructor(fileRepository, settingService, configService) {
|
|
40
|
+
this.fileRepository = fileRepository;
|
|
41
|
+
this.settingService = settingService;
|
|
42
|
+
this.configService = configService;
|
|
43
|
+
this.oss = new oss_util_1.Oss(this.settingService);
|
|
44
|
+
this.localUpload = new upload_util_1.LocalUpload();
|
|
45
|
+
}
|
|
46
|
+
async uploadFile(file, unique) {
|
|
47
|
+
const { originalname, mimetype, size, buffer } = file;
|
|
48
|
+
const dataFolder = date_util_1.dateFormat(new Date(), 'yyyy-MM-dd');
|
|
49
|
+
const ext = path.extname(originalname);
|
|
50
|
+
const filename = +unique === 1 ? `${dataFolder}/${originalname}` : `${dataFolder}/${uniqueid_util_1.uniqueid()}.${ext}`;
|
|
51
|
+
const hasOssConfig = await this.oss.hasOssConfig();
|
|
52
|
+
let url;
|
|
53
|
+
if (hasOssConfig) {
|
|
54
|
+
url = await this.oss.putFile(filename, buffer);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
url = await this.localUpload.putFile(filename, buffer);
|
|
58
|
+
const uploadUrl = this.configService.get('SERVER_PUBLIC_UPLOAD_URL') || `${this.configService.get('SERVER_SITE_URL')}/public/uploads`;
|
|
59
|
+
url = `${uploadUrl}/${filename}`;
|
|
60
|
+
}
|
|
61
|
+
const newFile = await this.fileRepository.create({
|
|
62
|
+
originalname,
|
|
63
|
+
filename,
|
|
64
|
+
url,
|
|
65
|
+
type: mimetype,
|
|
66
|
+
size,
|
|
67
|
+
});
|
|
68
|
+
await this.fileRepository.save(newFile);
|
|
69
|
+
return newFile;
|
|
70
|
+
}
|
|
71
|
+
async findAll(queryParams) {
|
|
72
|
+
const query = this.fileRepository.createQueryBuilder('file').orderBy('file.createAt', 'DESC');
|
|
73
|
+
if (typeof queryParams === 'object') {
|
|
74
|
+
const { page = 1, pageSize = 12 } = queryParams, otherParams = __rest(queryParams, ["page", "pageSize"]);
|
|
75
|
+
query.skip((+page - 1) * +pageSize);
|
|
76
|
+
query.take(+pageSize);
|
|
77
|
+
if (otherParams) {
|
|
78
|
+
Object.keys(otherParams).forEach((key) => {
|
|
79
|
+
query.andWhere(`file.${key} LIKE :${key}`).setParameter(`${key}`, `%${otherParams[key]}%`);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return query.getManyAndCount();
|
|
84
|
+
}
|
|
85
|
+
async findById(id) {
|
|
86
|
+
return this.fileRepository.findOne(id);
|
|
87
|
+
}
|
|
88
|
+
async findByIds(ids) {
|
|
89
|
+
return this.fileRepository.findByIds(ids);
|
|
90
|
+
}
|
|
91
|
+
async deleteById(id) {
|
|
92
|
+
const target = await this.fileRepository.findOne(id);
|
|
93
|
+
const hasOssConfig = await this.oss.hasOssConfig();
|
|
94
|
+
if (hasOssConfig) {
|
|
95
|
+
await this.oss.deleteFile(target.filename);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
await this.localUpload.deleteFile(target.filename);
|
|
99
|
+
}
|
|
100
|
+
return this.fileRepository.remove(target);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
FileService = __decorate([
|
|
104
|
+
common_1.Injectable(),
|
|
105
|
+
__param(0, typeorm_1.InjectRepository(file_entity_1.File)),
|
|
106
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
107
|
+
setting_service_1.SettingService,
|
|
108
|
+
config_1.ConfigService])
|
|
109
|
+
], FileService);
|
|
110
|
+
exports.FileService = FileService;
|
|
111
|
+
//# sourceMappingURL=file.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.service.js","sourceRoot":"","sources":["../../../src/modules/file/file.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstallService } from './install.service';
|
|
2
|
+
export declare class InstallController {
|
|
3
|
+
private readonly installService;
|
|
4
|
+
constructor(installService: InstallService);
|
|
5
|
+
checkEnvFileExists(): Promise<string>;
|
|
6
|
+
configureDatabase(body: {
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
database: string;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InstallController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const install_service_1 = require("./install.service");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
let InstallController = class InstallController {
|
|
20
|
+
constructor(installService) {
|
|
21
|
+
this.installService = installService;
|
|
22
|
+
}
|
|
23
|
+
async checkEnvFileExists() {
|
|
24
|
+
return this.installService.checkEnvFileExists() ? 'Environment file exists.' : 'Please configure your database.';
|
|
25
|
+
}
|
|
26
|
+
async configureDatabase(body) {
|
|
27
|
+
return this.installService.configureDatabase(body).then(() => 'Database configured successfully.');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
common_1.Post('check'),
|
|
32
|
+
__metadata("design:type", Function),
|
|
33
|
+
__metadata("design:paramtypes", []),
|
|
34
|
+
__metadata("design:returntype", Promise)
|
|
35
|
+
], InstallController.prototype, "checkEnvFileExists", null);
|
|
36
|
+
__decorate([
|
|
37
|
+
common_1.Post('configure'),
|
|
38
|
+
__param(0, common_1.Body()),
|
|
39
|
+
__metadata("design:type", Function),
|
|
40
|
+
__metadata("design:paramtypes", [Object]),
|
|
41
|
+
__metadata("design:returntype", Promise)
|
|
42
|
+
], InstallController.prototype, "configureDatabase", null);
|
|
43
|
+
InstallController = __decorate([
|
|
44
|
+
swagger_1.ApiTags('install'),
|
|
45
|
+
common_1.Controller('install'),
|
|
46
|
+
__metadata("design:paramtypes", [install_service_1.InstallService])
|
|
47
|
+
], InstallController);
|
|
48
|
+
exports.InstallController = InstallController;
|
|
49
|
+
//# sourceMappingURL=install.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.controller.js","sourceRoot":"","sources":["../../../src/modules/install/install.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6E;AAC7E,uDAAmD;AAEnD,6CAAwE;AAIxE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC5B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAG/D,KAAK,CAAC,kBAAkB;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,iCAAiC,CAAC;IACnH,CAAC;IAGD,KAAK,CAAC,iBAAiB,CAAS,IAA8D;QAC5F,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,CAAC,CAAC;IACrG,CAAC;CACF,CAAA;AARC;IADC,aAAI,CAAC,OAAO,CAAC;;;;2DAGb;AAGD;IADC,aAAI,CAAC,WAAW,CAAC;IACO,WAAA,aAAI,EAAE,CAAA;;;;0DAE9B;AAXU,iBAAiB;IAF7B,iBAAO,CAAC,SAAS,CAAC;IAClB,mBAAU,CAAC,SAAS,CAAC;qCAEyB,gCAAc;GADhD,iBAAiB,CAY7B;AAZY,8CAAiB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InstallModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const auth_module_1 = require("../auth/auth.module");
|
|
13
|
+
const setting_module_1 = require("../setting/setting.module");
|
|
14
|
+
const install_controller_1 = require("./install.controller");
|
|
15
|
+
const install_service_1 = require("./install.service");
|
|
16
|
+
let InstallModule = class InstallModule {
|
|
17
|
+
};
|
|
18
|
+
InstallModule = __decorate([
|
|
19
|
+
common_1.Module({
|
|
20
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([File]), auth_module_1.AuthModule, setting_module_1.SettingModule],
|
|
21
|
+
controllers: [install_controller_1.InstallController],
|
|
22
|
+
providers: [install_service_1.InstallService],
|
|
23
|
+
})
|
|
24
|
+
], InstallModule);
|
|
25
|
+
exports.InstallModule = InstallModule;
|
|
26
|
+
//# sourceMappingURL=install.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.module.js","sourceRoot":"","sources":["../../../src/modules/install/install.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAEhD,qDAAiD;AACjD,8DAA0D;AAC1D,6DAAyD;AACzD,uDAAmD;AAOnD,IAAa,aAAa,GAA1B,MAAa,aAAa;CAAG,CAAA;AAAhB,aAAa;IALzB,eAAM,CAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,wBAAU,EAAE,8BAAa,CAAC;QACtE,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,CAAC;KAC5B,CAAC;GACW,aAAa,CAAG;AAAhB,sCAAa"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
export declare class InstallService {
|
|
3
|
+
private envConfigPath;
|
|
4
|
+
private configService;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
checkEnvFileExists(): boolean;
|
|
7
|
+
configureDatabase(config: {
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
database: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InstallService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const typeorm_1 = require("typeorm");
|
|
17
|
+
const config_1 = require("@nestjs/config");
|
|
18
|
+
let InstallService = class InstallService {
|
|
19
|
+
constructor(configService) {
|
|
20
|
+
this.envConfigPath = path.resolve(__dirname, '..', '..', '.env');
|
|
21
|
+
this.configService = configService;
|
|
22
|
+
}
|
|
23
|
+
checkEnvFileExists() {
|
|
24
|
+
return fs.existsSync(this.envConfigPath);
|
|
25
|
+
}
|
|
26
|
+
async configureDatabase(config) {
|
|
27
|
+
const connection = await typeorm_1.createConnection({
|
|
28
|
+
type: 'mysql',
|
|
29
|
+
host: 'localhost',
|
|
30
|
+
port: 3306,
|
|
31
|
+
username: config.username,
|
|
32
|
+
password: config.password,
|
|
33
|
+
database: config.database,
|
|
34
|
+
synchronize: true,
|
|
35
|
+
logging: false,
|
|
36
|
+
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
await connection.connect();
|
|
40
|
+
console.log('Connected to the database');
|
|
41
|
+
const envConfigLines = [
|
|
42
|
+
`DB_HOST=localhost`,
|
|
43
|
+
`DB_PORT=3306`,
|
|
44
|
+
`DB_USERNAME=${config.username}`,
|
|
45
|
+
`DB_PASSWORD=${config.password}`,
|
|
46
|
+
`DB_NAME=${config.database}`,
|
|
47
|
+
];
|
|
48
|
+
fs.writeFileSync(this.envConfigPath, envConfigLines.join('\n'), { encoding: 'utf8' });
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error('Failed to connect to the database: ' + error.message);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
await connection.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
InstallService = __decorate([
|
|
59
|
+
common_1.Injectable(),
|
|
60
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
61
|
+
], InstallService);
|
|
62
|
+
exports.InstallService = InstallService;
|
|
63
|
+
//# sourceMappingURL=install.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.service.js","sourceRoot":"","sources":["../../../src/modules/install/install.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yBAAyB;AACzB,6BAA6B;AAC7B,qCAA2C;AAC3C,2CAA+C;AAG/C,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,YAAY,aAA4B;QAHhC,kBAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAIlE,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,kBAAkB;QAChB,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAgE;QACtF,MAAM,UAAU,GAAG,MAAM,0BAAgB,CAAC;YACxC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,CAAC,SAAS,GAAG,0BAA0B,CAAC;SACnD,CAAC,CAAC;QAEH,IAAI;YACF,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAGzC,MAAM,cAAc,GAAG;gBACrB,mBAAmB;gBACnB,cAAc;gBACd,eAAe,MAAM,CAAC,QAAQ,EAAE;gBAChC,eAAe,MAAM,CAAC,QAAQ,EAAE;gBAChC,WAAW,MAAM,CAAC,QAAQ,EAAE;aAC7B,CAAC;YAEF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;SACvF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;SACxE;gBAAS;YACR,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;SAC1B;IACH,CAAC;CACF,CAAA;AA7CY,cAAc;IAD1B,mBAAU,EAAE;qCAKgB,sBAAa;GAJ7B,cAAc,CA6C1B;AA7CY,wCAAc"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Knowledge } from './knowledge.entity';
|
|
2
|
+
import { KnowledgeService } from './knowledge.service';
|
|
3
|
+
export declare class KnowledgeController {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: KnowledgeService);
|
|
6
|
+
createBook(data: any): Promise<Knowledge>;
|
|
7
|
+
createChapter(data: any): Promise<Knowledge[]>;
|
|
8
|
+
deleteById(id: any): Promise<Knowledge>;
|
|
9
|
+
updateById(id: any, data: any): Promise<Knowledge>;
|
|
10
|
+
findAll(queryParams: any): Promise<[Knowledge[], number]>;
|
|
11
|
+
findById(id: any): Promise<Partial<Knowledge>>;
|
|
12
|
+
updateViewsById(id: any): Promise<Knowledge>;
|
|
13
|
+
updateLikesById(id: any, type: any): Promise<Knowledge>;
|
|
14
|
+
}
|