@comasoft/nestjs 0.0.2

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.
Files changed (67) hide show
  1. package/dist/decorators/api-custom-params.decorator.d.ts +7 -0
  2. package/dist/decorators/api-custom-params.decorator.js +35 -0
  3. package/dist/decorators/auth.decorator.factory.d.ts +1 -0
  4. package/dist/decorators/auth.decorator.factory.js +12 -0
  5. package/dist/decorators/cookies.decorator.d.ts +1 -0
  6. package/dist/decorators/cookies.decorator.js +9 -0
  7. package/dist/decorators/custom-params.decorator.d.ts +1 -0
  8. package/dist/decorators/custom-params.decorator.js +16 -0
  9. package/dist/decorators/index.d.ts +6 -0
  10. package/dist/decorators/index.js +22 -0
  11. package/dist/decorators/patch-body.decorator.d.ts +1 -0
  12. package/dist/decorators/patch-body.decorator.js +30 -0
  13. package/dist/decorators/user.decorator.d.ts +1 -0
  14. package/dist/decorators/user.decorator.js +8 -0
  15. package/dist/dto/auth-user-local.dto.d.ts +4 -0
  16. package/dist/dto/auth-user-local.dto.js +26 -0
  17. package/dist/dto/custom-params.dto.d.ts +7 -0
  18. package/dist/dto/custom-params.dto.js +46 -0
  19. package/dist/dto/index.d.ts +6 -0
  20. package/dist/dto/index.js +22 -0
  21. package/dist/dto/jwt-user.dto.d.ts +6 -0
  22. package/dist/dto/jwt-user.dto.js +6 -0
  23. package/dist/dto/pagination.dto.d.ts +8 -0
  24. package/dist/dto/pagination.dto.js +36 -0
  25. package/dist/dto/response-access-token.dto.d.ts +3 -0
  26. package/dist/dto/response-access-token.dto.js +24 -0
  27. package/dist/dto/response-id.dto.d.ts +6 -0
  28. package/dist/dto/response-id.dto.js +27 -0
  29. package/dist/enums.common.d.ts +29 -0
  30. package/dist/enums.common.js +35 -0
  31. package/dist/filters/http-exception.filter.d.ts +4 -0
  32. package/dist/filters/http-exception.filter.js +53 -0
  33. package/dist/filters/index.d.ts +1 -0
  34. package/dist/filters/index.js +17 -0
  35. package/dist/guards/auth.guard.d.ts +8 -0
  36. package/dist/guards/auth.guard.js +38 -0
  37. package/dist/guards/jwt.guard.d.ts +4 -0
  38. package/dist/guards/jwt.guard.js +17 -0
  39. package/dist/index.d.ts +8 -0
  40. package/dist/index.js +24 -0
  41. package/dist/interceptors/error.interceptor.d.ts +5 -0
  42. package/dist/interceptors/error.interceptor.js +26 -0
  43. package/dist/interceptors/index.d.ts +2 -0
  44. package/dist/interceptors/index.js +18 -0
  45. package/dist/interceptors/success.interceptor.d.ts +5 -0
  46. package/dist/interceptors/success.interceptor.js +30 -0
  47. package/dist/passport/jwt.strategy.d.ts +6 -0
  48. package/dist/passport/jwt.strategy.js +55 -0
  49. package/dist/passport/kakao.strategy.d.ts +12 -0
  50. package/dist/passport/kakao.strategy.js +36 -0
  51. package/dist/passport/local.strategy.d.ts +6 -0
  52. package/dist/passport/local.strategy.js +41 -0
  53. package/dist/setup-swagger.d.ts +9 -0
  54. package/dist/setup-swagger.js +32 -0
  55. package/dist/utils/common.utils.d.ts +2 -0
  56. package/dist/utils/common.utils.js +28 -0
  57. package/dist/utils/enum.utils.d.ts +1 -0
  58. package/dist/utils/enum.utils.js +8 -0
  59. package/dist/utils/index.d.ts +4 -0
  60. package/dist/utils/index.js +20 -0
  61. package/dist/utils/pagination-qb.utils.d.ts +8 -0
  62. package/dist/utils/pagination-qb.utils.js +52 -0
  63. package/dist/utils/pagination.utils.d.ts +21 -0
  64. package/dist/utils/pagination.utils.js +32 -0
  65. package/eslint.config.js +31 -0
  66. package/package.json +45 -0
  67. package/tsconfig.build.json +19 -0
