@lenne.tech/nest-server 11.7.2 → 11.8.0
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/dist/core/common/interfaces/server-options.interface.d.ts +22 -0
- package/dist/core/modules/auth/guards/roles.guard.d.ts +12 -2
- package/dist/core/modules/auth/guards/roles.guard.js +192 -5
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.d.ts +1 -0
- package/dist/core/modules/file/core-file.controller.js +22 -0
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/tus/core-tus.controller.d.ts +9 -0
- package/dist/core/modules/tus/core-tus.controller.js +85 -0
- package/dist/core/modules/tus/core-tus.controller.js.map +1 -0
- package/dist/core/modules/tus/core-tus.service.d.ts +30 -0
- package/dist/core/modules/tus/core-tus.service.js +284 -0
- package/dist/core/modules/tus/core-tus.service.js.map +1 -0
- package/dist/core/modules/tus/index.d.ts +4 -0
- package/dist/core/modules/tus/index.js +21 -0
- package/dist/core/modules/tus/index.js.map +1 -0
- package/dist/core/modules/tus/interfaces/tus-config.interface.d.ts +10 -0
- package/dist/core/modules/tus/interfaces/tus-config.interface.js +59 -0
- package/dist/core/modules/tus/interfaces/tus-config.interface.js.map +1 -0
- package/dist/core/modules/tus/tus.module.d.ts +21 -0
- package/dist/core/modules/tus/tus.module.js +99 -0
- package/dist/core/modules/tus/tus.module.js.map +1 -0
- package/dist/core/modules/user/core-user.service.d.ts +1 -0
- package/dist/core/modules/user/core-user.service.js +12 -0
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/file/file.controller.d.ts +5 -7
- package/dist/server/modules/file/file.controller.js +3 -31
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/server.module.js +3 -1
- package/dist/server/server.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/src/core/common/interfaces/server-options.interface.ts +154 -0
- package/src/core/modules/auth/guards/roles.guard.ts +298 -5
- package/src/core/modules/file/README.md +165 -0
- package/src/core/modules/file/core-file.controller.ts +27 -1
- package/src/core/modules/tus/INTEGRATION-CHECKLIST.md +176 -0
- package/src/core/modules/tus/README.md +439 -0
- package/src/core/modules/tus/core-tus.controller.ts +88 -0
- package/src/core/modules/tus/core-tus.service.ts +424 -0
- package/src/core/modules/tus/index.ts +5 -0
- package/src/core/modules/tus/interfaces/tus-config.interface.ts +107 -0
- package/src/core/modules/tus/tus.module.ts +187 -0
- package/src/core/modules/user/core-user.service.ts +27 -0
- package/src/index.ts +6 -0
- package/src/server/modules/file/file.controller.ts +14 -34
- package/src/server/server.module.ts +5 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CoreFileInfo } from '../../../core/modules/file/core-file-info.model';
|
|
1
|
+
import { CoreFileController } from '../../../core/modules/file/core-file.controller';
|
|
3
2
|
import { FileService } from './file.service';
|
|
4
|
-
export declare class FileController {
|
|
5
|
-
|
|
3
|
+
export declare class FileController extends CoreFileController {
|
|
4
|
+
protected readonly fileService: FileService;
|
|
6
5
|
constructor(fileService: FileService);
|
|
7
6
|
uploadFile(file: Express.Multer.File): Promise<any>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
deleteFile(id: string): Promise<CoreFileInfo>;
|
|
7
|
+
getFileInfo(id: string): Promise<import("../../..").CoreFileInfo>;
|
|
8
|
+
deleteFile(id: string): Promise<import("../../..").CoreFileInfo>;
|
|
11
9
|
}
|
|
@@ -18,9 +18,11 @@ const platform_express_1 = require("@nestjs/platform-express");
|
|
|
18
18
|
const stream_1 = require("stream");
|
|
19
19
|
const roles_decorator_1 = require("../../../core/common/decorators/roles.decorator");
|
|
20
20
|
const role_enum_1 = require("../../../core/common/enums/role.enum");
|
|
21
|
+
const core_file_controller_1 = require("../../../core/modules/file/core-file.controller");
|
|
21
22
|
const file_service_1 = require("./file.service");
|
|
22
|
-
let FileController = class FileController {
|
|
23
|
+
let FileController = class FileController extends core_file_controller_1.CoreFileController {
|
|
23
24
|
constructor(fileService) {
|
|
25
|
+
super(fileService);
|
|
24
26
|
this.fileService = fileService;
|
|
25
27
|
}
|
|
26
28
|
async uploadFile(file) {
|
|
@@ -35,27 +37,6 @@ let FileController = class FileController {
|
|
|
35
37
|
};
|
|
36
38
|
return await this.fileService.createFile(fileUpload);
|
|
37
39
|
}
|
|
38
|
-
async getFile(id, res) {
|
|
39
|
-
if (!id) {
|
|
40
|
-
throw new common_1.BadRequestException('Missing ID');
|
|
41
|
-
}
|
|
42
|
-
let file;
|
|
43
|
-
try {
|
|
44
|
-
file = await this.fileService.getFileInfo(id);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
console.error(e);
|
|
48
|
-
file = null;
|
|
49
|
-
}
|
|
50
|
-
if (!file) {
|
|
51
|
-
throw new common_1.NotFoundException('File not found');
|
|
52
|
-
}
|
|
53
|
-
const filestream = await this.fileService.getFileStream(id);
|
|
54
|
-
res.header('Content-Type', file.contentType || 'application/octet-stream');
|
|
55
|
-
res.header('Content-Disposition', `attachment; filename=${file.filename}`);
|
|
56
|
-
res.header('Cache-Control', 'max-age=31536000');
|
|
57
|
-
return filestream.pipe(res);
|
|
58
|
-
}
|
|
59
40
|
async getFileInfo(id) {
|
|
60
41
|
return await this.fileService.getFileInfo(id);
|
|
61
42
|
}
|
|
@@ -76,15 +57,6 @@ __decorate([
|
|
|
76
57
|
__metadata("design:paramtypes", [Object]),
|
|
77
58
|
__metadata("design:returntype", Promise)
|
|
78
59
|
], FileController.prototype, "uploadFile", null);
|
|
79
|
-
__decorate([
|
|
80
|
-
(0, common_1.Get)(':id'),
|
|
81
|
-
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
82
|
-
__param(0, (0, common_1.Param)('id')),
|
|
83
|
-
__param(1, (0, common_1.Res)()),
|
|
84
|
-
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
86
|
-
__metadata("design:returntype", Promise)
|
|
87
|
-
], FileController.prototype, "getFile", null);
|
|
88
60
|
__decorate([
|
|
89
61
|
(0, common_1.Get)('info/:id'),
|
|
90
62
|
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.ADMIN),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../../../src/server/modules/file/file.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,+DAA2D;AAC3D,mCAAkC;AAElC,qFAAwE;AACxE,oEAAgE;AAChE,0FAAqF;AAErF,iDAA6C;AAgBtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,yCAAkB;IAIpD,YAAwC,WAAwB;QAC9D,KAAK,CAAC,WAAW,CAAC,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAa;IAEhE,CAAC;IAQK,AAAN,KAAK,CAAC,UAAU,CAAiB,IAAyB;QACxD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,4BAAmB,CAAC,kBAAkB,CAAC,CAAC;QACpD,CAAC;QAGD,MAAM,UAAU,GAAe;YAC7B,SAAS,EAAE,IAAI;YACf,gBAAgB,EAAE,GAAG,EAAE,CAAC,iBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAClD,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QAGF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAOK,AAAN,KAAK,CAAC,WAAW,CAAc,EAAU;QACvC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;IAOK,AAAN,KAAK,CAAC,UAAU,CAAc,EAAU;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,4BAAmB,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AApDY,wCAAc;AAcnB;IAHL,IAAA,aAAI,EAAC,QAAQ,CAAC;IACd,IAAA,uBAAK,EAAC,oBAAQ,CAAC,KAAK,CAAC;IACrB,IAAA,wBAAe,EAAC,IAAA,kCAAe,EAAC,MAAM,CAAC,CAAC;IACvB,WAAA,IAAA,qBAAY,GAAE,CAAA;;;;gDAe/B;AAOK;IAFL,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,uBAAK,EAAC,oBAAQ,CAAC,KAAK,CAAC;IACH,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;iDAE7B;AAOK;IAFL,IAAA,eAAM,EAAC,KAAK,CAAC;IACb,IAAA,uBAAK,EAAC,oBAAQ,CAAC,KAAK,CAAC;IACJ,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;gDAM5B;yBAnDU,cAAc;IAF1B,IAAA,mBAAU,EAAC,OAAO,CAAC;IACnB,IAAA,uBAAK,EAAC,oBAAQ,CAAC,KAAK,CAAC;qCAKiC,0BAAW;GAJrD,cAAc,CAoD1B"}
|
|
@@ -15,6 +15,7 @@ const any_scalar_1 = require("../core/common/scalars/any.scalar");
|
|
|
15
15
|
const date_scalar_1 = require("../core/common/scalars/date.scalar");
|
|
16
16
|
const json_scalar_1 = require("../core/common/scalars/json.scalar");
|
|
17
17
|
const core_auth_service_1 = require("../core/modules/auth/services/core-auth.service");
|
|
18
|
+
const tus_1 = require("../core/modules/tus");
|
|
18
19
|
const cron_jobs_service_1 = require("./common/services/cron-jobs.service");
|
|
19
20
|
const auth_controller_1 = require("./modules/auth/auth.controller");
|
|
20
21
|
const auth_module_1 = require("./modules/auth/auth.module");
|
|
@@ -27,7 +28,7 @@ exports.ServerModule = ServerModule;
|
|
|
27
28
|
exports.ServerModule = ServerModule = __decorate([
|
|
28
29
|
(0, common_1.Module)({
|
|
29
30
|
controllers: [server_controller_1.ServerController, auth_controller_1.AuthController],
|
|
30
|
-
exports: [core_module_1.CoreModule, auth_module_1.AuthModule, better_auth_module_1.BetterAuthModule, file_module_1.FileModule],
|
|
31
|
+
exports: [core_module_1.CoreModule, auth_module_1.AuthModule, better_auth_module_1.BetterAuthModule, file_module_1.FileModule, tus_1.TusModule],
|
|
31
32
|
imports: [
|
|
32
33
|
core_module_1.CoreModule.forRoot(core_auth_service_1.CoreAuthService, auth_module_1.AuthModule.forRoot(config_env_1.default.jwt), config_env_1.default),
|
|
33
34
|
schedule_1.ScheduleModule.forRoot(),
|
|
@@ -37,6 +38,7 @@ exports.ServerModule = ServerModule = __decorate([
|
|
|
37
38
|
fallbackSecrets: [config_env_1.default.jwt?.secret, config_env_1.default.jwt?.refresh?.secret],
|
|
38
39
|
}),
|
|
39
40
|
file_module_1.FileModule,
|
|
41
|
+
tus_1.TusModule.forRoot(),
|
|
40
42
|
],
|
|
41
43
|
providers: [any_scalar_1.Any, cron_jobs_service_1.CronJobs, date_scalar_1.DateScalar, json_scalar_1.JSON],
|
|
42
44
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.module.js","sourceRoot":"","sources":["../../src/server/server.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+CAAkD;AAElD,8CAAsC;AACtC,gDAA4C;AAC5C,kEAAwD;AACxD,oEAAgE;AAChE,oEAA0D;AAC1D,uFAAkF;AAClF,2EAA+D;AAC/D,oEAAgE;AAChE,4DAAwD;AACxD,iFAA4E;AAC5E,4DAAwD;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