mfance-shark-v1 1.0.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/README.md +115 -0
- package/dist/common/constants/index.d.ts +57 -0
- package/dist/common/constants/index.js +61 -0
- package/dist/common/constants/index.js.map +1 -0
- package/dist/common/decorators/api-response.decorator.d.ts +8 -0
- package/dist/common/decorators/api-response.decorator.js +23 -0
- package/dist/common/decorators/api-response.decorator.js.map +1 -0
- package/dist/common/decorators/current-user.decorator.d.ts +1 -0
- package/dist/common/decorators/current-user.decorator.js +9 -0
- package/dist/common/decorators/current-user.decorator.js.map +1 -0
- package/dist/common/decorators/index.d.ts +4 -0
- package/dist/common/decorators/index.js +21 -0
- package/dist/common/decorators/index.js.map +1 -0
- package/dist/common/decorators/public.decorator.d.ts +2 -0
- package/dist/common/decorators/public.decorator.js +8 -0
- package/dist/common/decorators/public.decorator.js.map +1 -0
- package/dist/common/decorators/roles.decorator.d.ts +2 -0
- package/dist/common/decorators/roles.decorator.js +8 -0
- package/dist/common/decorators/roles.decorator.js.map +1 -0
- package/dist/common/filters/http-exception.filter.d.ts +4 -0
- package/dist/common/filters/http-exception.filter.js +31 -0
- package/dist/common/filters/http-exception.filter.js.map +1 -0
- package/dist/common/filters/index.d.ts +2 -0
- package/dist/common/filters/index.js +19 -0
- package/dist/common/filters/index.js.map +1 -0
- package/dist/common/filters/validation-exception.filter.d.ts +4 -0
- package/dist/common/filters/validation-exception.filter.js +31 -0
- package/dist/common/filters/validation-exception.filter.js.map +1 -0
- package/dist/common/guards/index.d.ts +2 -0
- package/dist/common/guards/index.js +19 -0
- package/dist/common/guards/index.js.map +1 -0
- package/dist/common/guards/jwt-auth.guard.d.ts +10 -0
- package/dist/common/guards/jwt-auth.guard.js +44 -0
- package/dist/common/guards/jwt-auth.guard.js.map +1 -0
- package/dist/common/guards/roles.guard.d.ts +7 -0
- package/dist/common/guards/roles.guard.js +37 -0
- package/dist/common/guards/roles.guard.js.map +1 -0
- package/dist/common/interceptors/index.d.ts +2 -0
- package/dist/common/interceptors/index.js +19 -0
- package/dist/common/interceptors/index.js.map +1 -0
- package/dist/common/interceptors/logging.interceptor.d.ts +5 -0
- package/dist/common/interceptors/logging.interceptor.js +29 -0
- package/dist/common/interceptors/logging.interceptor.js.map +1 -0
- package/dist/common/interceptors/transform.interceptor.d.ts +11 -0
- package/dist/common/interceptors/transform.interceptor.js +26 -0
- package/dist/common/interceptors/transform.interceptor.js.map +1 -0
- package/dist/common/utils/crypto.util.d.ts +6 -0
- package/dist/common/utils/crypto.util.js +27 -0
- package/dist/common/utils/crypto.util.js.map +1 -0
- package/dist/common/utils/date.util.d.ts +12 -0
- package/dist/common/utils/date.util.js +58 -0
- package/dist/common/utils/date.util.js.map +1 -0
- package/dist/common/utils/index.d.ts +4 -0
- package/dist/common/utils/index.js +21 -0
- package/dist/common/utils/index.js.map +1 -0
- package/dist/common/utils/string.util.d.ts +16 -0
- package/dist/common/utils/string.util.js +73 -0
- package/dist/common/utils/string.util.js.map +1 -0
- package/dist/common/utils/validation.util.d.ts +12 -0
- package/dist/common/utils/validation.util.js +41 -0
- package/dist/common/utils/validation.util.js.map +1 -0
- package/dist/dto/auth/auth-response.dto.d.ts +12 -0
- package/dist/dto/auth/auth-response.dto.js +51 -0
- package/dist/dto/auth/auth-response.dto.js.map +1 -0
- package/dist/dto/auth/index.d.ts +4 -0
- package/dist/dto/auth/index.js +21 -0
- package/dist/dto/auth/index.js.map +1 -0
- package/dist/dto/auth/login.dto.d.ts +4 -0
- package/dist/dto/auth/login.dto.js +38 -0
- package/dist/dto/auth/login.dto.js.map +1 -0
- package/dist/dto/auth/refresh-token.dto.d.ts +3 -0
- package/dist/dto/auth/refresh-token.dto.js +27 -0
- package/dist/dto/auth/refresh-token.dto.js.map +1 -0
- package/dist/dto/auth/register.dto.d.ts +7 -0
- package/dist/dto/auth/register.dto.js +66 -0
- package/dist/dto/auth/register.dto.js.map +1 -0
- package/dist/dto/balance/balance-response.dto.d.ts +8 -0
- package/dist/dto/balance/balance-response.dto.js +59 -0
- package/dist/dto/balance/balance-response.dto.js.map +1 -0
- package/dist/dto/balance/balance.dto.d.ts +8 -0
- package/dist/dto/balance/balance.dto.js +67 -0
- package/dist/dto/balance/balance.dto.js.map +1 -0
- package/dist/dto/balance/index.d.ts +2 -0
- package/dist/dto/balance/index.js +19 -0
- package/dist/dto/balance/index.js.map +1 -0
- package/dist/dto/transaction/create-transaction.dto.d.ts +9 -0
- package/dist/dto/transaction/create-transaction.dto.js +73 -0
- package/dist/dto/transaction/create-transaction.dto.js.map +1 -0
- package/dist/dto/transaction/index.d.ts +4 -0
- package/dist/dto/transaction/index.js +21 -0
- package/dist/dto/transaction/index.js.map +1 -0
- package/dist/dto/transaction/transaction-response.dto.d.ts +13 -0
- package/dist/dto/transaction/transaction-response.dto.js +91 -0
- package/dist/dto/transaction/transaction-response.dto.js.map +1 -0
- package/dist/dto/transaction/transaction.dto.d.ts +23 -0
- package/dist/dto/transaction/transaction.dto.js +108 -0
- package/dist/dto/transaction/transaction.dto.js.map +1 -0
- package/dist/dto/transaction/update-transaction.dto.d.ts +6 -0
- package/dist/dto/transaction/update-transaction.dto.js +50 -0
- package/dist/dto/transaction/update-transaction.dto.js.map +1 -0
- package/dist/dto/user/create-user.dto.d.ts +7 -0
- package/dist/dto/user/create-user.dto.js +66 -0
- package/dist/dto/user/create-user.dto.js.map +1 -0
- package/dist/dto/user/index.d.ts +4 -0
- package/dist/dto/user/index.js +21 -0
- package/dist/dto/user/index.js.map +1 -0
- package/dist/dto/user/update-user.dto.d.ts +6 -0
- package/dist/dto/user/update-user.dto.js +58 -0
- package/dist/dto/user/update-user.dto.js.map +1 -0
- package/dist/dto/user/user-response.dto.d.ts +9 -0
- package/dist/dto/user/user-response.dto.js +67 -0
- package/dist/dto/user/user-response.dto.js.map +1 -0
- package/dist/dto/user/user.dto.d.ts +9 -0
- package/dist/dto/user/user.dto.js +77 -0
- package/dist/dto/user/user.dto.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/api-response.interface.d.ts +29 -0
- package/dist/interfaces/api-response.interface.js +3 -0
- package/dist/interfaces/api-response.interface.js.map +1 -0
- package/dist/interfaces/balance.interface.d.ts +25 -0
- package/dist/interfaces/balance.interface.js +3 -0
- package/dist/interfaces/balance.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/pagination.interface.d.ts +20 -0
- package/dist/interfaces/pagination.interface.js +3 -0
- package/dist/interfaces/pagination.interface.js.map +1 -0
- package/dist/interfaces/transaction.interface.d.ts +38 -0
- package/dist/interfaces/transaction.interface.js +3 -0
- package/dist/interfaces/transaction.interface.js.map +1 -0
- package/dist/interfaces/user.interface.d.ts +36 -0
- package/dist/interfaces/user.interface.js +3 -0
- package/dist/interfaces/user.interface.js.map +1 -0
- package/dist/services/auth/auth.service.d.ts +20 -0
- package/dist/services/auth/auth.service.js +65 -0
- package/dist/services/auth/auth.service.js.map +1 -0
- package/dist/services/auth/index.d.ts +1 -0
- package/dist/services/auth/index.js +18 -0
- package/dist/services/auth/index.js.map +1 -0
- package/dist/services/logger/index.d.ts +1 -0
- package/dist/services/logger/index.js +18 -0
- package/dist/services/logger/index.js.map +1 -0
- package/dist/services/logger/logger.service.d.ts +11 -0
- package/dist/services/logger/logger.service.js +61 -0
- package/dist/services/logger/logger.service.js.map +1 -0
- package/dist/services/validation/index.d.ts +1 -0
- package/dist/services/validation/index.js +18 -0
- package/dist/services/validation/index.js.map +1 -0
- package/dist/services/validation/validation.service.d.ts +13 -0
- package/dist/services/validation/validation.service.js +55 -0
- package/dist/services/validation/validation.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +103 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# MasaFinance Shared Library
|
|
2
|
+
|
|
3
|
+
This is a shared library for MasaFinance microservices that provides common utilities, DTOs, interfaces, and services that can be used across all microservices.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Common DTOs**: Shared data transfer objects for consistent API contracts
|
|
8
|
+
- **Interfaces**: Common interfaces for type safety across services
|
|
9
|
+
- **Utilities**: Helper functions and utilities
|
|
10
|
+
- **Constants**: Shared constants and enums
|
|
11
|
+
- **Decorators**: Custom decorators for validation and metadata
|
|
12
|
+
- **Guards**: Authentication and authorization guards
|
|
13
|
+
- **Interceptors**: Common interceptors for logging, error handling, etc.
|
|
14
|
+
- **Filters**: Exception filters for consistent error responses
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install dependencies
|
|
20
|
+
npm install
|
|
21
|
+
|
|
22
|
+
# Build the library
|
|
23
|
+
npm run build
|
|
24
|
+
|
|
25
|
+
# Run tests
|
|
26
|
+
npm test
|
|
27
|
+
|
|
28
|
+
# Lint code
|
|
29
|
+
npm run lint
|
|
30
|
+
|
|
31
|
+
# Format code
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### In other microservices
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Install the shared library
|
|
41
|
+
npm install @masa-finance/shared-lib
|
|
42
|
+
|
|
43
|
+
# Or use local path for development
|
|
44
|
+
npm install file:../lib
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Import and use
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import {
|
|
51
|
+
ApiResponse,
|
|
52
|
+
UserDto,
|
|
53
|
+
LoggerService,
|
|
54
|
+
JwtAuthGuard,
|
|
55
|
+
ValidationPipe
|
|
56
|
+
} from '@masa-finance/shared-lib';
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Project Structure
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
src/
|
|
63
|
+
├── common/ # Common utilities and helpers
|
|
64
|
+
│ ├── constants/ # Shared constants
|
|
65
|
+
│ ├── decorators/ # Custom decorators
|
|
66
|
+
│ ├── filters/ # Exception filters
|
|
67
|
+
│ ├── guards/ # Authentication guards
|
|
68
|
+
│ ├── interceptors/ # Request/response interceptors
|
|
69
|
+
│ └── utils/ # Utility functions
|
|
70
|
+
├── dto/ # Shared DTOs
|
|
71
|
+
│ ├── auth/ # Authentication DTOs
|
|
72
|
+
│ ├── user/ # User-related DTOs
|
|
73
|
+
│ ├── transaction/ # Transaction DTOs
|
|
74
|
+
│ └── balance/ # Balance DTOs
|
|
75
|
+
├── interfaces/ # Shared interfaces
|
|
76
|
+
├── services/ # Shared services
|
|
77
|
+
│ ├── logger/ # Logging service
|
|
78
|
+
│ ├── auth/ # Authentication service
|
|
79
|
+
│ └── validation/ # Validation service
|
|
80
|
+
└── index.ts # Main export file
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
### Adding new shared components
|
|
86
|
+
|
|
87
|
+
1. Create the component in the appropriate directory
|
|
88
|
+
2. Export it from the main `index.ts` file
|
|
89
|
+
3. Update the README if necessary
|
|
90
|
+
4. Add tests for the new component
|
|
91
|
+
5. Build and test the library
|
|
92
|
+
|
|
93
|
+
### Testing
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Run all tests
|
|
97
|
+
npm test
|
|
98
|
+
|
|
99
|
+
# Run tests in watch mode
|
|
100
|
+
npm run test:watch
|
|
101
|
+
|
|
102
|
+
# Run tests with coverage
|
|
103
|
+
npm run test:cov
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
1. Follow the existing code style and patterns
|
|
109
|
+
2. Add tests for new functionality
|
|
110
|
+
3. Update documentation as needed
|
|
111
|
+
4. Ensure all tests pass before submitting
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const API_RESPONSE_MESSAGES: {
|
|
2
|
+
readonly SUCCESS: "Success";
|
|
3
|
+
readonly CREATED: "Created successfully";
|
|
4
|
+
readonly UPDATED: "Updated successfully";
|
|
5
|
+
readonly DELETED: "Deleted successfully";
|
|
6
|
+
readonly NOT_FOUND: "Resource not found";
|
|
7
|
+
readonly BAD_REQUEST: "Bad request";
|
|
8
|
+
readonly UNAUTHORIZED: "Unauthorized";
|
|
9
|
+
readonly FORBIDDEN: "Forbidden";
|
|
10
|
+
readonly INTERNAL_SERVER_ERROR: "Internal server error";
|
|
11
|
+
readonly VALIDATION_ERROR: "Validation error";
|
|
12
|
+
};
|
|
13
|
+
export declare const HTTP_STATUS_CODES: {
|
|
14
|
+
readonly OK: 200;
|
|
15
|
+
readonly CREATED: 201;
|
|
16
|
+
readonly NO_CONTENT: 204;
|
|
17
|
+
readonly BAD_REQUEST: 400;
|
|
18
|
+
readonly UNAUTHORIZED: 401;
|
|
19
|
+
readonly FORBIDDEN: 403;
|
|
20
|
+
readonly NOT_FOUND: 404;
|
|
21
|
+
readonly CONFLICT: 409;
|
|
22
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
23
|
+
readonly INTERNAL_SERVER_ERROR: 500;
|
|
24
|
+
};
|
|
25
|
+
export declare const PAGINATION: {
|
|
26
|
+
readonly DEFAULT_PAGE: 1;
|
|
27
|
+
readonly DEFAULT_LIMIT: 10;
|
|
28
|
+
readonly MAX_LIMIT: 100;
|
|
29
|
+
};
|
|
30
|
+
export declare const JWT: {
|
|
31
|
+
readonly ACCESS_TOKEN_EXPIRY: "15m";
|
|
32
|
+
readonly REFRESH_TOKEN_EXPIRY: "7d";
|
|
33
|
+
readonly ALGORITHM: "HS256";
|
|
34
|
+
};
|
|
35
|
+
export declare const DATABASE: {
|
|
36
|
+
readonly DEFAULT_TIMEOUT: 30000;
|
|
37
|
+
readonly MAX_CONNECTIONS: 10;
|
|
38
|
+
readonly MIN_CONNECTIONS: 2;
|
|
39
|
+
};
|
|
40
|
+
export declare const LOG_LEVELS: {
|
|
41
|
+
readonly ERROR: "error";
|
|
42
|
+
readonly WARN: "warn";
|
|
43
|
+
readonly INFO: "info";
|
|
44
|
+
readonly DEBUG: "debug";
|
|
45
|
+
};
|
|
46
|
+
export declare const MICROSERVICE_NAMES: {
|
|
47
|
+
readonly USER_MANAGEMENT: "user-management";
|
|
48
|
+
readonly TRANSACTION: "transaction";
|
|
49
|
+
readonly BALANCE: "balance";
|
|
50
|
+
readonly API_GATEWAY: "api-gateway";
|
|
51
|
+
};
|
|
52
|
+
export declare const ENV: {
|
|
53
|
+
readonly DEVELOPMENT: "development";
|
|
54
|
+
readonly STAGING: "staging";
|
|
55
|
+
readonly PRODUCTION: "production";
|
|
56
|
+
readonly TEST: "test";
|
|
57
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENV = exports.MICROSERVICE_NAMES = exports.LOG_LEVELS = exports.DATABASE = exports.JWT = exports.PAGINATION = exports.HTTP_STATUS_CODES = exports.API_RESPONSE_MESSAGES = void 0;
|
|
4
|
+
exports.API_RESPONSE_MESSAGES = {
|
|
5
|
+
SUCCESS: 'Success',
|
|
6
|
+
CREATED: 'Created successfully',
|
|
7
|
+
UPDATED: 'Updated successfully',
|
|
8
|
+
DELETED: 'Deleted successfully',
|
|
9
|
+
NOT_FOUND: 'Resource not found',
|
|
10
|
+
BAD_REQUEST: 'Bad request',
|
|
11
|
+
UNAUTHORIZED: 'Unauthorized',
|
|
12
|
+
FORBIDDEN: 'Forbidden',
|
|
13
|
+
INTERNAL_SERVER_ERROR: 'Internal server error',
|
|
14
|
+
VALIDATION_ERROR: 'Validation error',
|
|
15
|
+
};
|
|
16
|
+
exports.HTTP_STATUS_CODES = {
|
|
17
|
+
OK: 200,
|
|
18
|
+
CREATED: 201,
|
|
19
|
+
NO_CONTENT: 204,
|
|
20
|
+
BAD_REQUEST: 400,
|
|
21
|
+
UNAUTHORIZED: 401,
|
|
22
|
+
FORBIDDEN: 403,
|
|
23
|
+
NOT_FOUND: 404,
|
|
24
|
+
CONFLICT: 409,
|
|
25
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
26
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
27
|
+
};
|
|
28
|
+
exports.PAGINATION = {
|
|
29
|
+
DEFAULT_PAGE: 1,
|
|
30
|
+
DEFAULT_LIMIT: 10,
|
|
31
|
+
MAX_LIMIT: 100,
|
|
32
|
+
};
|
|
33
|
+
exports.JWT = {
|
|
34
|
+
ACCESS_TOKEN_EXPIRY: '15m',
|
|
35
|
+
REFRESH_TOKEN_EXPIRY: '7d',
|
|
36
|
+
ALGORITHM: 'HS256',
|
|
37
|
+
};
|
|
38
|
+
exports.DATABASE = {
|
|
39
|
+
DEFAULT_TIMEOUT: 30000,
|
|
40
|
+
MAX_CONNECTIONS: 10,
|
|
41
|
+
MIN_CONNECTIONS: 2,
|
|
42
|
+
};
|
|
43
|
+
exports.LOG_LEVELS = {
|
|
44
|
+
ERROR: 'error',
|
|
45
|
+
WARN: 'warn',
|
|
46
|
+
INFO: 'info',
|
|
47
|
+
DEBUG: 'debug',
|
|
48
|
+
};
|
|
49
|
+
exports.MICROSERVICE_NAMES = {
|
|
50
|
+
USER_MANAGEMENT: 'user-management',
|
|
51
|
+
TRANSACTION: 'transaction',
|
|
52
|
+
BALANCE: 'balance',
|
|
53
|
+
API_GATEWAY: 'api-gateway',
|
|
54
|
+
};
|
|
55
|
+
exports.ENV = {
|
|
56
|
+
DEVELOPMENT: 'development',
|
|
57
|
+
STAGING: 'staging',
|
|
58
|
+
PRODUCTION: 'production',
|
|
59
|
+
TEST: 'test',
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/constants/index.ts"],"names":[],"mappings":";;;AACa,QAAA,qBAAqB,GAAG;IACnC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,sBAAsB;IAC/B,SAAS,EAAE,oBAAoB;IAC/B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,qBAAqB,EAAE,uBAAuB;IAC9C,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAGE,QAAA,iBAAiB,GAAG;IAC/B,EAAE,EAAE,GAAG;IACP,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,oBAAoB,EAAE,GAAG;IACzB,qBAAqB,EAAE,GAAG;CAClB,CAAC;AAGE,QAAA,UAAU,GAAG;IACxB,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,GAAG;CACN,CAAC;AAGE,QAAA,GAAG,GAAG;IACjB,mBAAmB,EAAE,KAAK;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,SAAS,EAAE,OAAO;CACV,CAAC;AAGE,QAAA,QAAQ,GAAG;IACtB,eAAe,EAAE,KAAK;IACtB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,CAAC;CACV,CAAC;AAGE,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACN,CAAC;AAGE,QAAA,kBAAkB,GAAG;IAChC,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAGE,QAAA,GAAG,GAAG;IACjB,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
export interface ApiResponseOptions {
|
|
3
|
+
status?: number;
|
|
4
|
+
description?: string;
|
|
5
|
+
type?: Type<any>;
|
|
6
|
+
isArray?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const ApiResponseDecorator: (options: ApiResponseOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiResponseDecorator = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const ApiResponseDecorator = (options) => {
|
|
7
|
+
const { status = 200, description, type, isArray = false } = options;
|
|
8
|
+
const schema = type
|
|
9
|
+
? isArray
|
|
10
|
+
? {
|
|
11
|
+
type: 'array',
|
|
12
|
+
items: { $ref: (0, swagger_1.getSchemaPath)(type) },
|
|
13
|
+
}
|
|
14
|
+
: { $ref: (0, swagger_1.getSchemaPath)(type) }
|
|
15
|
+
: undefined;
|
|
16
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiResponse)({
|
|
17
|
+
status,
|
|
18
|
+
description,
|
|
19
|
+
schema,
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
exports.ApiResponseDecorator = ApiResponseDecorator;
|
|
23
|
+
//# sourceMappingURL=api-response.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/api-response.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,6CAA6D;AAStD,MAAM,oBAAoB,GAAG,CAAC,OAA2B,EAAE,EAAE;IAClE,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAErE,MAAM,MAAM,GAAG,IAAI;QACjB,CAAC,CAAC,OAAO;YACP,CAAC,CAAC;gBACE,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,IAAI,CAAC,EAAE;aACrC;YACH,CAAC,CAAC,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,IAAI,CAAC,EAAE;QACjC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,IAAA,wBAAe,EACpB,IAAA,qBAAW,EAAC;QACV,MAAM;QACN,WAAW;QACX,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,oBAAoB,wBAmB/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
|
7
|
+
return request.user;
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=current-user.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./api-response.decorator"), exports);
|
|
18
|
+
__exportStar(require("./current-user.decorator"), exports);
|
|
19
|
+
__exportStar(require("./roles.decorator"), exports);
|
|
20
|
+
__exportStar(require("./public.decorator"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,2DAAyC;AACzC,oDAAkC;AAClC,qDAAmC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.Public = Public;
|
|
8
|
+
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,qBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Roles = exports.ROLES_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.ROLES_KEY = 'roles';
|
|
6
|
+
const Roles = (...roles) => (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
|
|
7
|
+
exports.Roles = Roles;
|
|
8
|
+
//# sourceMappingURL=roles.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/roles.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,iBAAS,EAAE,KAAK,CAAC,CAAC;AAA9D,QAAA,KAAK,SAAyD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
const ctx = host.switchToHttp();
|
|
14
|
+
const response = ctx.getResponse();
|
|
15
|
+
const request = ctx.getRequest();
|
|
16
|
+
const status = exception.getStatus();
|
|
17
|
+
const errorResponse = {
|
|
18
|
+
statusCode: status,
|
|
19
|
+
timestamp: new Date().toISOString(),
|
|
20
|
+
path: request.url,
|
|
21
|
+
message: exception.message,
|
|
22
|
+
error: exception.getResponse(),
|
|
23
|
+
};
|
|
24
|
+
response.status(status).json(errorResponse);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.HttpExceptionFilter = HttpExceptionFilter;
|
|
28
|
+
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
|
|
29
|
+
(0, common_1.Catch)(common_1.HttpException)
|
|
30
|
+
], HttpExceptionFilter);
|
|
31
|
+
//# sourceMappingURL=http-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../../src/common/filters/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAMwB;AAIjB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,KAAK,CAAC,SAAwB,EAAE,IAAmB;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QAErC,MAAM,aAAa,GAAG;YACpB,UAAU,EAAE,MAAM;YAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,KAAK,EAAE,SAAS,CAAC,WAAW,EAAE;SAC/B,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;CACF,CAAA;AAjBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,sBAAa,CAAC;GACR,mBAAmB,CAiB/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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);
|
|
18
|
+
__exportStar(require("./validation-exception.filter"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/filters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,gEAA8C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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.ValidationExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let ValidationExceptionFilter = class ValidationExceptionFilter {
|
|
12
|
+
catch(exception, host) {
|
|
13
|
+
const ctx = host.switchToHttp();
|
|
14
|
+
const response = ctx.getResponse();
|
|
15
|
+
const request = ctx.getRequest();
|
|
16
|
+
const status = exception.getStatus();
|
|
17
|
+
const errorResponse = {
|
|
18
|
+
statusCode: status,
|
|
19
|
+
timestamp: new Date().toISOString(),
|
|
20
|
+
path: request.url,
|
|
21
|
+
message: 'Validation failed',
|
|
22
|
+
errors: exception.getResponse(),
|
|
23
|
+
};
|
|
24
|
+
response.status(status).json(errorResponse);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.ValidationExceptionFilter = ValidationExceptionFilter;
|
|
28
|
+
exports.ValidationExceptionFilter = ValidationExceptionFilter = __decorate([
|
|
29
|
+
(0, common_1.Catch)(common_1.BadRequestException)
|
|
30
|
+
], ValidationExceptionFilter);
|
|
31
|
+
//# sourceMappingURL=validation-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-exception.filter.js","sourceRoot":"","sources":["../../../src/common/filters/validation-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAIjB,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,KAAK,CAAC,SAA8B,EAAE,IAAmB;QACvD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QAErC,MAAM,aAAa,GAAG;YACpB,UAAU,EAAE,MAAM;YAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE;SAChC,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;CACF,CAAA;AAjBY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,cAAK,EAAC,4BAAmB,CAAC;GACd,yBAAyB,CAiBrC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./jwt-auth.guard"), exports);
|
|
18
|
+
__exportStar(require("./roles.guard"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/guards/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
|
+
export declare class JwtAuthGuard extends JwtAuthGuard_base {
|
|
5
|
+
private reflector;
|
|
6
|
+
constructor(reflector: Reflector);
|
|
7
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
8
|
+
handleRequest(err: any, user: any, info: any): any;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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.JwtAuthGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
const public_decorator_1 = require("../decorators/public.decorator");
|
|
17
|
+
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
18
|
+
constructor(reflector) {
|
|
19
|
+
super();
|
|
20
|
+
this.reflector = reflector;
|
|
21
|
+
}
|
|
22
|
+
canActivate(context) {
|
|
23
|
+
const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
|
|
24
|
+
context.getHandler(),
|
|
25
|
+
context.getClass(),
|
|
26
|
+
]);
|
|
27
|
+
if (isPublic) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return super.canActivate(context);
|
|
31
|
+
}
|
|
32
|
+
handleRequest(err, user, info) {
|
|
33
|
+
if (err || !user) {
|
|
34
|
+
throw err || new common_1.UnauthorizedException();
|
|
35
|
+
}
|
|
36
|
+
return user;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
|
40
|
+
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
43
|
+
], JwtAuthGuard);
|
|
44
|
+
//# sourceMappingURL=jwt-auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../../src/common/guards/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAIwB;AACxB,uCAAyC;AACzC,+CAA6C;AAC7C,qEAA+D;AAGxD,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;IAChD,YAAoB,SAAoB;QACtC,KAAK,EAAE,CAAC;QADU,cAAS,GAAT,SAAS,CAAW;IAExC,CAAC;IAED,WAAW,CAAC,OAAyB;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,gCAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,aAAa,CAAC,GAAQ,EAAE,IAAS,EAAE,IAAS;QAC1C,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,GAAG,IAAI,IAAI,8BAAqB,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAxBY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAEoB,gBAAS;GAD7B,YAAY,CAwBxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
export declare class RolesGuard implements CanActivate {
|
|
4
|
+
private reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.RolesGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const roles_decorator_1 = require("../decorators/roles.decorator");
|
|
16
|
+
let RolesGuard = class RolesGuard {
|
|
17
|
+
constructor(reflector) {
|
|
18
|
+
this.reflector = reflector;
|
|
19
|
+
}
|
|
20
|
+
canActivate(context) {
|
|
21
|
+
const requiredRoles = this.reflector.getAllAndOverride(roles_decorator_1.ROLES_KEY, [
|
|
22
|
+
context.getHandler(),
|
|
23
|
+
context.getClass(),
|
|
24
|
+
]);
|
|
25
|
+
if (!requiredRoles) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const { user } = context.switchToHttp().getRequest();
|
|
29
|
+
return requiredRoles.some((role) => user.roles?.includes(role));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.RolesGuard = RolesGuard;
|
|
33
|
+
exports.RolesGuard = RolesGuard = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
36
|
+
], RolesGuard);
|
|
37
|
+
//# sourceMappingURL=roles.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.guard.js","sourceRoot":"","sources":["../../../src/common/guards/roles.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,mEAA0D;AAGnD,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,WAAW,CAAC,OAAyB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAW,2BAAS,EAAE;YAC1E,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACrD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAhBY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAEoB,gBAAS;GAD7B,UAAU,CAgBtB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./logging.interceptor"), exports);
|
|
18
|
+
__exportStar(require("./transform.interceptor"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/interceptors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,0DAAwC"}
|