@@ -0,0 +1,7 @@
1
+ import { ApiQueryOptions } from '@nestjs/swagger';
2
+ type AvailableParams = '_page' | '_limit' | '_keyword' | '_sort' | '_group';
3
+ type CustomParamOptions = Partial<Record<AvailableParams, ApiQueryOptions>> & {
4
+ custom?: ApiQueryOptions[];
5
+ };
6
+ export declare const ApiCustomParams: (options?: CustomParamOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
7
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiCustomParams = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const defaultParamOptions = {
7
+ _page: { name: '_page', required: false, type: Number, example: 1 },
8
+ _limit: { name: '_limit', required: false, type: Number, example: 5 },
9
+ _keyword: { name: '_keyword', required: false, type: String },
10
+ _sort: {
11
+ name: '_sort',
12
+ required: false,
13
+ type: String,
14
+ description: 'Sorting (field1-asc|field2-desc)',
15
+ },
16
+ _group: {
17
+ name: '_group',
18
+ required: false,
19
+ type: String,
20
+ description: 'Group (field1-value1|field2-value2)',
21
+ },
22
+ };
23
+ const ApiCustomParams = (options = {}) => {
24
+ const decos = [];
25
+ for (const key of Object.keys(defaultParamOptions)) {
26
+ if (key in options || key === '_page' || key === '_limit') {
27
+ decos.push(Object.assign(Object.assign({}, defaultParamOptions[key]), options[key]));
28
+ }
29
+ }
30
+ if (options.custom) {
31
+ decos.push(...options.custom);
32
+ }
33
+ return (0, common_1.applyDecorators)(...decos.map((deco) => (0, swagger_1.ApiQuery)(deco)));
34
+ };
35
+ exports.ApiCustomParams = ApiCustomParams;
@@ -0,0 +1 @@
1
+ export declare function createAuthDecorator<T extends Record<string, any>>(roleEnum: T): (...roles: Lowercase<keyof T & string>[]) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthDecorator = createAuthDecorator;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const auth_guard_1 = require("../guards/auth.guard");
7
+ const jwt_guard_1 = require("../guards/jwt.guard");
8
+ function createAuthDecorator(roleEnum) {
9
+ return function (...roles) {
10
+ return (0, common_1.applyDecorators)((0, common_1.SetMetadata)("roles", roles), (0, common_1.SetMetadata)("roleEnum", roleEnum), (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard, auth_guard_1.AuthGuard), (0, swagger_1.ApiBearerAuth)("access_token"), (0, swagger_1.ApiUnauthorizedResponse)({ description: "Unauthorized" }));
11
+ };
12
+ }
@@ -0,0 +1 @@
1
+ export declare const Cookies: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cookies = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.Cookies = (0, common_1.createParamDecorator)((data, ctx) => {
6
+ var _a;
7
+ const request = ctx.switchToHttp().getRequest();
8
+ return data ? (_a = request.cookies) === null || _a === void 0 ? void 0 : _a[data] : request.cookies;
9
+ });
@@ -0,0 +1 @@
1
+ export declare const CustomParams: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomParams = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.CustomParams = (0, common_1.createParamDecorator)((_data, ctx) => {
6
+ const request = ctx.switchToHttp().getRequest();
7
+ const query = request.query;
8
+ const customParams = {
9
+ _page: query._page ? parseInt(query._page, 10) : 1,
10
+ _limit: query._limit ? parseInt(query._limit, 10) : 5,
11
+ _keyword: query._keyword || undefined,
12
+ _group: query._group || undefined,
13
+ _sort: query._sort || undefined,
14
+ };
15
+ return customParams;
16
+ });
@@ -0,0 +1,6 @@
1
+ export * from './custom-params.decorator';
2
+ export * from './api-custom-params.decorator';
3
+ export * from './patch-body.decorator';
4
+ export * from './user.decorator';
5
+ export * from './auth.decorator.factory';
6
+ export * from './cookies.decorator';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./custom-params.decorator"), exports);
18
+ __exportStar(require("./api-custom-params.decorator"), exports);
19
+ __exportStar(require("./patch-body.decorator"), exports);
20
+ __exportStar(require("./user.decorator"), exports);
21
+ __exportStar(require("./auth.decorator.factory"), exports);
22
+ __exportStar(require("./cookies.decorator"), exports);
@@ -0,0 +1 @@
1
+ export declare function PatchBody<T>(dtoClass: new () => T): ParameterDecorator;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PatchBody = PatchBody;
4
+ const common_1 = require("@nestjs/common");
5
+ const class_transformer_1 = require("class-transformer");
6
+ function PatchBody(dtoClass) {
7
+ return (target, key, index) => {
8
+ (0, common_1.Body)()(target, key, index);
9
+ const originalMethod = (0, common_1.createParamDecorator)((data, ctx) => {
10
+ const request = ctx.switchToHttp().getRequest();
11
+ const body = request.body;
12
+ const dtoInstance = (0, class_transformer_1.plainToClass)(dtoClass, body, {
13
+ strategy: 'excludeAll',
14
+ excludeExtraneousValues: true,
15
+ });
16
+ const correctKeys = Object.fromEntries(Object.entries(dtoInstance).filter(([_, v]) => v !== undefined));
17
+ if (Object.keys(correctKeys).length !== Object.keys(body).length) {
18
+ const invalidKeys = Object.keys(body).filter((key) => !Object.keys(correctKeys).includes(key));
19
+ if (invalidKeys.length > 0) {
20
+ throw new common_1.BadRequestException(`Invalid keys: ${invalidKeys.join(', ')}`);
21
+ }
22
+ }
23
+ if (Object.keys(correctKeys).length === 0) {
24
+ throw new common_1.BadRequestException('At least one field is required');
25
+ }
26
+ return correctKeys;
27
+ });
28
+ originalMethod()(target, key, index);
29
+ };
30
+ }
@@ -0,0 +1 @@
1
+ export declare const User: (...dataOrPipes: any[]) => ParameterDecorator;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.User = (0, common_1.createParamDecorator)((data, ctx) => {
6
+ const request = ctx.switchToHttp().getRequest();
7
+ return request.user;
8
+ });
@@ -0,0 +1,4 @@
1
+ export declare class AuthUserLocalDto {
2
+ userid: string;
3
+ password: string;
4
+ }
@@ -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
+ 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.AuthUserLocalDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class AuthUserLocalDto {
15
+ }
16
+ exports.AuthUserLocalDto = AuthUserLocalDto;
17
+ __decorate([
18
+ (0, class_validator_1.IsString)(),
19
+ (0, class_validator_1.IsNotEmpty)(),
20
+ __metadata("design:type", String)
21
+ ], AuthUserLocalDto.prototype, "userid", void 0);
22
+ __decorate([
23
+ (0, class_validator_1.IsString)(),
24
+ (0, class_validator_1.IsNotEmpty)(),
25
+ __metadata("design:type", String)
26
+ ], AuthUserLocalDto.prototype, "password", void 0);
@@ -0,0 +1,7 @@
1
+ export declare class CustomParamsDto {
2
+ _page: number;
3
+ _limit: number;
4
+ _keyword?: string;
5
+ _group?: string;
6
+ _sort?: string;
7
+ }
@@ -0,0 +1,46 @@
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.CustomParamsDto = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ class CustomParamsDto {
16
+ constructor() {
17
+ this._page = 1;
18
+ this._limit = 5;
19
+ }
20
+ }
21
+ exports.CustomParamsDto = CustomParamsDto;
22
+ __decorate([
23
+ (0, class_transformer_1.Type)(() => Number),
24
+ (0, class_validator_1.IsOptional)(),
25
+ __metadata("design:type", Number)
26
+ ], CustomParamsDto.prototype, "_page", void 0);
27
+ __decorate([
28
+ (0, class_transformer_1.Type)(() => Number),
29
+ (0, class_validator_1.IsOptional)(),
30
+ __metadata("design:type", Number)
31
+ ], CustomParamsDto.prototype, "_limit", void 0);
32
+ __decorate([
33
+ (0, class_transformer_1.Type)(() => String),
34
+ (0, class_validator_1.IsOptional)(),
35
+ __metadata("design:type", String)
36
+ ], CustomParamsDto.prototype, "_keyword", void 0);
37
+ __decorate([
38
+ (0, class_transformer_1.Type)(() => String),
39
+ (0, class_validator_1.IsOptional)(),
40
+ __metadata("design:type", String)
41
+ ], CustomParamsDto.prototype, "_group", void 0);
42
+ __decorate([
43
+ (0, class_transformer_1.Type)(() => String),
44
+ (0, class_validator_1.IsOptional)(),
45
+ __metadata("design:type", String)
46
+ ], CustomParamsDto.prototype, "_sort", void 0);
@@ -0,0 +1,6 @@
1
+ export * from "./auth-user-local.dto";
2
+ export * from "./pagination.dto";
3
+ export * from "./response-id.dto";
4
+ export * from "./response-access-token.dto";
5
+ export * from "./custom-params.dto";
6
+ export * from "./jwt-user.dto";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./auth-user-local.dto"), exports);
18
+ __exportStar(require("./pagination.dto"), exports);
19
+ __exportStar(require("./response-id.dto"), exports);
20
+ __exportStar(require("./response-access-token.dto"), exports);
21
+ __exportStar(require("./custom-params.dto"), exports);
22
+ __exportStar(require("./jwt-user.dto"), exports);
@@ -0,0 +1,6 @@
1
+ export declare class JwtUserDto {
2
+ id: number;
3
+ userid: string;
4
+ role: string;
5
+ name: string;
6
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JwtUserDto = void 0;
4
+ class JwtUserDto {
5
+ }
6
+ exports.JwtUserDto = JwtUserDto;
@@ -0,0 +1,8 @@
1
+ import { CustomPaginationMeta } from '../utils/pagination.utils';
2
+ export declare class PaginationDto implements CustomPaginationMeta {
3
+ page: number;
4
+ limit: number;
5
+ count: number;
6
+ count_total: number;
7
+ count_page: number;
8
+ }
@@ -0,0 +1,36 @@
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.PaginationDto = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ class PaginationDto {
15
+ }
16
+ exports.PaginationDto = PaginationDto;
17
+ __decorate([
18
+ (0, class_transformer_1.Expose)(),
19
+ __metadata("design:type", Number)
20
+ ], PaginationDto.prototype, "page", void 0);
21
+ __decorate([
22
+ (0, class_transformer_1.Expose)(),
23
+ __metadata("design:type", Number)
24
+ ], PaginationDto.prototype, "limit", void 0);
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ __metadata("design:type", Number)
28
+ ], PaginationDto.prototype, "count", void 0);
29
+ __decorate([
30
+ (0, class_transformer_1.Expose)(),
31
+ __metadata("design:type", Number)
32
+ ], PaginationDto.prototype, "count_total", void 0);
33
+ __decorate([
34
+ (0, class_transformer_1.Expose)(),
35
+ __metadata("design:type", Number)
36
+ ], PaginationDto.prototype, "count_page", void 0);
@@ -0,0 +1,3 @@
1
+ export declare class ResponseAccessTokenDto {
2
+ access_token: string;
3
+ }
@@ -0,0 +1,24 @@
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.ResponseAccessTokenDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
15
+ class ResponseAccessTokenDto {
16
+ }
17
+ exports.ResponseAccessTokenDto = ResponseAccessTokenDto;
18
+ __decorate([
19
+ (0, class_transformer_1.Expose)(),
20
+ (0, swagger_1.ApiProperty)({
21
+ example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
22
+ }),
23
+ __metadata("design:type", String)
24
+ ], ResponseAccessTokenDto.prototype, "access_token", void 0);
@@ -0,0 +1,6 @@
1
+ export declare class ResponseIdDto {
2
+ id: number;
3
+ }
4
+ export declare class ResponseIdsDto {
5
+ ids: number[];
6
+ }
@@ -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
+ 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.ResponseIdsDto = exports.ResponseIdDto = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ class ResponseIdDto {
15
+ }
16
+ exports.ResponseIdDto = ResponseIdDto;
17
+ __decorate([
18
+ (0, class_transformer_1.Expose)(),
19
+ __metadata("design:type", Number)
20
+ ], ResponseIdDto.prototype, "id", void 0);
21
+ class ResponseIdsDto {
22
+ }
23
+ exports.ResponseIdsDto = ResponseIdsDto;
24
+ __decorate([
25
+ (0, class_transformer_1.Expose)(),
26
+ __metadata("design:type", Array)
27
+ ], ResponseIdsDto.prototype, "ids", void 0);
@@ -0,0 +1,29 @@
1
+ export declare enum FILE_TYPE {
2
+ IMAGE = "IMAGE",
3
+ VIDEO = "VIDEO",
4
+ DOCUMENT = "DOCUMENT",
5
+ AUDIO = "AUDIO",
6
+ OTHER = "OTHER"
7
+ }
8
+ export declare enum MIME_TYPE {
9
+ JPEG = "image/jpeg",
10
+ PNG = "image/png",
11
+ GIF = "image/gif",
12
+ PDF = "application/pdf",
13
+ DOC = "application/msword",
14
+ DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
15
+ XLS = "application/vnd.ms-excel",
16
+ XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
17
+ PPT = "application/vnd.ms-powerpoint",
18
+ PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
19
+ TXT = "text/plain",
20
+ HTML = "text/html",
21
+ CSV = "text/csv"
22
+ }
23
+ export declare enum DEVICE_TYPE {
24
+ ANDROID = "android",
25
+ IOS = "ios",
26
+ PC = "pc",
27
+ MAC = "mac",
28
+ OTHER = "other"
29
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEVICE_TYPE = exports.MIME_TYPE = exports.FILE_TYPE = void 0;
4
+ var FILE_TYPE;
5
+ (function (FILE_TYPE) {
6
+ FILE_TYPE["IMAGE"] = "IMAGE";
7
+ FILE_TYPE["VIDEO"] = "VIDEO";
8
+ FILE_TYPE["DOCUMENT"] = "DOCUMENT";
9
+ FILE_TYPE["AUDIO"] = "AUDIO";
10
+ FILE_TYPE["OTHER"] = "OTHER";
11
+ })(FILE_TYPE || (exports.FILE_TYPE = FILE_TYPE = {}));
12
+ var MIME_TYPE;
13
+ (function (MIME_TYPE) {
14
+ MIME_TYPE["JPEG"] = "image/jpeg";
15
+ MIME_TYPE["PNG"] = "image/png";
16
+ MIME_TYPE["GIF"] = "image/gif";
17
+ MIME_TYPE["PDF"] = "application/pdf";
18
+ MIME_TYPE["DOC"] = "application/msword";
19
+ MIME_TYPE["DOCX"] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
20
+ MIME_TYPE["XLS"] = "application/vnd.ms-excel";
21
+ MIME_TYPE["XLSX"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
22
+ MIME_TYPE["PPT"] = "application/vnd.ms-powerpoint";
23
+ MIME_TYPE["PPTX"] = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
24
+ MIME_TYPE["TXT"] = "text/plain";
25
+ MIME_TYPE["HTML"] = "text/html";
26
+ MIME_TYPE["CSV"] = "text/csv";
27
+ })(MIME_TYPE || (exports.MIME_TYPE = MIME_TYPE = {}));
28
+ var DEVICE_TYPE;
29
+ (function (DEVICE_TYPE) {
30
+ DEVICE_TYPE["ANDROID"] = "android";
31
+ DEVICE_TYPE["IOS"] = "ios";
32
+ DEVICE_TYPE["PC"] = "pc";
33
+ DEVICE_TYPE["MAC"] = "mac";
34
+ DEVICE_TYPE["OTHER"] = "other";
35
+ })(DEVICE_TYPE || (exports.DEVICE_TYPE = DEVICE_TYPE = {}));
@@ -0,0 +1,4 @@
1
+ import { ExceptionFilter, ArgumentsHost, HttpException } from '@nestjs/common';
2
+ export declare class HttpExceptionFilter implements ExceptionFilter {
3
+ catch(exception: HttpException, host: ArgumentsHost): void;
4
+ }
@@ -0,0 +1,53 @@
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.HttpExceptionFilter = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let HttpExceptionFilter = class HttpExceptionFilter {
12
+ catch(exception, host) {
13
+ var _a, _b;
14
+ const ctx = host.switchToHttp();
15
+ const response = ctx.getResponse();
16
+ const request = ctx.getRequest();
17
+ const httpStatus = exception instanceof common_1.HttpException
18
+ ? exception.getStatus()
19
+ : common_1.HttpStatus.INTERNAL_SERVER_ERROR;
20
+ let error = {};
21
+ if (exception instanceof common_1.HttpException) {
22
+ error = exception.getResponse();
23
+ }
24
+ else {
25
+ console.error(exception);
26
+ error = {
27
+ error: 'Internal Server Error',
28
+ };
29
+ }
30
+ if (typeof error === 'string') {
31
+ response.status(httpStatus).json({
32
+ success: false,
33
+ code: httpStatus,
34
+ timestamp: new Date().toISOString(),
35
+ path: request.url,
36
+ message: error,
37
+ });
38
+ }
39
+ else {
40
+ response.status(httpStatus).json({
41
+ success: false,
42
+ status: httpStatus,
43
+ path: request.url,
44
+ message: (_a = error.message) !== null && _a !== void 0 ? _a : error.error,
45
+ code: (_b = error.code) !== null && _b !== void 0 ? _b : undefined,
46
+ });
47
+ }
48
+ }
49
+ };
50
+ exports.HttpExceptionFilter = HttpExceptionFilter;
51
+ exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
52
+ (0, common_1.Catch)()
53
+ ], HttpExceptionFilter);
@@ -0,0 +1 @@
1
+ export * from './http-exception.filter';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./http-exception.filter"), exports);
@@ -0,0 +1,8 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ import { Observable } from 'rxjs';
4
+ export declare class AuthGuard implements CanActivate {
5
+ private reflector;
6
+ constructor(reflector: Reflector);
7
+ canActivate(ctx: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
8
+ }
@@ -0,0 +1,38 @@
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.AuthGuard = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const core_1 = require("@nestjs/core");
15
+ let AuthGuard = class AuthGuard {
16
+ constructor(reflector) {
17
+ this.reflector = reflector;
18
+ }
19
+ canActivate(ctx) {
20
+ var _a;
21
+ const roles = this.reflector.get('roles', ctx.getHandler()) ||
22
+ this.reflector.get('roles', ctx.getClass());
23
+ if (!roles.length)
24
+ return true;
25
+ const request = ctx.switchToHttp().getRequest();
26
+ if (roles.includes((_a = request.user) === null || _a === void 0 ? void 0 : _a.role)) {
27
+ return true;
28
+ }
29
+ else {
30
+ throw new common_1.UnauthorizedException('Unauthorized (AuthGuard)');
31
+ }
32
+ }
33
+ };
34
+ exports.AuthGuard = AuthGuard;
35
+ exports.AuthGuard = AuthGuard = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __metadata("design:paramtypes", [core_1.Reflector])
38
+ ], AuthGuard);
@@ -0,0 +1,4 @@
1
+ declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ export declare class JwtAuthGuard extends JwtAuthGuard_base {
3
+ }
4
+ export {};