Compare commits
2 Commits
32682ff45b
...
532f2ed8e8
| Author | SHA1 | Date | |
|---|---|---|---|
| 532f2ed8e8 | |||
| db5dedf1fb |
18
.env
Normal file
18
.env
Normal file
@@ -0,0 +1,18 @@
|
||||
PORT=3000
|
||||
NODE_ENV=production
|
||||
DB_URL=postgres://parsdbshop:ZtKKAQWA00umtkNXUMcjVNRD6avXFOVDOfqGcTTLwhnGUYq6EnSvaYsyJi06sx6j@62.3.14.124:6986/postgres
|
||||
REDIS_URL=redis://parsuserdb:xTpObuam6vTAAtWhn92rvQdo8rjhO22K4IxyJxdooUAPoyY9zLbYSYBSRm6io7E6@62.3.14.124:9654/0
|
||||
MINIO_ENDPOINT=s3.ir-thr-at1.arvanstorage.ir
|
||||
MINIO_PORT=80
|
||||
MINIO_ACCESS_KEY=8e66af66-67cb-4dcb-ba62-36e88ad7083e
|
||||
MINIO_SECRET_KEY=770b6bd2f4a93313312dd29bdee80fd57b1490ec86039124b44333a8f150d138
|
||||
MINIO_BUCKET=pod
|
||||
JWT_SECRET=HJAKINMAqi1732bJHGHABADRMESTAhad
|
||||
JWT_ACCESS_TTL=15m
|
||||
JWT_REFRESH_TTL=30d
|
||||
SMS_API_KEY=replace-me
|
||||
OTP_TTL_SECONDS=120
|
||||
SMS_WSDL_URL=http://payammatni.com/webservice/send.php?wsdl
|
||||
SMS_USERNAME=engel5960
|
||||
SMS_PASSWORD=replace-me
|
||||
SMS_NUMBER=80008
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
npm-debug.log
|
||||
coverage
|
||||
|
||||
/dist
|
||||
tmp-start.*
|
||||
*.log
|
||||
|
||||
6
dist/app.controller.d.ts
vendored
6
dist/app.controller.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
import { AppService } from './app.service';
|
||||
export declare class AppController {
|
||||
private readonly appService;
|
||||
constructor(appService: AppService);
|
||||
getHealth(): string;
|
||||
}
|
||||
38
dist/app.controller.js
vendored
38
dist/app.controller.js
vendored
@@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const app_service_1 = require("./app.service");
|
||||
let AppController = class AppController {
|
||||
appService;
|
||||
constructor(appService) {
|
||||
this.appService = appService;
|
||||
}
|
||||
getHealth() {
|
||||
return this.appService.getHealth();
|
||||
}
|
||||
};
|
||||
exports.AppController = AppController;
|
||||
__decorate([
|
||||
(0, common_1.Get)('health'),
|
||||
(0, common_1.Header)('Content-Type', 'text/plain; charset=utf-8'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "getHealth", null);
|
||||
exports.AppController = AppController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Health'),
|
||||
(0, common_1.Controller)(),
|
||||
__metadata("design:paramtypes", [app_service_1.AppService])
|
||||
], AppController);
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
1
dist/app.controller.js.map
vendored
1
dist/app.controller.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyD;AACzD,6CAA0C;AAC1C,+CAA2C;AAIpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACK;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAIvD,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;CACF,CAAA;AARY,sCAAa;AAKxB;IAFC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,eAAM,EAAC,cAAc,EAAE,2BAA2B,CAAC;;;;8CAGnD;wBAPU,aAAa;IAFzB,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAQzB"}
|
||||
2
dist/app.module.d.ts
vendored
2
dist/app.module.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
export declare class AppModule {
|
||||
}
|
||||
78
dist/app.module.js
vendored
78
dist/app.module.js
vendored
@@ -1,78 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const app_controller_1 = require("./app.controller");
|
||||
const app_service_1 = require("./app.service");
|
||||
const configuration_1 = require("./config/configuration");
|
||||
const env_validation_1 = require("./config/env.validation");
|
||||
const typeorm_config_1 = require("./config/typeorm.config");
|
||||
const auth_module_1 = require("./modules/auth/auth.module");
|
||||
const auth_otp_entity_1 = require("./modules/auth/entities/auth-otp.entity");
|
||||
const user_session_entity_1 = require("./modules/auth/entities/user-session.entity");
|
||||
const category_entity_1 = require("./modules/catalog/entities/category.entity");
|
||||
const attribute_definition_entity_1 = require("./modules/catalog/entities/attribute-definition.entity");
|
||||
const brand_entity_1 = require("./modules/catalog/entities/brand.entity");
|
||||
const product_attribute_value_entity_1 = require("./modules/catalog/entities/product-attribute-value.entity");
|
||||
const product_meta_entity_1 = require("./modules/catalog/entities/product-meta.entity");
|
||||
const product_entity_1 = require("./modules/catalog/entities/product.entity");
|
||||
const product_review_entity_1 = require("./modules/catalog/entities/product-review.entity");
|
||||
const media_module_1 = require("./modules/media/media.module");
|
||||
const media_asset_entity_1 = require("./modules/media/entities/media-asset.entity");
|
||||
const catalog_module_1 = require("./modules/catalog/catalog.module");
|
||||
const storage_module_1 = require("./modules/storage/storage.module");
|
||||
const loyalty_profile_entity_1 = require("./modules/users/entities/loyalty-profile.entity");
|
||||
const user_entity_1 = require("./modules/users/entities/user.entity");
|
||||
const user_level_history_entity_1 = require("./modules/users/entities/user-level-history.entity");
|
||||
const wallet_transaction_entity_1 = require("./modules/users/entities/wallet-transaction.entity");
|
||||
const wallet_entity_1 = require("./modules/users/entities/wallet.entity");
|
||||
const users_module_1 = require("./modules/users/users.module");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
exports.AppModule = AppModule;
|
||||
exports.AppModule = AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
config_1.ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [configuration_1.default],
|
||||
validate: env_validation_1.validateEnv,
|
||||
envFilePath: ['.env'],
|
||||
}),
|
||||
typeorm_1.TypeOrmModule.forRootAsync(typeorm_config_1.typeOrmConfigFactory),
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
user_entity_1.User,
|
||||
wallet_entity_1.Wallet,
|
||||
wallet_transaction_entity_1.WalletTransaction,
|
||||
loyalty_profile_entity_1.LoyaltyProfile,
|
||||
user_level_history_entity_1.UserLevelHistory,
|
||||
auth_otp_entity_1.AuthOtp,
|
||||
user_session_entity_1.UserSession,
|
||||
product_entity_1.Product,
|
||||
category_entity_1.Category,
|
||||
brand_entity_1.Brand,
|
||||
product_review_entity_1.ProductReview,
|
||||
product_meta_entity_1.ProductMeta,
|
||||
attribute_definition_entity_1.AttributeDefinition,
|
||||
product_attribute_value_entity_1.ProductAttributeValue,
|
||||
media_asset_entity_1.MediaAsset,
|
||||
]),
|
||||
storage_module_1.StorageModule,
|
||||
users_module_1.UsersModule,
|
||||
catalog_module_1.CatalogModule,
|
||||
media_module_1.MediaModule,
|
||||
auth_module_1.AuthModule,
|
||||
],
|
||||
controllers: [app_controller_1.AppController],
|
||||
providers: [app_service_1.AppService],
|
||||
})
|
||||
], AppModule);
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
1
dist/app.module.js.map
vendored
1
dist/app.module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAC9C,6CAAgD;AAChD,qDAAiD;AACjD,+CAA2C;AAC3C,0DAAmD;AACnD,4DAAsD;AACtD,4DAA+D;AAC/D,4DAAwD;AACxD,6EAAkE;AAClE,qFAA0E;AAC1E,gFAAsE;AACtE,wGAA6F;AAC7F,0EAAgE;AAChE,8GAAkG;AAClG,wFAA6E;AAC7E,8EAAoE;AACpE,4FAAiF;AACjF,+DAA2D;AAC3D,oFAAyE;AACzE,qEAAiE;AACjE,qEAAiE;AACjE,4FAAiF;AACjF,sEAA4D;AAC5D,kGAAsF;AACtF,kGAAuF;AACvF,0EAAgE;AAChE,+DAA2D;AAqCpD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAnCrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,CAAC,uBAAa,CAAC;gBACrB,QAAQ,EAAE,4BAAW;gBACrB,WAAW,EAAE,CAAC,MAAM,CAAC;aACtB,CAAC;YACF,uBAAa,CAAC,YAAY,CAAC,qCAAoB,CAAC;YAChD,uBAAa,CAAC,UAAU,CAAC;gBACvB,kBAAI;gBACJ,sBAAM;gBACN,6CAAiB;gBACjB,uCAAc;gBACd,4CAAgB;gBAChB,yBAAO;gBACP,iCAAW;gBACX,wBAAO;gBACP,0BAAQ;gBACR,oBAAK;gBACL,qCAAa;gBACb,iCAAW;gBACX,iDAAmB;gBACnB,sDAAqB;gBACrB,+BAAU;aACX,CAAC;YACF,8BAAa;YACb,0BAAW;YACX,8BAAa;YACb,0BAAW;YACX,wBAAU;SACX;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"}
|
||||
3
dist/app.service.d.ts
vendored
3
dist/app.service.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
export declare class AppService {
|
||||
getHealth(): string;
|
||||
}
|
||||
20
dist/app.service.js
vendored
20
dist/app.service.js
vendored
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppService = class AppService {
|
||||
getHealth() {
|
||||
return 'OK';
|
||||
}
|
||||
};
|
||||
exports.AppService = AppService;
|
||||
exports.AppService = AppService = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], AppService);
|
||||
//# sourceMappingURL=app.service.js.map
|
||||
1
dist/app.service.js.map
vendored
1
dist/app.service.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,SAAS;QACP,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAJY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB"}
|
||||
@@ -1,2 +0,0 @@
|
||||
export declare const PERMISSIONS_KEY = "permissions";
|
||||
export declare const Permissions: (...permissions: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
||||
@@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Permissions = exports.PERMISSIONS_KEY = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
exports.PERMISSIONS_KEY = 'permissions';
|
||||
const Permissions = (...permissions) => (0, common_1.SetMetadata)(exports.PERMISSIONS_KEY, permissions);
|
||||
exports.Permissions = Permissions;
|
||||
//# sourceMappingURL=permissions.decorator.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"permissions.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/permissions.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,WAAW,GAAG,CAAC,GAAG,WAAqB,EAAE,EAAE,CACtD,IAAA,oBAAW,EAAC,uBAAe,EAAE,WAAW,CAAC,CAAC;AAD/B,QAAA,WAAW,eACoB"}
|
||||
3
dist/common/decorators/roles.decorator.d.ts
vendored
3
dist/common/decorators/roles.decorator.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
import { UserRole } from '../../modules/users/enums/user-role.enum';
|
||||
export declare const ROLES_KEY = "roles";
|
||||
export declare const Roles: (...roles: UserRole[]) => import("@nestjs/common").CustomDecorator<string>;
|
||||
8
dist/common/decorators/roles.decorator.js
vendored
8
dist/common/decorators/roles.decorator.js
vendored
@@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Roles = exports.ROLES_KEY = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
exports.ROLES_KEY = 'roles';
|
||||
const Roles = (...roles) => (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
|
||||
exports.Roles = Roles;
|
||||
//# sourceMappingURL=roles.decorator.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"roles.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/roles.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAGhC,QAAA,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAiB,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,iBAAS,EAAE,KAAK,CAAC,CAAC;AAAhE,QAAA,KAAK,SAA2D"}
|
||||
7
dist/common/guards/permissions.guard.d.ts
vendored
7
dist/common/guards/permissions.guard.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
export declare class PermissionsGuard implements CanActivate {
|
||||
private readonly reflector;
|
||||
constructor(reflector: Reflector);
|
||||
canActivate(context: ExecutionContext): boolean;
|
||||
}
|
||||
37
dist/common/guards/permissions.guard.js
vendored
37
dist/common/guards/permissions.guard.js
vendored
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PermissionsGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const permissions_decorator_1 = require("../decorators/permissions.decorator");
|
||||
let PermissionsGuard = class PermissionsGuard {
|
||||
reflector;
|
||||
constructor(reflector) {
|
||||
this.reflector = reflector;
|
||||
}
|
||||
canActivate(context) {
|
||||
const requiredPermissions = this.reflector.getAllAndOverride(permissions_decorator_1.PERMISSIONS_KEY, [context.getHandler(), context.getClass()]);
|
||||
if (!requiredPermissions || requiredPermissions.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const user = request.user;
|
||||
const permissions = user?.permissions ?? [];
|
||||
return requiredPermissions.every((permission) => permissions.includes(permission));
|
||||
}
|
||||
};
|
||||
exports.PermissionsGuard = PermissionsGuard;
|
||||
exports.PermissionsGuard = PermissionsGuard = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [core_1.Reflector])
|
||||
], PermissionsGuard);
|
||||
//# sourceMappingURL=permissions.guard.js.map
|
||||
1
dist/common/guards/permissions.guard.js.map
vendored
1
dist/common/guards/permissions.guard.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"permissions.guard.js","sourceRoot":"","sources":["../../../src/common/guards/permissions.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAIwB;AACxB,uCAAyC;AACzC,+EAAsE;AAI/D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,WAAW,CAAC,OAAyB;QACnC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAC1D,uCAAe,EACf,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAC3C,CAAC;QAEF,IAAI,CAAC,mBAAmB,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAA8B,CAAC;QACpD,MAAM,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;QAE5C,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAC9C,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CACjC,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE6B,gBAAS;GADtC,gBAAgB,CAqB5B"}
|
||||
7
dist/common/guards/roles.guard.d.ts
vendored
7
dist/common/guards/roles.guard.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
export declare class RolesGuard implements CanActivate {
|
||||
private readonly reflector;
|
||||
constructor(reflector: Reflector);
|
||||
canActivate(context: ExecutionContext): boolean;
|
||||
}
|
||||
39
dist/common/guards/roles.guard.js
vendored
39
dist/common/guards/roles.guard.js
vendored
@@ -1,39 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RolesGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const roles_decorator_1 = require("../decorators/roles.decorator");
|
||||
let RolesGuard = class RolesGuard {
|
||||
reflector;
|
||||
constructor(reflector) {
|
||||
this.reflector = reflector;
|
||||
}
|
||||
canActivate(context) {
|
||||
const requiredRoles = this.reflector.getAllAndOverride(roles_decorator_1.ROLES_KEY, [
|
||||
context.getHandler(),
|
||||
context.getClass(),
|
||||
]);
|
||||
if (!requiredRoles || requiredRoles.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const user = request.user;
|
||||
return !!user && requiredRoles.includes(user.role);
|
||||
}
|
||||
};
|
||||
exports.RolesGuard = RolesGuard;
|
||||
exports.RolesGuard = RolesGuard = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [core_1.Reflector])
|
||||
], RolesGuard);
|
||||
//# sourceMappingURL=roles.guard.js.map
|
||||
1
dist/common/guards/roles.guard.js.map
vendored
1
dist/common/guards/roles.guard.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"roles.guard.js","sourceRoot":"","sources":["../../../src/common/guards/roles.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAIwB;AACxB,uCAAyC;AACzC,mEAA0D;AAInD,IAAM,UAAU,GAAhB,MAAM,UAAU;IACQ;IAA7B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,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,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAA8B,CAAC;QAEpD,OAAO,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAlBY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAE6B,gBAAS;GADtC,UAAU,CAkBtB"}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { Observable } from 'rxjs';
|
||||
export interface StandardApiResponse<T> {
|
||||
success: boolean;
|
||||
statusCode: number;
|
||||
path: string;
|
||||
timestamp: string;
|
||||
data: T;
|
||||
}
|
||||
export declare class ResponseInterceptor<T> implements NestInterceptor<T, StandardApiResponse<T>> {
|
||||
private readonly reflector;
|
||||
constructor(reflector: Reflector);
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<StandardApiResponse<T>>;
|
||||
}
|
||||
39
dist/common/interceptors/response.interceptor.js
vendored
39
dist/common/interceptors/response.interceptor.js
vendored
@@ -1,39 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ResponseInterceptor = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const rxjs_1 = require("rxjs");
|
||||
let ResponseInterceptor = class ResponseInterceptor {
|
||||
reflector;
|
||||
constructor(reflector) {
|
||||
this.reflector = reflector;
|
||||
}
|
||||
intercept(context, next) {
|
||||
const http = context.switchToHttp();
|
||||
const response = http.getResponse();
|
||||
const request = http.getRequest();
|
||||
return next.handle().pipe((0, rxjs_1.map)((data) => ({
|
||||
success: true,
|
||||
statusCode: response.statusCode,
|
||||
path: request.url,
|
||||
timestamp: new Date().toISOString(),
|
||||
data,
|
||||
})));
|
||||
}
|
||||
};
|
||||
exports.ResponseInterceptor = ResponseInterceptor;
|
||||
exports.ResponseInterceptor = ResponseInterceptor = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [core_1.Reflector])
|
||||
], ResponseInterceptor);
|
||||
//# sourceMappingURL=response.interceptor.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"response.interceptor.js","sourceRoot":"","sources":["../../../src/common/interceptors/response.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,uCAAyC;AACzC,+BAAuC;AAWhC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAGD;IAA7B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,SAAS,CACP,OAAyB,EACzB,IAAiB;QAEjB,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACb,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI;SACL,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;CACF,CAAA;AAvBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAI6B,gBAAS;GAHtC,mBAAmB,CAuB/B"}
|
||||
2
dist/common/utils/json-transform.util.d.ts
vendored
2
dist/common/utils/json-transform.util.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
import { TransformFnParams } from 'class-transformer';
|
||||
export declare function parseJsonValue({ value }: TransformFnParams): any;
|
||||
21
dist/common/utils/json-transform.util.js
vendored
21
dist/common/utils/json-transform.util.js
vendored
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseJsonValue = parseJsonValue;
|
||||
function parseJsonValue({ value }) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
//# sourceMappingURL=json-transform.util.js.map
|
||||
1
dist/common/utils/json-transform.util.js.map
vendored
1
dist/common/utils/json-transform.util.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"json-transform.util.js","sourceRoot":"","sources":["../../../src/common/utils/json-transform.util.ts"],"names":[],"mappings":";;AAEA,wCAkBC;AAlBD,SAAgB,cAAc,CAAC,EAAE,KAAK,EAAqB;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
||||
40
dist/config/configuration.d.ts
vendored
40
dist/config/configuration.d.ts
vendored
@@ -1,40 +0,0 @@
|
||||
declare const _default: () => {
|
||||
app: {
|
||||
port: number;
|
||||
nodeEnv: string;
|
||||
};
|
||||
database: {
|
||||
url: string | undefined;
|
||||
ssl: boolean;
|
||||
};
|
||||
redis: {
|
||||
url: string | undefined;
|
||||
};
|
||||
jwt: {
|
||||
secret: string | undefined;
|
||||
accessTtl: string;
|
||||
refreshTtl: string;
|
||||
};
|
||||
sms: {
|
||||
apiKey: string | undefined;
|
||||
wsdlUrl: string | undefined;
|
||||
username: string | undefined;
|
||||
password: string | undefined;
|
||||
fromNumber: string | undefined;
|
||||
};
|
||||
otp: {
|
||||
ttlSeconds: number;
|
||||
};
|
||||
minio: {
|
||||
endpoint: string | undefined;
|
||||
port: number;
|
||||
useSsl: boolean;
|
||||
accessKey: string | undefined;
|
||||
secretKey: string | undefined;
|
||||
bucket: string | undefined;
|
||||
publicBucket: string | undefined;
|
||||
privateBucket: string;
|
||||
publicUrl: string | undefined;
|
||||
};
|
||||
};
|
||||
export default _default;
|
||||
42
dist/config/configuration.js
vendored
42
dist/config/configuration.js
vendored
@@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = () => ({
|
||||
app: {
|
||||
port: parseInt(process.env.PORT ?? '3000', 10),
|
||||
nodeEnv: process.env.NODE_ENV ?? 'development',
|
||||
},
|
||||
database: {
|
||||
url: process.env.DB_URL,
|
||||
ssl: (process.env.DB_SSL ?? 'false') === 'true',
|
||||
},
|
||||
redis: {
|
||||
url: process.env.REDIS_URL,
|
||||
},
|
||||
jwt: {
|
||||
secret: process.env.JWT_SECRET,
|
||||
accessTtl: process.env.JWT_ACCESS_TTL ?? '15m',
|
||||
refreshTtl: process.env.JWT_REFRESH_TTL ?? '30d',
|
||||
},
|
||||
sms: {
|
||||
apiKey: process.env.SMS_API_KEY,
|
||||
wsdlUrl: process.env.SMS_WSDL_URL,
|
||||
username: process.env.SMS_USERNAME,
|
||||
password: process.env.SMS_PASSWORD,
|
||||
fromNumber: process.env.SMS_NUMBER,
|
||||
},
|
||||
otp: {
|
||||
ttlSeconds: parseInt(process.env.OTP_TTL_SECONDS ?? '120', 10),
|
||||
},
|
||||
minio: {
|
||||
endpoint: process.env.MINIO_ENDPOINT,
|
||||
port: parseInt(process.env.MINIO_PORT ?? '9000', 10),
|
||||
useSsl: (process.env.MINIO_USE_SSL ?? 'false') === 'true',
|
||||
accessKey: process.env.MINIO_ACCESS_KEY,
|
||||
secretKey: process.env.MINIO_SECRET_KEY,
|
||||
bucket: process.env.MINIO_BUCKET,
|
||||
publicBucket: process.env.MINIO_PUBLIC_BUCKET ?? process.env.MINIO_BUCKET,
|
||||
privateBucket: process.env.MINIO_PRIVATE_BUCKET ?? 'parsshop-private',
|
||||
publicUrl: process.env.MINIO_PUBLIC_URL,
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=configuration.js.map
|
||||
1
dist/config/configuration.js.map
vendored
1
dist/config/configuration.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/config/configuration.ts"],"names":[],"mappings":";;AAAA,kBAAe,GAAG,EAAE,CAAC,CAAC;IACpB,GAAG,EAAE;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,CAAC;QAC9C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;KAC/C;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;QACvB,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,MAAM;KAChD;IACD,KAAK,EAAE;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;KAC3B;IACD,GAAG,EAAE;QACH,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,KAAK;QAC9C,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK;KACjD;IACD,GAAG,EAAE;QACH,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;QAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QACjC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAClC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAClC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;KACnC;IACD,GAAG,EAAE;QACH,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK,EAAE,EAAE,CAAC;KAC/D;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QACpC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,EAAE,EAAE,CAAC;QACpD,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,KAAK,MAAM;QACzD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACvC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACvC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAChC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;QACzE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,kBAAkB;QACrE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;KACxC;CACF,CAAC,CAAC"}
|
||||
27
dist/config/env.validation.d.ts
vendored
27
dist/config/env.validation.d.ts
vendored
@@ -1,27 +0,0 @@
|
||||
declare class EnvironmentVariables {
|
||||
PORT?: string;
|
||||
NODE_ENV?: string;
|
||||
DB_URL: string;
|
||||
DB_SSL?: string;
|
||||
REDIS_URL?: string;
|
||||
JWT_SECRET: string;
|
||||
JWT_ACCESS_TTL?: string;
|
||||
JWT_REFRESH_TTL?: string;
|
||||
SMS_API_KEY: string;
|
||||
SMS_WSDL_URL?: string;
|
||||
SMS_USERNAME?: string;
|
||||
SMS_PASSWORD?: string;
|
||||
SMS_NUMBER?: string;
|
||||
OTP_TTL_SECONDS?: string;
|
||||
MINIO_ENDPOINT?: string;
|
||||
MINIO_PORT?: string;
|
||||
MINIO_USE_SSL?: string;
|
||||
MINIO_ACCESS_KEY?: string;
|
||||
MINIO_SECRET_KEY?: string;
|
||||
MINIO_BUCKET?: string;
|
||||
MINIO_PUBLIC_BUCKET?: string;
|
||||
MINIO_PRIVATE_BUCKET?: string;
|
||||
MINIO_PUBLIC_URL?: string;
|
||||
}
|
||||
export declare function validateEnv(config: Record<string, unknown>): EnvironmentVariables;
|
||||
export {};
|
||||
167
dist/config/env.validation.js
vendored
167
dist/config/env.validation.js
vendored
@@ -1,167 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateEnv = validateEnv;
|
||||
const class_transformer_1 = require("class-transformer");
|
||||
const class_validator_1 = require("class-validator");
|
||||
class EnvironmentVariables {
|
||||
PORT;
|
||||
NODE_ENV;
|
||||
DB_URL;
|
||||
DB_SSL;
|
||||
REDIS_URL;
|
||||
JWT_SECRET;
|
||||
JWT_ACCESS_TTL;
|
||||
JWT_REFRESH_TTL;
|
||||
SMS_API_KEY;
|
||||
SMS_WSDL_URL;
|
||||
SMS_USERNAME;
|
||||
SMS_PASSWORD;
|
||||
SMS_NUMBER;
|
||||
OTP_TTL_SECONDS;
|
||||
MINIO_ENDPOINT;
|
||||
MINIO_PORT;
|
||||
MINIO_USE_SSL;
|
||||
MINIO_ACCESS_KEY;
|
||||
MINIO_SECRET_KEY;
|
||||
MINIO_BUCKET;
|
||||
MINIO_PUBLIC_BUCKET;
|
||||
MINIO_PRIVATE_BUCKET;
|
||||
MINIO_PUBLIC_URL;
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsNumberString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "PORT", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "NODE_ENV", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsNotEmpty)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "DB_URL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "DB_SSL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "REDIS_URL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsNotEmpty)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "JWT_SECRET", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "JWT_ACCESS_TTL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "JWT_REFRESH_TTL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsNotEmpty)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "SMS_API_KEY", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "SMS_WSDL_URL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "SMS_USERNAME", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "SMS_PASSWORD", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "SMS_NUMBER", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsNumberString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "OTP_TTL_SECONDS", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_ENDPOINT", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsNumberString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_PORT", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_USE_SSL", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_ACCESS_KEY", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_SECRET_KEY", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_BUCKET", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_PUBLIC_BUCKET", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_PRIVATE_BUCKET", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], EnvironmentVariables.prototype, "MINIO_PUBLIC_URL", void 0);
|
||||
function validateEnv(config) {
|
||||
const validatedConfig = (0, class_transformer_1.plainToInstance)(EnvironmentVariables, config, {
|
||||
enableImplicitConversion: true,
|
||||
});
|
||||
const errors = (0, class_validator_1.validateSync)(validatedConfig, {
|
||||
skipMissingProperties: false,
|
||||
});
|
||||
if (errors.length > 0) {
|
||||
throw new Error(errors.toString());
|
||||
}
|
||||
return validatedConfig;
|
||||
}
|
||||
//# sourceMappingURL=env.validation.js.map
|
||||
1
dist/config/env.validation.js.map
vendored
1
dist/config/env.validation.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../../src/config/env.validation.ts"],"names":[],"mappings":"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"}
|
||||
4
dist/config/typeorm.config.d.ts
vendored
4
dist/config/typeorm.config.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { TypeOrmModuleAsyncOptions, TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
export declare const buildTypeOrmOptions: (configService: ConfigService) => TypeOrmModuleOptions;
|
||||
export declare const typeOrmConfigFactory: TypeOrmModuleAsyncOptions;
|
||||
54
dist/config/typeorm.config.js
vendored
54
dist/config/typeorm.config.js
vendored
@@ -1,54 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.typeOrmConfigFactory = exports.buildTypeOrmOptions = void 0;
|
||||
const config_1 = require("@nestjs/config");
|
||||
const auth_otp_entity_1 = require("../modules/auth/entities/auth-otp.entity");
|
||||
const user_session_entity_1 = require("../modules/auth/entities/user-session.entity");
|
||||
const attribute_definition_entity_1 = require("../modules/catalog/entities/attribute-definition.entity");
|
||||
const brand_entity_1 = require("../modules/catalog/entities/brand.entity");
|
||||
const category_entity_1 = require("../modules/catalog/entities/category.entity");
|
||||
const product_attribute_value_entity_1 = require("../modules/catalog/entities/product-attribute-value.entity");
|
||||
const product_meta_entity_1 = require("../modules/catalog/entities/product-meta.entity");
|
||||
const product_entity_1 = require("../modules/catalog/entities/product.entity");
|
||||
const product_review_entity_1 = require("../modules/catalog/entities/product-review.entity");
|
||||
const media_asset_entity_1 = require("../modules/media/entities/media-asset.entity");
|
||||
const loyalty_profile_entity_1 = require("../modules/users/entities/loyalty-profile.entity");
|
||||
const user_entity_1 = require("../modules/users/entities/user.entity");
|
||||
const user_level_history_entity_1 = require("../modules/users/entities/user-level-history.entity");
|
||||
const wallet_transaction_entity_1 = require("../modules/users/entities/wallet-transaction.entity");
|
||||
const wallet_entity_1 = require("../modules/users/entities/wallet.entity");
|
||||
const buildTypeOrmOptions = (configService) => {
|
||||
const sslEnabled = configService.get('database.ssl', false);
|
||||
return {
|
||||
type: 'postgres',
|
||||
url: configService.get('database.url'),
|
||||
ssl: sslEnabled ? { rejectUnauthorized: false } : false,
|
||||
extra: sslEnabled ? { ssl: { rejectUnauthorized: false } } : {},
|
||||
entities: [
|
||||
user_entity_1.User,
|
||||
wallet_entity_1.Wallet,
|
||||
wallet_transaction_entity_1.WalletTransaction,
|
||||
loyalty_profile_entity_1.LoyaltyProfile,
|
||||
user_level_history_entity_1.UserLevelHistory,
|
||||
auth_otp_entity_1.AuthOtp,
|
||||
user_session_entity_1.UserSession,
|
||||
product_entity_1.Product,
|
||||
category_entity_1.Category,
|
||||
brand_entity_1.Brand,
|
||||
product_review_entity_1.ProductReview,
|
||||
product_meta_entity_1.ProductMeta,
|
||||
attribute_definition_entity_1.AttributeDefinition,
|
||||
product_attribute_value_entity_1.ProductAttributeValue,
|
||||
media_asset_entity_1.MediaAsset,
|
||||
],
|
||||
autoLoadEntities: false,
|
||||
synchronize: true,
|
||||
};
|
||||
};
|
||||
exports.buildTypeOrmOptions = buildTypeOrmOptions;
|
||||
exports.typeOrmConfigFactory = {
|
||||
imports: [config_1.ConfigModule],
|
||||
inject: [config_1.ConfigService],
|
||||
useFactory: (configService) => (0, exports.buildTypeOrmOptions)(configService),
|
||||
};
|
||||
//# sourceMappingURL=typeorm.config.js.map
|
||||
1
dist/config/typeorm.config.js.map
vendored
1
dist/config/typeorm.config.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"typeorm.config.js","sourceRoot":"","sources":["../../src/config/typeorm.config.ts"],"names":[],"mappings":";;;AAAA,2CAA6D;AAE7D,8EAAmE;AACnE,sFAA2E;AAC3E,yGAA8F;AAC9F,2EAAiE;AACjE,iFAAuE;AACvE,+GAAmG;AACnG,yFAA8E;AAC9E,+EAAqE;AACrE,6FAAkF;AAClF,qFAA0E;AAC1E,6FAAkF;AAClF,uEAA6D;AAC7D,mGAAuF;AACvF,mGAAwF;AACxF,2EAAiE;AAE1D,MAAM,mBAAmB,GAAG,CACjC,aAA4B,EACN,EAAE;IACxB,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAU,cAAc,EAAE,KAAK,CAAC,CAAC;IAErE,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC;QAC9C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK;QACvD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;QAC/D,QAAQ,EAAE;YACR,kBAAI;YACJ,sBAAM;YACN,6CAAiB;YACjB,uCAAc;YACd,4CAAgB;YAChB,yBAAO;YACP,iCAAW;YACX,wBAAO;YACP,0BAAQ;YACR,oBAAK;YACL,qCAAa;YACb,iCAAW;YACX,iDAAmB;YACnB,sDAAqB;YACrB,+BAAU;SACX;QACD,gBAAgB,EAAE,KAAK;QACvB,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,mBAAmB,uBA8B9B;AAEW,QAAA,oBAAoB,GAA8B;IAC7D,OAAO,EAAE,CAAC,qBAAY,CAAC;IACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;IACvB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,IAAA,2BAAmB,EAAC,aAAa,CAAC;CACjF,CAAC"}
|
||||
1
dist/main.d.ts
vendored
1
dist/main.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export {};
|
||||
32
dist/main.js
vendored
32
dist/main.js
vendored
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const app_module_1 = require("./app.module");
|
||||
const response_interceptor_1 = require("./common/interceptors/response.interceptor");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||
const reflector = app.get(core_1.Reflector);
|
||||
app.setGlobalPrefix('api');
|
||||
app.useGlobalPipes(new common_1.ValidationPipe({
|
||||
whitelist: true,
|
||||
transform: true,
|
||||
forbidNonWhitelisted: true,
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
}));
|
||||
app.useGlobalInterceptors(new response_interceptor_1.ResponseInterceptor(reflector));
|
||||
const swaggerConfig = new swagger_1.DocumentBuilder()
|
||||
.setTitle('ParsShop API')
|
||||
.setDescription('Phase 1 API documentation for ParsShop')
|
||||
.setVersion('1.0.0')
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
const swaggerDocument = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
|
||||
swagger_1.SwaggerModule.setup('docs', app, swaggerDocument);
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
||||
1
dist/main.js.map
vendored
1
dist/main.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,2CAAgD;AAChD,uCAAsD;AACtD,6CAAiE;AACjE,6CAAyC;AACzC,qFAAiF;AAEjF,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,gBAAS,CAAC,CAAC;IAErC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3B,GAAG,CAAC,cAAc,CAChB,IAAI,uBAAc,CAAC;QACjB,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;QACf,oBAAoB,EAAE,IAAI;QAC1B,gBAAgB,EAAE;YAChB,wBAAwB,EAAE,IAAI;SAC/B;KACF,CAAC,CACH,CAAC;IACF,GAAG,CAAC,qBAAqB,CAAC,IAAI,0CAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;IAE9D,MAAM,aAAa,GAAG,IAAI,yBAAe,EAAE;SACxC,QAAQ,CAAC,cAAc,CAAC;SACxB,cAAc,CAAC,wCAAwC,CAAC;SACxD,UAAU,CAAC,OAAO,CAAC;SACnB,aAAa,EAAE;SACf,KAAK,EAAE,CAAC;IACX,MAAM,eAAe,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACzE,uBAAa,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC;IAElD,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,EAAE,CAAC"}
|
||||
75
dist/modules/auth/auth.controller.d.ts
vendored
75
dist/modules/auth/auth.controller.d.ts
vendored
@@ -1,75 +0,0 @@
|
||||
import { Request } from 'express';
|
||||
import { UserRole } from '../users/enums/user-role.enum';
|
||||
import { AuthService } from './auth.service';
|
||||
import { LoginPasswordDto } from './dto/login-password.dto';
|
||||
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
||||
import { RegisterPasswordDto } from './dto/register-password.dto';
|
||||
import { RequestOtpDto } from './dto/request-otp.dto';
|
||||
import { VerifyOtpDto } from './dto/verify-otp.dto';
|
||||
import { JwtPayload } from './interfaces/jwt-payload.interface';
|
||||
export declare class AuthController {
|
||||
private readonly authService;
|
||||
constructor(authService: AuthService);
|
||||
requestOtp(dto: RequestOtpDto): Promise<{
|
||||
message: string;
|
||||
expiresInSeconds: number;
|
||||
phone: string;
|
||||
smsSent: boolean;
|
||||
otpPreview: string | undefined;
|
||||
}>;
|
||||
registerWithPassword(dto: RegisterPasswordDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: import("../users/enums/user-level.enum").UserLevel;
|
||||
};
|
||||
}>;
|
||||
loginWithPassword(dto: LoginPasswordDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: import("../users/enums/user-level.enum").UserLevel;
|
||||
};
|
||||
}>;
|
||||
verifyOtp(dto: VerifyOtpDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: import("../users/enums/user-level.enum").UserLevel;
|
||||
};
|
||||
}>;
|
||||
refresh(dto: RefreshTokenDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: import("../users/enums/user-level.enum").UserLevel;
|
||||
};
|
||||
}>;
|
||||
logout(request: Request & {
|
||||
user: JwtPayload;
|
||||
}): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
adminCheck(request: Request & {
|
||||
user: JwtPayload;
|
||||
}): {
|
||||
user: Express.User & JwtPayload;
|
||||
authorized: boolean;
|
||||
};
|
||||
}
|
||||
121
dist/modules/auth/auth.controller.js
vendored
121
dist/modules/auth/auth.controller.js
vendored
@@ -1,121 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const permissions_decorator_1 = require("../../common/decorators/permissions.decorator");
|
||||
const roles_decorator_1 = require("../../common/decorators/roles.decorator");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const login_password_dto_1 = require("./dto/login-password.dto");
|
||||
const refresh_token_dto_1 = require("./dto/refresh-token.dto");
|
||||
const register_password_dto_1 = require("./dto/register-password.dto");
|
||||
const request_otp_dto_1 = require("./dto/request-otp.dto");
|
||||
const verify_otp_dto_1 = require("./dto/verify-otp.dto");
|
||||
const jwt_auth_guard_1 = require("./guards/jwt-auth.guard");
|
||||
let AuthController = class AuthController {
|
||||
authService;
|
||||
constructor(authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
requestOtp(dto) {
|
||||
return this.authService.requestOtp(dto.phone, dto.fullName);
|
||||
}
|
||||
registerWithPassword(dto) {
|
||||
return this.authService.registerWithPassword(dto);
|
||||
}
|
||||
loginWithPassword(dto) {
|
||||
return this.authService.loginWithPassword(dto);
|
||||
}
|
||||
verifyOtp(dto) {
|
||||
return this.authService.verifyOtp(dto.phone, dto.otp);
|
||||
}
|
||||
refresh(dto) {
|
||||
return this.authService.refreshToken(dto.refreshToken);
|
||||
}
|
||||
logout(request) {
|
||||
return this.authService.logout(request.user.sub);
|
||||
}
|
||||
adminCheck(request) {
|
||||
return {
|
||||
user: request.user,
|
||||
authorized: true,
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.AuthController = AuthController;
|
||||
__decorate([
|
||||
(0, common_1.Post)('otp/request'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [request_otp_dto_1.RequestOtpDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "requestOtp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('register/password'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [register_password_dto_1.RegisterPasswordDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "registerWithPassword", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('login/password'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [login_password_dto_1.LoginPasswordDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "loginWithPassword", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('otp/verify'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [verify_otp_dto_1.VerifyOtpDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "verifyOtp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('refresh'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [refresh_token_dto_1.RefreshTokenDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "refresh", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, common_1.Post)('logout'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "logout", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('users.manage'),
|
||||
(0, common_1.Get)('me/admin-check'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthController.prototype, "adminCheck", null);
|
||||
exports.AuthController = AuthController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Auth'),
|
||||
(0, common_1.Controller)('auth'),
|
||||
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
||||
], AuthController);
|
||||
//# sourceMappingURL=auth.controller.js.map
|
||||
1
dist/modules/auth/auth.controller.js.map
vendored
1
dist/modules/auth/auth.controller.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAOwB;AAExB,6CAAyD;AACzD,yFAA4E;AAC5E,6EAAgE;AAChE,6EAAyE;AACzE,iEAA6D;AAC7D,kEAAyD;AACzD,iDAA6C;AAC7C,iEAA4D;AAC5D,+DAA0D;AAC1D,uEAAkE;AAClE,2DAAsD;AACtD,yDAAoD;AACpD,4DAAuD;AAKhD,IAAM,cAAc,GAApB,MAAM,cAAc;IACI;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAGzD,UAAU,CAAS,GAAkB;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAGD,oBAAoB,CAAS,GAAwB;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAGD,iBAAiB,CAAS,GAAqB;QAC7C,OAAO,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAGD,SAAS,CAAS,GAAiB;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;IAGD,OAAO,CAAS,GAAoB;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAKD,MAAM,CAAQ,OAAuC;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IAOD,UAAU,CAAQ,OAAuC;QACvD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,IAAI;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AA9CY,wCAAc;AAIzB;IADC,IAAA,aAAI,EAAC,aAAa,CAAC;IACR,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,+BAAa;;gDAEpC;AAGD;IADC,IAAA,aAAI,EAAC,mBAAmB,CAAC;IACJ,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,2CAAmB;;0DAEpD;AAGD;IADC,IAAA,aAAI,EAAC,gBAAgB,CAAC;IACJ,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,qCAAgB;;uDAE9C;AAGD;IADC,IAAA,aAAI,EAAC,YAAY,CAAC;IACR,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,6BAAY;;+CAElC;AAGD;IADC,IAAA,aAAI,EAAC,SAAS,CAAC;IACP,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,mCAAe;;6CAEnC;AAKD;IAHC,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACvB,IAAA,uBAAa,GAAE;IACf,IAAA,aAAI,EAAC,QAAQ,CAAC;IACP,WAAA,IAAA,YAAG,GAAE,CAAA;;;;4CAEZ;AAOD;IALC,IAAA,kBAAS,EAAC,6BAAY,EAAE,wBAAU,EAAE,oCAAgB,CAAC;IACrD,IAAA,uBAAa,GAAE;IACf,IAAA,uBAAK,EAAC,yBAAQ,CAAC,KAAK,CAAC;IACrB,IAAA,mCAAW,EAAC,cAAc,CAAC;IAC3B,IAAA,YAAG,EAAC,gBAAgB,CAAC;IACV,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAKhB;yBA7CU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAEyB,0BAAW;GAD1C,cAAc,CA8C1B"}
|
||||
2
dist/modules/auth/auth.module.d.ts
vendored
2
dist/modules/auth/auth.module.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
export declare class AuthModule {
|
||||
}
|
||||
47
dist/modules/auth/auth.module.js
vendored
47
dist/modules/auth/auth.module.js
vendored
@@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const auth_controller_1 = require("./auth.controller");
|
||||
const auth_service_1 = require("./auth.service");
|
||||
const auth_otp_entity_1 = require("./entities/auth-otp.entity");
|
||||
const user_session_entity_1 = require("./entities/user-session.entity");
|
||||
const sms_service_1 = require("./sms.service");
|
||||
const jwt_strategy_1 = require("./strategies/jwt.strategy");
|
||||
const users_module_1 = require("../users/users.module");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
let AuthModule = class AuthModule {
|
||||
};
|
||||
exports.AuthModule = AuthModule;
|
||||
exports.AuthModule = AuthModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
users_module_1.UsersModule,
|
||||
passport_1.PassportModule,
|
||||
config_1.ConfigModule,
|
||||
typeorm_1.TypeOrmModule.forFeature([auth_otp_entity_1.AuthOtp, user_session_entity_1.UserSession]),
|
||||
jwt_1.JwtModule.registerAsync({
|
||||
imports: [config_1.ConfigModule],
|
||||
inject: [config_1.ConfigService],
|
||||
useFactory: (configService) => ({
|
||||
secret: configService.getOrThrow('jwt.secret'),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
controllers: [auth_controller_1.AuthController],
|
||||
providers: [auth_service_1.AuthService, sms_service_1.SmsService, jwt_strategy_1.JwtStrategy, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard],
|
||||
exports: [auth_service_1.AuthService],
|
||||
})
|
||||
], AuthModule);
|
||||
//# sourceMappingURL=auth.module.js.map
|
||||
1
dist/modules/auth/auth.module.js.map
vendored
1
dist/modules/auth/auth.module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAA6D;AAC7D,qCAAwC;AACxC,+CAAkD;AAClD,6CAAgD;AAChD,uDAAmD;AACnD,iDAA6C;AAC7C,gEAAqD;AACrD,wEAA6D;AAC7D,+CAA2C;AAC3C,4DAAwD;AACxD,wDAAoD;AACpD,iEAA6D;AAC7D,6EAAyE;AAoBlE,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAlBtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,0BAAW;YACX,yBAAc;YACd,qBAAY;YACZ,uBAAa,CAAC,UAAU,CAAC,CAAC,yBAAO,EAAE,iCAAW,CAAC,CAAC;YAChD,eAAS,CAAC,aAAa,CAAC;gBACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC;oBAC7C,MAAM,EAAE,aAAa,CAAC,UAAU,CAAS,YAAY,CAAC;iBACvD,CAAC;aACH,CAAC;SACH;QACD,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,EAAE,wBAAU,EAAE,0BAAW,EAAE,wBAAU,EAAE,oCAAgB,CAAC;QAC/E,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}
|
||||
81
dist/modules/auth/auth.service.d.ts
vendored
81
dist/modules/auth/auth.service.d.ts
vendored
@@ -1,81 +0,0 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Repository } from 'typeorm';
|
||||
import { AuthOtp } from './entities/auth-otp.entity';
|
||||
import { UserSession } from './entities/user-session.entity';
|
||||
import { UserLevel } from '../users/enums/user-level.enum';
|
||||
import { UserRole } from '../users/enums/user-role.enum';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { LoginPasswordDto } from './dto/login-password.dto';
|
||||
import { RegisterPasswordDto } from './dto/register-password.dto';
|
||||
import { SmsService } from './sms.service';
|
||||
export declare class AuthService {
|
||||
private readonly usersService;
|
||||
private readonly jwtService;
|
||||
private readonly configService;
|
||||
private readonly smsService;
|
||||
private readonly authOtpsRepository;
|
||||
private readonly userSessionsRepository;
|
||||
constructor(usersService: UsersService, jwtService: JwtService, configService: ConfigService, smsService: SmsService, authOtpsRepository: Repository<AuthOtp>, userSessionsRepository: Repository<UserSession>);
|
||||
requestOtp(phone: string, fullName?: string): Promise<{
|
||||
message: string;
|
||||
expiresInSeconds: number;
|
||||
phone: string;
|
||||
smsSent: boolean;
|
||||
otpPreview: string | undefined;
|
||||
}>;
|
||||
registerWithPassword(dto: RegisterPasswordDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: UserLevel;
|
||||
};
|
||||
}>;
|
||||
loginWithPassword(dto: LoginPasswordDto): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: UserLevel;
|
||||
};
|
||||
}>;
|
||||
verifyOtp(phone: string, otp: string): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: UserLevel;
|
||||
};
|
||||
}>;
|
||||
refreshToken(refreshToken: string): Promise<{
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: {
|
||||
id: string;
|
||||
phone: string;
|
||||
fullName: string;
|
||||
role: UserRole;
|
||||
level: UserLevel;
|
||||
};
|
||||
}>;
|
||||
logout(userId: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
private issueTokens;
|
||||
private storeRefreshToken;
|
||||
private generateOtp;
|
||||
private resolvePermissions;
|
||||
private findUserById;
|
||||
private findMatchingSession;
|
||||
private parseDurationToMs;
|
||||
}
|
||||
276
dist/modules/auth/auth.service.js
vendored
276
dist/modules/auth/auth.service.js
vendored
@@ -1,276 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const jwt_1 = require("@nestjs/jwt");
|
||||
const bcrypt = require("bcryptjs");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const auth_otp_entity_1 = require("./entities/auth-otp.entity");
|
||||
const user_session_entity_1 = require("./entities/user-session.entity");
|
||||
const user_level_enum_1 = require("../users/enums/user-level.enum");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const users_service_1 = require("../users/users.service");
|
||||
const sms_service_1 = require("./sms.service");
|
||||
let AuthService = class AuthService {
|
||||
usersService;
|
||||
jwtService;
|
||||
configService;
|
||||
smsService;
|
||||
authOtpsRepository;
|
||||
userSessionsRepository;
|
||||
constructor(usersService, jwtService, configService, smsService, authOtpsRepository, userSessionsRepository) {
|
||||
this.usersService = usersService;
|
||||
this.jwtService = jwtService;
|
||||
this.configService = configService;
|
||||
this.smsService = smsService;
|
||||
this.authOtpsRepository = authOtpsRepository;
|
||||
this.userSessionsRepository = userSessionsRepository;
|
||||
}
|
||||
async requestOtp(phone, fullName) {
|
||||
const user = await this.usersService.findOrCreateByPhone(phone, fullName);
|
||||
const otpCode = this.generateOtp();
|
||||
const ttlSeconds = this.configService.get('otp.ttlSeconds', 120);
|
||||
const otp = this.authOtpsRepository.create({
|
||||
phone: user.phone,
|
||||
codeHash: await bcrypt.hash(otpCode, 10),
|
||||
purpose: 'login',
|
||||
expiresAt: new Date(Date.now() + ttlSeconds * 1000),
|
||||
attemptCount: 0,
|
||||
});
|
||||
await this.authOtpsRepository.save(otp);
|
||||
const smsSent = await this.smsService.sendOtp(phone, otpCode);
|
||||
return {
|
||||
message: 'OTP generated successfully',
|
||||
expiresInSeconds: ttlSeconds,
|
||||
phone,
|
||||
smsSent,
|
||||
otpPreview: this.configService.get('app.nodeEnv') === 'development'
|
||||
? otpCode
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
async registerWithPassword(dto) {
|
||||
const existingPhone = await this.usersService.findByPhone(dto.phone);
|
||||
if (existingPhone) {
|
||||
throw new common_1.BadRequestException('Phone already exists');
|
||||
}
|
||||
const existingUsername = await this.usersService.findByUsername(dto.username);
|
||||
if (existingUsername) {
|
||||
throw new common_1.BadRequestException('Username already exists');
|
||||
}
|
||||
const savedUser = await this.usersService.create({
|
||||
phone: dto.phone,
|
||||
username: dto.username,
|
||||
fullName: dto.fullName ?? dto.username,
|
||||
passwordHash: await bcrypt.hash(dto.password, 10),
|
||||
isVerified: true,
|
||||
role: user_role_enum_1.UserRole.USER,
|
||||
});
|
||||
const tokens = await this.issueTokens(savedUser);
|
||||
await this.storeRefreshToken(savedUser, tokens.refreshToken);
|
||||
return tokens;
|
||||
}
|
||||
async loginWithPassword(dto) {
|
||||
const user = await this.usersService.findByUsername(dto.username);
|
||||
if (!user?.passwordHash) {
|
||||
throw new common_1.UnauthorizedException('Invalid username or password');
|
||||
}
|
||||
const isPasswordValid = await bcrypt.compare(dto.password, user.passwordHash);
|
||||
if (!isPasswordValid) {
|
||||
throw new common_1.UnauthorizedException('Invalid username or password');
|
||||
}
|
||||
const tokens = await this.issueTokens(user);
|
||||
await this.storeRefreshToken(user, tokens.refreshToken);
|
||||
return tokens;
|
||||
}
|
||||
async verifyOtp(phone, otp) {
|
||||
const user = await this.usersService.findByPhone(phone);
|
||||
const otpRecord = await this.authOtpsRepository.findOne({
|
||||
where: { phone, purpose: 'login', usedAt: (0, typeorm_2.IsNull)() },
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
if (!user || !otpRecord) {
|
||||
throw new common_1.UnauthorizedException('OTP not requested');
|
||||
}
|
||||
if (otpRecord.expiresAt.getTime() < Date.now()) {
|
||||
throw new common_1.UnauthorizedException('OTP expired');
|
||||
}
|
||||
const isOtpValid = await bcrypt.compare(otp, otpRecord.codeHash);
|
||||
if (!isOtpValid) {
|
||||
otpRecord.attemptCount += 1;
|
||||
await this.authOtpsRepository.save(otpRecord);
|
||||
throw new common_1.BadRequestException('Invalid OTP');
|
||||
}
|
||||
user.isVerified = true;
|
||||
otpRecord.usedAt = new Date();
|
||||
await Promise.all([
|
||||
this.usersService.save(user),
|
||||
this.authOtpsRepository.save(otpRecord),
|
||||
]);
|
||||
const tokens = await this.issueTokens(user);
|
||||
await this.storeRefreshToken(user, tokens.refreshToken);
|
||||
return tokens;
|
||||
}
|
||||
async refreshToken(refreshToken) {
|
||||
const payload = await this.jwtService.verifyAsync(refreshToken, {
|
||||
secret: this.configService.getOrThrow('jwt.secret'),
|
||||
});
|
||||
if (payload.type !== 'refresh') {
|
||||
throw new common_1.UnauthorizedException('Invalid token type');
|
||||
}
|
||||
const user = await this.usersService.findByPhone(payload.phone);
|
||||
if (!user) {
|
||||
throw new common_1.UnauthorizedException('Refresh token not found');
|
||||
}
|
||||
const sessions = await this.userSessionsRepository.find({
|
||||
where: {
|
||||
user: { id: user.id },
|
||||
revokedAt: (0, typeorm_2.IsNull)(),
|
||||
},
|
||||
relations: { user: true },
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
const validSession = await this.findMatchingSession(sessions, refreshToken);
|
||||
if (!validSession || validSession.expiresAt.getTime() < Date.now()) {
|
||||
throw new common_1.UnauthorizedException('Invalid refresh token');
|
||||
}
|
||||
validSession.revokedAt = new Date();
|
||||
await this.userSessionsRepository.save(validSession);
|
||||
const tokens = await this.issueTokens(user);
|
||||
await this.storeRefreshToken(user, tokens.refreshToken);
|
||||
return tokens;
|
||||
}
|
||||
async logout(userId) {
|
||||
const user = await this.findUserById(userId);
|
||||
await this.userSessionsRepository
|
||||
.createQueryBuilder()
|
||||
.update(user_session_entity_1.UserSession)
|
||||
.set({ revokedAt: new Date() })
|
||||
.where('userId = :userId', { userId: user.id })
|
||||
.andWhere('revoked_at IS NULL')
|
||||
.execute();
|
||||
return { message: 'Logged out successfully' };
|
||||
}
|
||||
async issueTokens(user) {
|
||||
const currentLevel = user.loyaltyProfile?.currentLevel ?? user_level_enum_1.UserLevel.BRONZE;
|
||||
const accessPayload = {
|
||||
sub: user.id,
|
||||
phone: user.phone,
|
||||
role: user.role,
|
||||
level: currentLevel,
|
||||
permissions: this.resolvePermissions(user),
|
||||
type: 'access',
|
||||
};
|
||||
const refreshPayload = {
|
||||
...accessPayload,
|
||||
type: 'refresh',
|
||||
};
|
||||
const [accessToken, refreshToken] = await Promise.all([
|
||||
this.jwtService.signAsync(accessPayload, {
|
||||
secret: this.configService.getOrThrow('jwt.secret'),
|
||||
expiresIn: this.configService.getOrThrow('jwt.accessTtl'),
|
||||
}),
|
||||
this.jwtService.signAsync(refreshPayload, {
|
||||
secret: this.configService.getOrThrow('jwt.secret'),
|
||||
expiresIn: this.configService.getOrThrow('jwt.refreshTtl'),
|
||||
}),
|
||||
]);
|
||||
return {
|
||||
accessToken,
|
||||
refreshToken,
|
||||
user: {
|
||||
id: user.id,
|
||||
phone: user.phone,
|
||||
fullName: user.fullName,
|
||||
role: user.role,
|
||||
level: currentLevel,
|
||||
},
|
||||
};
|
||||
}
|
||||
async storeRefreshToken(user, refreshToken) {
|
||||
const refreshTtl = this.configService.getOrThrow('jwt.refreshTtl');
|
||||
const session = this.userSessionsRepository.create({
|
||||
user,
|
||||
refreshTokenHash: await bcrypt.hash(refreshToken, 10),
|
||||
expiresAt: new Date(Date.now() + this.parseDurationToMs(refreshTtl)),
|
||||
});
|
||||
await this.userSessionsRepository.save(session);
|
||||
}
|
||||
generateOtp() {
|
||||
return Math.floor(100000 + Math.random() * 900000).toString();
|
||||
}
|
||||
resolvePermissions(user) {
|
||||
if (user.role === user_role_enum_1.UserRole.ADMIN) {
|
||||
return [
|
||||
'products.manage',
|
||||
'categories.manage',
|
||||
'brands.manage',
|
||||
'users.manage',
|
||||
'media.manage',
|
||||
];
|
||||
}
|
||||
if (user.role === user_role_enum_1.UserRole.AGENT) {
|
||||
return ['orders.assist', 'customers.assist'];
|
||||
}
|
||||
return ['profile.read'];
|
||||
}
|
||||
async findUserById(userId) {
|
||||
const user = await this.usersService.findById(userId);
|
||||
if (!user) {
|
||||
throw new common_1.UnauthorizedException('User not found');
|
||||
}
|
||||
return user;
|
||||
}
|
||||
async findMatchingSession(sessions, refreshToken) {
|
||||
for (const session of sessions) {
|
||||
const isValid = await bcrypt.compare(refreshToken, session.refreshTokenHash);
|
||||
if (isValid) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
parseDurationToMs(value) {
|
||||
const match = /^(\d+)(ms|s|m|h|d)$/i.exec(value);
|
||||
if (!match) {
|
||||
throw new common_1.BadRequestException(`Unsupported duration format: ${value}`);
|
||||
}
|
||||
const amount = Number(match[1]);
|
||||
const unit = match[2].toLowerCase();
|
||||
const unitMap = {
|
||||
ms: 1,
|
||||
s: 1000,
|
||||
m: 60 * 1000,
|
||||
h: 60 * 60 * 1000,
|
||||
d: 24 * 60 * 60 * 1000,
|
||||
};
|
||||
return amount * unitMap[unit];
|
||||
}
|
||||
};
|
||||
exports.AuthService = AuthService;
|
||||
exports.AuthService = AuthService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(4, (0, typeorm_1.InjectRepository)(auth_otp_entity_1.AuthOtp)),
|
||||
__param(5, (0, typeorm_1.InjectRepository)(user_session_entity_1.UserSession)),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService,
|
||||
jwt_1.JwtService,
|
||||
config_1.ConfigService,
|
||||
sms_service_1.SmsService,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository])
|
||||
], AuthService);
|
||||
//# sourceMappingURL=auth.service.js.map
|
||||
1
dist/modules/auth/auth.service.js.map
vendored
1
dist/modules/auth/auth.service.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
export declare class LoginPasswordDto {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
31
dist/modules/auth/dto/login-password.dto.js
vendored
31
dist/modules/auth/dto/login-password.dto.js
vendored
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LoginPasswordDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class LoginPasswordDto {
|
||||
username;
|
||||
password;
|
||||
}
|
||||
exports.LoginPasswordDto = LoginPasswordDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(3),
|
||||
(0, class_validator_1.MaxLength)(50),
|
||||
__metadata("design:type", String)
|
||||
], LoginPasswordDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(6),
|
||||
(0, class_validator_1.MaxLength)(100),
|
||||
__metadata("design:type", String)
|
||||
], LoginPasswordDto.prototype, "password", void 0);
|
||||
//# sourceMappingURL=login-password.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"login-password.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/login-password.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiE;AAEjE,MAAa,gBAAgB;IAI3B,QAAQ,CAAS;IAKjB,QAAQ,CAAS;CAClB;AAVD,4CAUC;AANC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,EAAE,CAAC;;kDACG;AAKjB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,GAAG,CAAC;;kDACE"}
|
||||
3
dist/modules/auth/dto/refresh-token.dto.d.ts
vendored
3
dist/modules/auth/dto/refresh-token.dto.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
export declare class RefreshTokenDto {
|
||||
refreshToken: string;
|
||||
}
|
||||
23
dist/modules/auth/dto/refresh-token.dto.js
vendored
23
dist/modules/auth/dto/refresh-token.dto.js
vendored
@@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RefreshTokenDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class RefreshTokenDto {
|
||||
refreshToken;
|
||||
}
|
||||
exports.RefreshTokenDto = RefreshTokenDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(10),
|
||||
__metadata("design:type", String)
|
||||
], RefreshTokenDto.prototype, "refreshToken", void 0);
|
||||
//# sourceMappingURL=refresh-token.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"refresh-token.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/refresh-token.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsD;AAEtD,MAAa,eAAe;IAG1B,YAAY,CAAS;CACtB;AAJD,0CAIC;AADC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,EAAE,CAAC;;qDACO"}
|
||||
@@ -1,6 +0,0 @@
|
||||
export declare class RegisterPasswordDto {
|
||||
phone: string;
|
||||
username: string;
|
||||
password: string;
|
||||
fullName?: string;
|
||||
}
|
||||
44
dist/modules/auth/dto/register-password.dto.js
vendored
44
dist/modules/auth/dto/register-password.dto.js
vendored
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RegisterPasswordDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class RegisterPasswordDto {
|
||||
phone;
|
||||
username;
|
||||
password;
|
||||
fullName;
|
||||
}
|
||||
exports.RegisterPasswordDto = RegisterPasswordDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.Matches)(/^\+?[1-9]\d{7,14}$/),
|
||||
__metadata("design:type", String)
|
||||
], RegisterPasswordDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(3),
|
||||
(0, class_validator_1.MaxLength)(50),
|
||||
__metadata("design:type", String)
|
||||
], RegisterPasswordDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(6),
|
||||
(0, class_validator_1.MaxLength)(100),
|
||||
__metadata("design:type", String)
|
||||
], RegisterPasswordDto.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(2),
|
||||
(0, class_validator_1.MaxLength)(150),
|
||||
__metadata("design:type", String)
|
||||
], RegisterPasswordDto.prototype, "fullName", void 0);
|
||||
//# sourceMappingURL=register-password.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"register-password.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/register-password.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsF;AAEtF,MAAa,mBAAmB;IAE9B,KAAK,CAAS;IAKd,QAAQ,CAAS;IAKjB,QAAQ,CAAS;IAMjB,QAAQ,CAAU;CACnB;AAnBD,kDAmBC;AAjBC;IADC,IAAA,yBAAO,EAAC,oBAAoB,CAAC;;kDAChB;AAKd;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,EAAE,CAAC;;qDACG;AAKjB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,GAAG,CAAC;;qDACE;AAMjB;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,GAAG,CAAC;;qDACG"}
|
||||
4
dist/modules/auth/dto/request-otp.dto.d.ts
vendored
4
dist/modules/auth/dto/request-otp.dto.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
export declare class RequestOtpDto {
|
||||
phone: string;
|
||||
fullName?: string;
|
||||
}
|
||||
30
dist/modules/auth/dto/request-otp.dto.js
vendored
30
dist/modules/auth/dto/request-otp.dto.js
vendored
@@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RequestOtpDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class RequestOtpDto {
|
||||
phone;
|
||||
fullName;
|
||||
}
|
||||
exports.RequestOtpDto = RequestOtpDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.Matches)(/^\+?[1-9]\d{7,14}$/),
|
||||
__metadata("design:type", String)
|
||||
], RequestOtpDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(2),
|
||||
(0, class_validator_1.MaxLength)(150),
|
||||
__metadata("design:type", String)
|
||||
], RequestOtpDto.prototype, "fullName", void 0);
|
||||
//# sourceMappingURL=request-otp.dto.js.map
|
||||
1
dist/modules/auth/dto/request-otp.dto.js.map
vendored
1
dist/modules/auth/dto/request-otp.dto.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"request-otp.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/request-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsF;AAEtF,MAAa,aAAa;IAExB,KAAK,CAAS;IAMd,QAAQ,CAAU;CACnB;AATD,sCASC;AAPC;IADC,IAAA,yBAAO,EAAC,oBAAoB,CAAC;;4CAChB;AAMd;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,GAAG,CAAC;;+CACG"}
|
||||
4
dist/modules/auth/dto/verify-otp.dto.d.ts
vendored
4
dist/modules/auth/dto/verify-otp.dto.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
export declare class VerifyOtpDto {
|
||||
phone: string;
|
||||
otp: string;
|
||||
}
|
||||
28
dist/modules/auth/dto/verify-otp.dto.js
vendored
28
dist/modules/auth/dto/verify-otp.dto.js
vendored
@@ -1,28 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VerifyOtpDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class VerifyOtpDto {
|
||||
phone;
|
||||
otp;
|
||||
}
|
||||
exports.VerifyOtpDto = VerifyOtpDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.Matches)(/^\+?[1-9]\d{7,14}$/),
|
||||
__metadata("design:type", String)
|
||||
], VerifyOtpDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.Length)(4, 6),
|
||||
__metadata("design:type", String)
|
||||
], VerifyOtpDto.prototype, "otp", void 0);
|
||||
//# sourceMappingURL=verify-otp.dto.js.map
|
||||
1
dist/modules/auth/dto/verify-otp.dto.js.map
vendored
1
dist/modules/auth/dto/verify-otp.dto.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"verify-otp.dto.js","sourceRoot":"","sources":["../../../../src/modules/auth/dto/verify-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4D;AAE5D,MAAa,YAAY;IAEvB,KAAK,CAAS;IAId,GAAG,CAAS;CACb;AAPD,oCAOC;AALC;IADC,IAAA,yBAAO,EAAC,oBAAoB,CAAC;;2CAChB;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAM,EAAC,CAAC,EAAE,CAAC,CAAC;;yCACD"}
|
||||
11
dist/modules/auth/entities/auth-otp.entity.d.ts
vendored
11
dist/modules/auth/entities/auth-otp.entity.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
export declare class AuthOtp {
|
||||
id: string;
|
||||
phone: string;
|
||||
codeHash: string;
|
||||
purpose: string;
|
||||
expiresAt: Date;
|
||||
usedAt?: Date | null;
|
||||
attemptCount: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
66
dist/modules/auth/entities/auth-otp.entity.js
vendored
66
dist/modules/auth/entities/auth-otp.entity.js
vendored
@@ -1,66 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthOtp = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
let AuthOtp = class AuthOtp {
|
||||
id;
|
||||
phone;
|
||||
codeHash;
|
||||
purpose;
|
||||
expiresAt;
|
||||
usedAt;
|
||||
attemptCount;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
};
|
||||
exports.AuthOtp = AuthOtp;
|
||||
__decorate([
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
||||
__metadata("design:type", String)
|
||||
], AuthOtp.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Index)(),
|
||||
(0, typeorm_1.Column)({ length: 20 }),
|
||||
__metadata("design:type", String)
|
||||
], AuthOtp.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'code_hash', length: 255 }),
|
||||
__metadata("design:type", String)
|
||||
], AuthOtp.prototype, "codeHash", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ length: 30, default: 'login' }),
|
||||
__metadata("design:type", String)
|
||||
], AuthOtp.prototype, "purpose", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'expires_at', type: 'timestamp with time zone' }),
|
||||
__metadata("design:type", Date)
|
||||
], AuthOtp.prototype, "expiresAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'used_at', type: 'timestamp with time zone', nullable: true }),
|
||||
__metadata("design:type", Object)
|
||||
], AuthOtp.prototype, "usedAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'attempt_count', type: 'int', default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], AuthOtp.prototype, "attemptCount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
|
||||
__metadata("design:type", Date)
|
||||
], AuthOtp.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
|
||||
__metadata("design:type", Date)
|
||||
], AuthOtp.prototype, "updatedAt", void 0);
|
||||
exports.AuthOtp = AuthOtp = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'auth_otps' })
|
||||
], AuthOtp);
|
||||
//# sourceMappingURL=auth-otp.entity.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"auth-otp.entity.js","sourceRoot":"","sources":["../../../../src/modules/auth/entities/auth-otp.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AAGV,IAAM,OAAO,GAAb,MAAM,OAAO;IAElB,EAAE,CAAS;IAIX,KAAK,CAAS;IAGd,QAAQ,CAAS;IAGjB,OAAO,CAAS;IAGhB,SAAS,CAAO;IAGhB,MAAM,CAAe;IAGrB,YAAY,CAAS;IAGrB,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AA5BY,0BAAO;AAElB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;mCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;sCACT;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;yCAC1B;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;;wCACzB;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;8BACtD,IAAI;0CAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACzD;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6CACtC;AAGrB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;0CAAC;AAGhB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;0CAAC;kBA3BL,OAAO;IADnB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;GACjB,OAAO,CA4BnB"}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
export declare class UserSession {
|
||||
id: string;
|
||||
user: User;
|
||||
refreshTokenHash: string;
|
||||
expiresAt: Date;
|
||||
revokedAt?: Date | null;
|
||||
deviceInfo?: string | null;
|
||||
ipAddress?: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserSession = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const user_entity_1 = require("../../users/entities/user.entity");
|
||||
let UserSession = class UserSession {
|
||||
id;
|
||||
user;
|
||||
refreshTokenHash;
|
||||
expiresAt;
|
||||
revokedAt;
|
||||
deviceInfo;
|
||||
ipAddress;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
};
|
||||
exports.UserSession = UserSession;
|
||||
__decorate([
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
||||
__metadata("design:type", String)
|
||||
], UserSession.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Index)(),
|
||||
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.sessions, { onDelete: 'CASCADE' }),
|
||||
__metadata("design:type", user_entity_1.User)
|
||||
], UserSession.prototype, "user", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'refresh_token_hash', length: 255 }),
|
||||
__metadata("design:type", String)
|
||||
], UserSession.prototype, "refreshTokenHash", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'expires_at', type: 'timestamp with time zone' }),
|
||||
__metadata("design:type", Date)
|
||||
], UserSession.prototype, "expiresAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'revoked_at', type: 'timestamp with time zone', nullable: true }),
|
||||
__metadata("design:type", Object)
|
||||
], UserSession.prototype, "revokedAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'device_info', type: 'varchar', length: 255, nullable: true }),
|
||||
__metadata("design:type", Object)
|
||||
], UserSession.prototype, "deviceInfo", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'ip_address', type: 'varchar', length: 64, nullable: true }),
|
||||
__metadata("design:type", Object)
|
||||
], UserSession.prototype, "ipAddress", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
|
||||
__metadata("design:type", Date)
|
||||
], UserSession.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
|
||||
__metadata("design:type", Date)
|
||||
], UserSession.prototype, "updatedAt", void 0);
|
||||
exports.UserSession = UserSession = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'user_sessions' })
|
||||
], UserSession);
|
||||
//# sourceMappingURL=user-session.entity.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"user-session.entity.js","sourceRoot":"","sources":["../../../../src/modules/auth/entities/user-session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAQiB;AACjB,kEAAwD;AAGjD,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,EAAE,CAAS;IAIX,IAAI,CAAO;IAGX,gBAAgB,CAAS;IAGzB,SAAS,CAAO;IAGhB,SAAS,CAAe;IAGxB,UAAU,CAAiB;IAG3B,SAAS,CAAiB;IAG1B,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AA5BY,kCAAW;AAEtB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;uCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;8BAClE,kBAAI;yCAAC;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;qDAC3B;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;8BACtD,IAAI;8CAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACzD;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACnD;AAG3B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAClD;AAG1B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;8CAAC;AAGhB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;8CAAC;sBA3BL,WAAW;IADvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;GACrB,WAAW,CA4BvB"}
|
||||
4
dist/modules/auth/guards/jwt-auth.guard.d.ts
vendored
4
dist/modules/auth/guards/jwt-auth.guard.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
||||
export declare class JwtAuthGuard extends JwtAuthGuard_base {
|
||||
}
|
||||
export {};
|
||||
18
dist/modules/auth/guards/jwt-auth.guard.js
vendored
18
dist/modules/auth/guards/jwt-auth.guard.js
vendored
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JwtAuthGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
||||
};
|
||||
exports.JwtAuthGuard = JwtAuthGuard;
|
||||
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], JwtAuthGuard);
|
||||
//# sourceMappingURL=jwt-auth.guard.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../../../src/modules/auth/guards/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;CAAG,CAAA;AAAxC,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAA4B"}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { UserLevel } from '../../users/enums/user-level.enum';
|
||||
import { UserRole } from '../../users/enums/user-role.enum';
|
||||
export interface JwtPayload {
|
||||
sub: string;
|
||||
phone: string;
|
||||
role: UserRole;
|
||||
level: UserLevel;
|
||||
permissions: string[];
|
||||
type: 'access' | 'refresh';
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=jwt-payload.interface.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"jwt-payload.interface.js","sourceRoot":"","sources":["../../../../src/modules/auth/interfaces/jwt-payload.interface.ts"],"names":[],"mappings":""}
|
||||
7
dist/modules/auth/sms.service.d.ts
vendored
7
dist/modules/auth/sms.service.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
export declare class SmsService {
|
||||
private readonly configService;
|
||||
private readonly logger;
|
||||
constructor(configService: ConfigService);
|
||||
sendOtp(mobile: string, otpCode: string): Promise<boolean>;
|
||||
}
|
||||
56
dist/modules/auth/sms.service.js
vendored
56
dist/modules/auth/sms.service.js
vendored
@@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var SmsService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SmsService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const soap_1 = require("soap");
|
||||
let SmsService = SmsService_1 = class SmsService {
|
||||
configService;
|
||||
logger = new common_1.Logger(SmsService_1.name);
|
||||
constructor(configService) {
|
||||
this.configService = configService;
|
||||
}
|
||||
async sendOtp(mobile, otpCode) {
|
||||
const wsdlUrl = this.configService.get('sms.wsdlUrl');
|
||||
const username = this.configService.get('sms.username');
|
||||
const password = this.configService.get('sms.password');
|
||||
const fromNumber = this.configService.get('sms.fromNumber');
|
||||
if (!wsdlUrl || !username || !password || !fromNumber) {
|
||||
this.logger.warn('SMS provider config is incomplete, OTP SMS skipped.');
|
||||
return false;
|
||||
}
|
||||
const content = `آکادمی زبان آلمانی انجل\nکد تایید شما: ${otpCode}\nلغو11`;
|
||||
try {
|
||||
const client = await (0, soap_1.createClientAsync)(wsdlUrl);
|
||||
const [result] = await client.SendSMSAsync(fromNumber, [mobile], content, '0', username, password);
|
||||
if (Array.isArray(result) && result[0] > 0) {
|
||||
return true;
|
||||
}
|
||||
if (typeof result === 'number' && result > 0) {
|
||||
return true;
|
||||
}
|
||||
this.logger.warn(`SMS provider returned unsuccessful response: ${JSON.stringify(result)}`);
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
this.logger.error('SOAP SMS send failed', error instanceof Error ? error.stack : undefined);
|
||||
throw new common_1.InternalServerErrorException('OTP SMS sending failed');
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.SmsService = SmsService;
|
||||
exports.SmsService = SmsService = SmsService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [config_1.ConfigService])
|
||||
], SmsService);
|
||||
//# sourceMappingURL=sms.service.js.map
|
||||
1
dist/modules/auth/sms.service.js.map
vendored
1
dist/modules/auth/sms.service.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"sms.service.js","sourceRoot":"","sources":["../../../src/modules/auth/sms.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAkF;AAClF,2CAA+C;AAC/C,+BAAyC;AAGlC,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAGQ;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,YAAU,CAAC,IAAI,CAAC,CAAC;IAEtD,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,OAAe;QAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,aAAa,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,gBAAgB,CAAC,CAAC;QAEpE,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;YACtD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;YACxE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,OAAO,GAAG,0CAA0C,OAAO,SAAS,CAAC;QAE3E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAiB,EAAC,OAAO,CAAC,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,YAAY,CACxC,UAAU,EACV,CAAC,MAAM,CAAC,EACR,OAAO,EACP,GAAG,EACH,QAAQ,EACR,QAAQ,CACT,CAAC;YAEF,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gDAAgD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC3F,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC5F,MAAM,IAAI,qCAA4B,CAAC,wBAAwB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF,CAAA;AA5CY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAIiC,sBAAa;GAH9C,UAAU,CA4CtB"}
|
||||
11
dist/modules/auth/strategies/jwt.strategy.d.ts
vendored
11
dist/modules/auth/strategies/jwt.strategy.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Strategy } from 'passport-jwt';
|
||||
import { JwtPayload } from '../interfaces/jwt-payload.interface';
|
||||
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithoutRequest] | [opt: import("passport-jwt").StrategyOptionsWithRequest]) => Strategy & {
|
||||
validate(...args: any[]): unknown;
|
||||
};
|
||||
export declare class JwtStrategy extends JwtStrategy_base {
|
||||
constructor(configService: ConfigService);
|
||||
validate(payload: JwtPayload): JwtPayload;
|
||||
}
|
||||
export {};
|
||||
34
dist/modules/auth/strategies/jwt.strategy.js
vendored
34
dist/modules/auth/strategies/jwt.strategy.js
vendored
@@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JwtStrategy = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const passport_jwt_1 = require("passport-jwt");
|
||||
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
||||
constructor(configService) {
|
||||
super({
|
||||
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
ignoreExpiration: false,
|
||||
secretOrKey: configService.getOrThrow('jwt.secret'),
|
||||
});
|
||||
}
|
||||
validate(payload) {
|
||||
return payload;
|
||||
}
|
||||
};
|
||||
exports.JwtStrategy = JwtStrategy;
|
||||
exports.JwtStrategy = JwtStrategy = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [config_1.ConfigService])
|
||||
], JwtStrategy);
|
||||
//# sourceMappingURL=jwt.strategy.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../../src/modules/auth/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,+CAAoD;AACpD,+CAAoD;AAI7C,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACzD,YAAY,aAA4B;QACtC,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,aAAa,CAAC,UAAU,CAAS,YAAY,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,OAAmB;QAC1B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAZY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEgB,sBAAa;GAD7B,WAAW,CAYvB"}
|
||||
314
dist/modules/catalog/admin-products.controller.d.ts
vendored
314
dist/modules/catalog/admin-products.controller.d.ts
vendored
@@ -1,314 +0,0 @@
|
||||
import { CheckProductSlugDto } from './dto/check-product-slug.dto';
|
||||
import { CreateProductDto } from './dto/create-product.dto';
|
||||
import { FilterProductReviewsDto } from './dto/filter-product-reviews.dto';
|
||||
import { FilterProductsDto } from './dto/filter-products.dto';
|
||||
import { ModerateProductReviewDto } from './dto/moderate-product-review.dto';
|
||||
import { UpdateProductDto } from './dto/update-product.dto';
|
||||
import { ProductsService } from './products.service';
|
||||
export declare class AdminProductsController {
|
||||
private readonly productsService;
|
||||
constructor(productsService: ProductsService);
|
||||
create(dto: CreateProductDto, files: {
|
||||
mainImage?: Express.Multer.File[];
|
||||
images?: Express.Multer.File[];
|
||||
model3d?: Express.Multer.File[];
|
||||
}): Promise<{
|
||||
attributes: {
|
||||
id: string;
|
||||
displayOrder: number;
|
||||
attributeId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
dataType: import("./enums/attribute-data-type.enum").AttributeDataType;
|
||||
unit: string | null;
|
||||
options: string[];
|
||||
isFilterable: boolean;
|
||||
isVisible: boolean;
|
||||
valueText: string | null;
|
||||
valueNumber: number | null;
|
||||
valueBoolean: boolean | null;
|
||||
valueJson: string[] | Record<string, unknown> | null;
|
||||
}[];
|
||||
meta: import("./entities/product-meta.entity").ProductMeta | {
|
||||
shortDescription: string | null;
|
||||
description: string | null;
|
||||
seo: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
} | undefined;
|
||||
share: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
imageUrl: string | null | undefined;
|
||||
};
|
||||
};
|
||||
brandInfo: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
primaryCategory: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
categories: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
}[];
|
||||
id: string;
|
||||
sku: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
technicalCode: string;
|
||||
brand: string;
|
||||
brandEntity?: import("./entities/brand.entity").Brand | null;
|
||||
basePriceUSD: number;
|
||||
salePriceUSD?: number | null;
|
||||
stock: number;
|
||||
featured: boolean;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
status: import("./enums/product-status.enum").ProductStatus;
|
||||
mainImageUrl?: string | null;
|
||||
threeDModelUrl?: string | null;
|
||||
imageGalleryUrls: string[];
|
||||
tags: string[];
|
||||
averageRating: number;
|
||||
reviewsCount: number;
|
||||
attributeValues: import("./entities/product-attribute-value.entity").ProductAttributeValue[];
|
||||
reviews: import("./entities/product-review.entity").ProductReview[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}>;
|
||||
findAll(filters: FilterProductsDto, productType?: string): Promise<{
|
||||
items: {
|
||||
status?: import("./enums/product-status.enum").ProductStatus | undefined;
|
||||
createdAt?: Date | undefined;
|
||||
updatedAt?: Date | undefined;
|
||||
id: string;
|
||||
sku: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
technicalCode: string;
|
||||
brand: string;
|
||||
brandInfo: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
featured: boolean;
|
||||
basePriceUSD: number;
|
||||
salePriceUSD: number | null;
|
||||
stock: number;
|
||||
averageRating: number;
|
||||
reviewsCount: number;
|
||||
mainImageUrl: string | null;
|
||||
shortDescription: string | null;
|
||||
primaryCategory: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
attributes: {
|
||||
id: string;
|
||||
displayOrder: number;
|
||||
attributeId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
dataType: import("./enums/attribute-data-type.enum").AttributeDataType;
|
||||
unit: string | null;
|
||||
valueText: string | null;
|
||||
valueNumber: number | null;
|
||||
valueBoolean: boolean | null;
|
||||
valueJson: string[] | Record<string, unknown> | null;
|
||||
}[];
|
||||
}[];
|
||||
meta: {
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
};
|
||||
}>;
|
||||
checkSlug(query: CheckProductSlugDto): Promise<boolean>;
|
||||
findReviews(filters: FilterProductReviewsDto): Promise<{
|
||||
items: import("./entities/product-review.entity").ProductReview[];
|
||||
meta: {
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
};
|
||||
}>;
|
||||
updateReview(reviewId: string, dto: ModerateProductReviewDto): Promise<import("./entities/product-review.entity").ProductReview>;
|
||||
removeReview(reviewId: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
findOne(id: string): Promise<{
|
||||
attributes: {
|
||||
id: string;
|
||||
displayOrder: number;
|
||||
attributeId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
dataType: import("./enums/attribute-data-type.enum").AttributeDataType;
|
||||
unit: string | null;
|
||||
options: string[];
|
||||
isFilterable: boolean;
|
||||
isVisible: boolean;
|
||||
valueText: string | null;
|
||||
valueNumber: number | null;
|
||||
valueBoolean: boolean | null;
|
||||
valueJson: string[] | Record<string, unknown> | null;
|
||||
}[];
|
||||
meta: import("./entities/product-meta.entity").ProductMeta | {
|
||||
shortDescription: string | null;
|
||||
description: string | null;
|
||||
seo: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
} | undefined;
|
||||
share: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
imageUrl: string | null | undefined;
|
||||
};
|
||||
};
|
||||
brandInfo: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
primaryCategory: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
categories: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
}[];
|
||||
id: string;
|
||||
sku: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
technicalCode: string;
|
||||
brand: string;
|
||||
brandEntity?: import("./entities/brand.entity").Brand | null;
|
||||
basePriceUSD: number;
|
||||
salePriceUSD?: number | null;
|
||||
stock: number;
|
||||
featured: boolean;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
status: import("./enums/product-status.enum").ProductStatus;
|
||||
mainImageUrl?: string | null;
|
||||
threeDModelUrl?: string | null;
|
||||
imageGalleryUrls: string[];
|
||||
tags: string[];
|
||||
averageRating: number;
|
||||
reviewsCount: number;
|
||||
attributeValues: import("./entities/product-attribute-value.entity").ProductAttributeValue[];
|
||||
reviews: import("./entities/product-review.entity").ProductReview[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}>;
|
||||
update(id: string, dto: UpdateProductDto, files: {
|
||||
mainImage?: Express.Multer.File[];
|
||||
images?: Express.Multer.File[];
|
||||
model3d?: Express.Multer.File[];
|
||||
}): Promise<{
|
||||
attributes: {
|
||||
id: string;
|
||||
displayOrder: number;
|
||||
attributeId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
dataType: import("./enums/attribute-data-type.enum").AttributeDataType;
|
||||
unit: string | null;
|
||||
options: string[];
|
||||
isFilterable: boolean;
|
||||
isVisible: boolean;
|
||||
valueText: string | null;
|
||||
valueNumber: number | null;
|
||||
valueBoolean: boolean | null;
|
||||
valueJson: string[] | Record<string, unknown> | null;
|
||||
}[];
|
||||
meta: import("./entities/product-meta.entity").ProductMeta | {
|
||||
shortDescription: string | null;
|
||||
description: string | null;
|
||||
seo: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
} | undefined;
|
||||
share: {
|
||||
title: string;
|
||||
description: string | null;
|
||||
imageUrl: string | null | undefined;
|
||||
};
|
||||
};
|
||||
brandInfo: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
primaryCategory: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
} | null;
|
||||
categories: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
imageUrl: string | null | undefined;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
}[];
|
||||
id: string;
|
||||
sku: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
technicalCode: string;
|
||||
brand: string;
|
||||
brandEntity?: import("./entities/brand.entity").Brand | null;
|
||||
basePriceUSD: number;
|
||||
salePriceUSD?: number | null;
|
||||
stock: number;
|
||||
featured: boolean;
|
||||
type: import("./enums/product-type.enum").ProductType;
|
||||
status: import("./enums/product-status.enum").ProductStatus;
|
||||
mainImageUrl?: string | null;
|
||||
threeDModelUrl?: string | null;
|
||||
imageGalleryUrls: string[];
|
||||
tags: string[];
|
||||
averageRating: number;
|
||||
reviewsCount: number;
|
||||
attributeValues: import("./entities/product-attribute-value.entity").ProductAttributeValue[];
|
||||
reviews: import("./entities/product-review.entity").ProductReview[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}>;
|
||||
remove(id: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
}
|
||||
172
dist/modules/catalog/admin-products.controller.js
vendored
172
dist/modules/catalog/admin-products.controller.js
vendored
@@ -1,172 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdminProductsController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const platform_express_1 = require("@nestjs/platform-express");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const permissions_decorator_1 = require("../../common/decorators/permissions.decorator");
|
||||
const roles_decorator_1 = require("../../common/decorators/roles.decorator");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const check_product_slug_dto_1 = require("./dto/check-product-slug.dto");
|
||||
const create_product_dto_1 = require("./dto/create-product.dto");
|
||||
const filter_product_reviews_dto_1 = require("./dto/filter-product-reviews.dto");
|
||||
const filter_products_dto_1 = require("./dto/filter-products.dto");
|
||||
const moderate_product_review_dto_1 = require("./dto/moderate-product-review.dto");
|
||||
const update_product_dto_1 = require("./dto/update-product.dto");
|
||||
const products_service_1 = require("./products.service");
|
||||
let AdminProductsController = class AdminProductsController {
|
||||
productsService;
|
||||
constructor(productsService) {
|
||||
this.productsService = productsService;
|
||||
}
|
||||
create(dto, files) {
|
||||
return this.productsService.create(dto, files);
|
||||
}
|
||||
findAll(filters, productType) {
|
||||
return this.productsService.findAdmin(filters, productType);
|
||||
}
|
||||
checkSlug(query) {
|
||||
return this.productsService.checkSlugAvailability(query.slug, query.excludeId);
|
||||
}
|
||||
findReviews(filters) {
|
||||
return this.productsService.findAdminReviews(filters);
|
||||
}
|
||||
updateReview(reviewId, dto) {
|
||||
return this.productsService.updateReview(reviewId, dto);
|
||||
}
|
||||
removeReview(reviewId) {
|
||||
return this.productsService.removeReview(reviewId);
|
||||
}
|
||||
findOne(id) {
|
||||
return this.productsService.findAdminOne(id);
|
||||
}
|
||||
update(id, dto, files) {
|
||||
return this.productsService.update(id, dto, files);
|
||||
}
|
||||
remove(id) {
|
||||
return this.productsService.remove(id);
|
||||
}
|
||||
};
|
||||
exports.AdminProductsController = AdminProductsController;
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Create a product for admin panel' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: create_product_dto_1.CreateProductDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([
|
||||
{ name: 'mainImage', maxCount: 1 },
|
||||
{ name: 'images', maxCount: 10 },
|
||||
{ name: 'model3d', maxCount: 1 },
|
||||
])),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_product_dto_1.CreateProductDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'List all products for admin panel, including drafts' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__param(1, (0, common_1.Headers)('x-product-type')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [filter_products_dto_1.FilterProductsDto, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('check-slug'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Check whether a product slug is available for admin create/edit' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [check_product_slug_dto_1.CheckProductSlugDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "checkSlug", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('reviews/list'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'List product reviews for moderation' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [filter_product_reviews_dto_1.FilterProductReviewsDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "findReviews", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)('reviews/:reviewId'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Approve or pin a product review' }),
|
||||
__param(0, (0, common_1.Param)('reviewId')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, moderate_product_review_dto_1.ModerateProductReviewDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "updateReview", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)('reviews/:reviewId'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Delete a product review' }),
|
||||
__param(0, (0, common_1.Param)('reviewId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "removeReview", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Get one product for admin panel' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Update a product for admin panel' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: update_product_dto_1.UpdateProductDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([
|
||||
{ name: 'mainImage', maxCount: 1 },
|
||||
{ name: 'images', maxCount: 10 },
|
||||
{ name: 'model3d', maxCount: 1 },
|
||||
])),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__param(2, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, update_product_dto_1.UpdateProductDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Delete a product and its assets' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "remove", null);
|
||||
exports.AdminProductsController = AdminProductsController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Admin Products'),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('products.manage'),
|
||||
(0, swagger_1.ApiHeader)({
|
||||
name: 'x-product-type',
|
||||
required: false,
|
||||
description: 'Optional product type filter header. Falls back to query param `type` if omitted.',
|
||||
enum: ['Industrial', 'Automotive'],
|
||||
}),
|
||||
(0, common_1.Controller)('admin/products'),
|
||||
__metadata("design:paramtypes", [products_service_1.ProductsService])
|
||||
], AdminProductsController);
|
||||
//# sourceMappingURL=admin-products.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"admin-products.controller.js","sourceRoot":"","sources":["../../../src/modules/catalog/admin-products.controller.ts"],"names":[],"mappings":"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"}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { CreateAttributeDefinitionDto } from './dto/create-attribute-definition.dto';
|
||||
import { UpdateAttributeDefinitionDto } from './dto/update-attribute-definition.dto';
|
||||
import { ProductsService } from './products.service';
|
||||
export declare class AttributeDefinitionsController {
|
||||
private readonly productsService;
|
||||
constructor(productsService: ProductsService);
|
||||
findAll(): Promise<import("./entities/attribute-definition.entity").AttributeDefinition[]>;
|
||||
create(dto: CreateAttributeDefinitionDto): Promise<import("./entities/attribute-definition.entity").AttributeDefinition>;
|
||||
update(id: string, dto: UpdateAttributeDefinitionDto): Promise<import("./entities/attribute-definition.entity").AttributeDefinition>;
|
||||
remove(id: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AttributeDefinitionsController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const permissions_decorator_1 = require("../../common/decorators/permissions.decorator");
|
||||
const roles_decorator_1 = require("../../common/decorators/roles.decorator");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const create_attribute_definition_dto_1 = require("./dto/create-attribute-definition.dto");
|
||||
const update_attribute_definition_dto_1 = require("./dto/update-attribute-definition.dto");
|
||||
const products_service_1 = require("./products.service");
|
||||
let AttributeDefinitionsController = class AttributeDefinitionsController {
|
||||
productsService;
|
||||
constructor(productsService) {
|
||||
this.productsService = productsService;
|
||||
}
|
||||
findAll() {
|
||||
return this.productsService.listAttributeDefinitions();
|
||||
}
|
||||
create(dto) {
|
||||
return this.productsService.createAttributeDefinition(dto);
|
||||
}
|
||||
update(id, dto) {
|
||||
return this.productsService.updateAttributeDefinition(id, dto);
|
||||
}
|
||||
remove(id) {
|
||||
return this.productsService.removeAttributeDefinition(id);
|
||||
}
|
||||
};
|
||||
exports.AttributeDefinitionsController = AttributeDefinitionsController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'List reusable product attribute definitions' }),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AttributeDefinitionsController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Create reusable product attribute definition' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_attribute_definition_dto_1.CreateAttributeDefinitionDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AttributeDefinitionsController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Update reusable product attribute definition' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, update_attribute_definition_dto_1.UpdateAttributeDefinitionDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AttributeDefinitionsController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Delete reusable product attribute definition' }),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AttributeDefinitionsController.prototype, "remove", null);
|
||||
exports.AttributeDefinitionsController = AttributeDefinitionsController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Admin Product Attributes'),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('products.manage'),
|
||||
(0, common_1.Controller)('admin/product-attributes'),
|
||||
__metadata("design:paramtypes", [products_service_1.ProductsService])
|
||||
], AttributeDefinitionsController);
|
||||
//# sourceMappingURL=attribute-definitions.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"attribute-definitions.controller.js","sourceRoot":"","sources":["../../../src/modules/catalog/attribute-definitions.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,6CAAuE;AACvE,yFAA4E;AAC5E,6EAAgE;AAChE,6EAAyE;AACzE,iEAA6D;AAC7D,kEAA6D;AAC7D,kEAAyD;AACzD,2FAAqF;AACrF,2FAAqF;AACrF,yDAAqD;AAQ9C,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACZ;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAIjE,OAAO;QACL,OAAO,IAAI,CAAC,eAAe,CAAC,wBAAwB,EAAE,CAAC;IACzD,CAAC;IAID,MAAM,CAAS,GAAiC;QAC9C,OAAO,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;IAC7D,CAAC;IAID,MAAM,CAAc,EAAU,EAAU,GAAiC;QACvE,OAAO,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACjE,CAAC;IAID,MAAM,CAAc,EAAU;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AA1BY,wEAA8B;AAKzC;IAFC,IAAA,YAAG,GAAE;IACL,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC;;;;6DAGxE;AAID;IAFC,IAAA,aAAI,GAAE;IACN,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;IAClE,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,8DAA4B;;4DAE/C;AAID;IAFC,IAAA,cAAK,EAAC,KAAK,CAAC;IACZ,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;IAClE,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,8DAA4B;;4DAExE;AAID;IAFC,IAAA,eAAM,EAAC,KAAK,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC;IAClE,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;4DAElB;yCAzBU,8BAA8B;IAN1C,IAAA,iBAAO,EAAC,0BAA0B,CAAC;IACnC,IAAA,uBAAa,GAAE;IACf,IAAA,kBAAS,EAAC,6BAAY,EAAE,wBAAU,EAAE,oCAAgB,CAAC;IACrD,IAAA,uBAAK,EAAC,yBAAQ,CAAC,KAAK,CAAC;IACrB,IAAA,mCAAW,EAAC,iBAAiB,CAAC;IAC9B,IAAA,mBAAU,EAAC,0BAA0B,CAAC;qCAES,kCAAe;GADlD,8BAA8B,CA0B1C"}
|
||||
18
dist/modules/catalog/brand.controller.d.ts
vendored
18
dist/modules/catalog/brand.controller.d.ts
vendored
@@ -1,18 +0,0 @@
|
||||
import { BrandService } from './brand.service';
|
||||
import { CreateBrandDto } from './dto/create-brand.dto';
|
||||
import { UpdateBrandDto } from './dto/update-brand.dto';
|
||||
export declare class BrandController {
|
||||
private readonly brandService;
|
||||
constructor(brandService: BrandService);
|
||||
create(dto: CreateBrandDto, files: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<import("./entities/brand.entity").Brand>;
|
||||
findAll(): Promise<import("./entities/brand.entity").Brand[]>;
|
||||
findOne(id: string): Promise<import("./entities/brand.entity").Brand>;
|
||||
update(id: string, dto: UpdateBrandDto, files: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<import("./entities/brand.entity").Brand>;
|
||||
remove(id: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
}
|
||||
112
dist/modules/catalog/brand.controller.js
vendored
112
dist/modules/catalog/brand.controller.js
vendored
@@ -1,112 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrandController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const platform_express_1 = require("@nestjs/platform-express");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const permissions_decorator_1 = require("../../common/decorators/permissions.decorator");
|
||||
const roles_decorator_1 = require("../../common/decorators/roles.decorator");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const brand_service_1 = require("./brand.service");
|
||||
const create_brand_dto_1 = require("./dto/create-brand.dto");
|
||||
const update_brand_dto_1 = require("./dto/update-brand.dto");
|
||||
let BrandController = class BrandController {
|
||||
brandService;
|
||||
constructor(brandService) {
|
||||
this.brandService = brandService;
|
||||
}
|
||||
create(dto, files) {
|
||||
return this.brandService.create(dto, files);
|
||||
}
|
||||
findAll() {
|
||||
return this.brandService.findAll();
|
||||
}
|
||||
findOne(id) {
|
||||
return this.brandService.findOne(id);
|
||||
}
|
||||
update(id, dto, files) {
|
||||
return this.brandService.update(id, dto, files);
|
||||
}
|
||||
remove(id) {
|
||||
return this.brandService.remove(id);
|
||||
}
|
||||
};
|
||||
exports.BrandController = BrandController;
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('brands.manage'),
|
||||
(0, common_1.Post)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Create brand with optional uploaded or existing image' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: create_brand_dto_1.CreateBrandDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([{ name: 'image', maxCount: 1 }])),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_brand_dto_1.CreateBrandDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BrandController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BrandController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BrandController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('brands.manage'),
|
||||
(0, common_1.Patch)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Update brand and brand image' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: update_brand_dto_1.UpdateBrandDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([{ name: 'image', maxCount: 1 }])),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__param(2, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, update_brand_dto_1.UpdateBrandDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BrandController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('brands.manage'),
|
||||
(0, common_1.Delete)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BrandController.prototype, "remove", null);
|
||||
exports.BrandController = BrandController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Brands'),
|
||||
(0, common_1.Controller)('brands'),
|
||||
__metadata("design:paramtypes", [brand_service_1.BrandService])
|
||||
], BrandController);
|
||||
//# sourceMappingURL=brand.controller.js.map
|
||||
1
dist/modules/catalog/brand.controller.js.map
vendored
1
dist/modules/catalog/brand.controller.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"brand.controller.js","sourceRoot":"","sources":["../../../src/modules/catalog/brand.controller.ts"],"names":[],"mappings":"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"}
|
||||
22
dist/modules/catalog/brand.service.d.ts
vendored
22
dist/modules/catalog/brand.service.d.ts
vendored
@@ -1,22 +0,0 @@
|
||||
import { Repository } from 'typeorm';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { CreateBrandDto } from './dto/create-brand.dto';
|
||||
import { UpdateBrandDto } from './dto/update-brand.dto';
|
||||
import { Brand } from './entities/brand.entity';
|
||||
export declare class BrandService {
|
||||
private readonly brandsRepository;
|
||||
private readonly storageService;
|
||||
constructor(brandsRepository: Repository<Brand>, storageService: StorageService);
|
||||
create(dto: CreateBrandDto, files?: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<Brand>;
|
||||
findAll(): Promise<Brand[]>;
|
||||
findOne(id: string): Promise<Brand>;
|
||||
update(id: string, dto: UpdateBrandDto, files?: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<Brand>;
|
||||
remove(id: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
private replaceImage;
|
||||
}
|
||||
89
dist/modules/catalog/brand.service.js
vendored
89
dist/modules/catalog/brand.service.js
vendored
@@ -1,89 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrandService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const storage_service_1 = require("../storage/storage.service");
|
||||
const brand_entity_1 = require("./entities/brand.entity");
|
||||
let BrandService = class BrandService {
|
||||
brandsRepository;
|
||||
storageService;
|
||||
constructor(brandsRepository, storageService) {
|
||||
this.brandsRepository = brandsRepository;
|
||||
this.storageService = storageService;
|
||||
}
|
||||
async create(dto, files) {
|
||||
const imageUpload = files?.image?.[0]
|
||||
? await this.storageService.uploadPublicFile(files.image[0], 'brands')
|
||||
: null;
|
||||
const brand = this.brandsRepository.create({
|
||||
name: dto.name,
|
||||
slug: dto.slug,
|
||||
imageUrl: imageUpload?.url ?? dto.existingImageUrl ?? null,
|
||||
type: dto.type,
|
||||
});
|
||||
return this.brandsRepository.save(brand);
|
||||
}
|
||||
findAll() {
|
||||
return this.brandsRepository.find({
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
}
|
||||
async findOne(id) {
|
||||
const brand = await this.brandsRepository.findOne({ where: { id } });
|
||||
if (!brand) {
|
||||
throw new common_1.NotFoundException('Brand not found');
|
||||
}
|
||||
return brand;
|
||||
}
|
||||
async update(id, dto, files) {
|
||||
const brand = await this.findOne(id);
|
||||
if (files?.image?.[0]) {
|
||||
const imageUpload = await this.storageService.uploadPublicFile(files.image[0], 'brands');
|
||||
await this.replaceImage(brand.imageUrl, imageUpload.url);
|
||||
brand.imageUrl = imageUpload.url;
|
||||
}
|
||||
else if (dto.existingImageUrl !== undefined) {
|
||||
await this.replaceImage(brand.imageUrl, dto.existingImageUrl || null);
|
||||
brand.imageUrl = dto.existingImageUrl || null;
|
||||
}
|
||||
Object.assign(brand, {
|
||||
name: dto.name ?? brand.name,
|
||||
slug: dto.slug ?? brand.slug,
|
||||
type: dto.type ?? brand.type,
|
||||
});
|
||||
return this.brandsRepository.save(brand);
|
||||
}
|
||||
async remove(id) {
|
||||
const brand = await this.findOne(id);
|
||||
await this.storageService.deletePublicFileByUrl(brand.imageUrl);
|
||||
await this.brandsRepository.remove(brand);
|
||||
return { message: 'Brand deleted successfully' };
|
||||
}
|
||||
async replaceImage(currentUrl, nextUrl) {
|
||||
if (currentUrl && currentUrl !== nextUrl) {
|
||||
await this.storageService.deletePublicFileByUrl(currentUrl);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.BrandService = BrandService;
|
||||
exports.BrandService = BrandService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(brand_entity_1.Brand)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
storage_service_1.StorageService])
|
||||
], BrandService);
|
||||
//# sourceMappingURL=brand.service.js.map
|
||||
1
dist/modules/catalog/brand.service.js.map
vendored
1
dist/modules/catalog/brand.service.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"brand.service.js","sourceRoot":"","sources":["../../../src/modules/catalog/brand.service.ts"],"names":[],"mappings":"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"}
|
||||
2
dist/modules/catalog/catalog.module.d.ts
vendored
2
dist/modules/catalog/catalog.module.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
export declare class CatalogModule {
|
||||
}
|
||||
56
dist/modules/catalog/catalog.module.js
vendored
56
dist/modules/catalog/catalog.module.js
vendored
@@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CatalogModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const storage_module_1 = require("../storage/storage.module");
|
||||
const admin_products_controller_1 = require("./admin-products.controller");
|
||||
const attribute_definitions_controller_1 = require("./attribute-definitions.controller");
|
||||
const brand_controller_1 = require("./brand.controller");
|
||||
const brand_service_1 = require("./brand.service");
|
||||
const category_controller_1 = require("./category.controller");
|
||||
const category_service_1 = require("./category.service");
|
||||
const attribute_definition_entity_1 = require("./entities/attribute-definition.entity");
|
||||
const brand_entity_1 = require("./entities/brand.entity");
|
||||
const category_entity_1 = require("./entities/category.entity");
|
||||
const product_attribute_value_entity_1 = require("./entities/product-attribute-value.entity");
|
||||
const product_meta_entity_1 = require("./entities/product-meta.entity");
|
||||
const product_entity_1 = require("./entities/product.entity");
|
||||
const product_review_entity_1 = require("./entities/product-review.entity");
|
||||
const products_controller_1 = require("./products.controller");
|
||||
const products_service_1 = require("./products.service");
|
||||
let CatalogModule = class CatalogModule {
|
||||
};
|
||||
exports.CatalogModule = CatalogModule;
|
||||
exports.CatalogModule = CatalogModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
category_entity_1.Category,
|
||||
brand_entity_1.Brand,
|
||||
product_entity_1.Product,
|
||||
product_review_entity_1.ProductReview,
|
||||
product_meta_entity_1.ProductMeta,
|
||||
attribute_definition_entity_1.AttributeDefinition,
|
||||
product_attribute_value_entity_1.ProductAttributeValue,
|
||||
]),
|
||||
storage_module_1.StorageModule,
|
||||
],
|
||||
controllers: [
|
||||
category_controller_1.CategoryController,
|
||||
brand_controller_1.BrandController,
|
||||
products_controller_1.ProductsController,
|
||||
admin_products_controller_1.AdminProductsController,
|
||||
attribute_definitions_controller_1.AttributeDefinitionsController,
|
||||
],
|
||||
providers: [category_service_1.CategoryService, brand_service_1.BrandService, products_service_1.ProductsService],
|
||||
exports: [typeorm_1.TypeOrmModule, category_service_1.CategoryService, brand_service_1.BrandService, products_service_1.ProductsService],
|
||||
})
|
||||
], CatalogModule);
|
||||
//# sourceMappingURL=catalog.module.js.map
|
||||
1
dist/modules/catalog/catalog.module.js.map
vendored
1
dist/modules/catalog/catalog.module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"catalog.module.js","sourceRoot":"","sources":["../../../src/modules/catalog/catalog.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,8DAA0D;AAC1D,2EAAsE;AACtE,yFAAoF;AACpF,yDAAqD;AACrD,mDAA+C;AAC/C,+DAA2D;AAC3D,yDAAqD;AACrD,wFAA6E;AAC7E,0DAAgD;AAChD,gEAAsD;AACtD,8FAAkF;AAClF,wEAA6D;AAC7D,8DAAoD;AACpD,4EAAiE;AACjE,+DAA2D;AAC3D,yDAAqD;AAyB9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAvBzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC;gBACvB,0BAAQ;gBACR,oBAAK;gBACL,wBAAO;gBACP,qCAAa;gBACb,iCAAW;gBACX,iDAAmB;gBACnB,sDAAqB;aACtB,CAAC;YACF,8BAAa;SACd;QACD,WAAW,EAAE;YACX,wCAAkB;YAClB,kCAAe;YACf,wCAAkB;YAClB,mDAAuB;YACvB,iEAA8B;SAC/B;QACD,SAAS,EAAE,CAAC,kCAAe,EAAE,4BAAY,EAAE,kCAAe,CAAC;QAC3D,OAAO,EAAE,CAAC,uBAAa,EAAE,kCAAe,EAAE,4BAAY,EAAE,kCAAe,CAAC;KACzE,CAAC;GACW,aAAa,CAAG"}
|
||||
18
dist/modules/catalog/category.controller.d.ts
vendored
18
dist/modules/catalog/category.controller.d.ts
vendored
@@ -1,18 +0,0 @@
|
||||
import { CategoryService } from './category.service';
|
||||
import { CreateCategoryDto } from './dto/create-category.dto';
|
||||
import { UpdateCategoryDto } from './dto/update-category.dto';
|
||||
export declare class CategoryController {
|
||||
private readonly categoryService;
|
||||
constructor(categoryService: CategoryService);
|
||||
create(dto: CreateCategoryDto, files: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<import("./entities/category.entity").Category>;
|
||||
findAll(): Promise<import("./entities/category.entity").Category[]>;
|
||||
findOne(id: string): Promise<import("./entities/category.entity").Category>;
|
||||
update(id: string, dto: UpdateCategoryDto, files: {
|
||||
image?: Express.Multer.File[];
|
||||
}): Promise<import("./entities/category.entity").Category>;
|
||||
remove(id: string): Promise<{
|
||||
message: string;
|
||||
}>;
|
||||
}
|
||||
112
dist/modules/catalog/category.controller.js
vendored
112
dist/modules/catalog/category.controller.js
vendored
@@ -1,112 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CategoryController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const platform_express_1 = require("@nestjs/platform-express");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const permissions_decorator_1 = require("../../common/decorators/permissions.decorator");
|
||||
const roles_decorator_1 = require("../../common/decorators/roles.decorator");
|
||||
const permissions_guard_1 = require("../../common/guards/permissions.guard");
|
||||
const roles_guard_1 = require("../../common/guards/roles.guard");
|
||||
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
||||
const user_role_enum_1 = require("../users/enums/user-role.enum");
|
||||
const category_service_1 = require("./category.service");
|
||||
const create_category_dto_1 = require("./dto/create-category.dto");
|
||||
const update_category_dto_1 = require("./dto/update-category.dto");
|
||||
let CategoryController = class CategoryController {
|
||||
categoryService;
|
||||
constructor(categoryService) {
|
||||
this.categoryService = categoryService;
|
||||
}
|
||||
create(dto, files) {
|
||||
return this.categoryService.create(dto, files);
|
||||
}
|
||||
findAll() {
|
||||
return this.categoryService.findAll();
|
||||
}
|
||||
findOne(id) {
|
||||
return this.categoryService.findOne(id);
|
||||
}
|
||||
update(id, dto, files) {
|
||||
return this.categoryService.update(id, dto, files);
|
||||
}
|
||||
remove(id) {
|
||||
return this.categoryService.remove(id);
|
||||
}
|
||||
};
|
||||
exports.CategoryController = CategoryController;
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('categories.manage'),
|
||||
(0, common_1.Post)(),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Create category with optional uploaded or existing image' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: create_category_dto_1.CreateCategoryDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([{ name: 'image', maxCount: 1 }])),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_category_dto_1.CreateCategoryDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CategoryController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CategoryController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CategoryController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('categories.manage'),
|
||||
(0, common_1.Patch)(':id'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'Update category and category image' }),
|
||||
(0, swagger_1.ApiConsumes)('multipart/form-data'),
|
||||
(0, swagger_1.ApiBody)({ type: update_category_dto_1.UpdateCategoryDto }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileFieldsInterceptor)([{ name: 'image', maxCount: 1 }])),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__param(2, (0, common_1.UploadedFiles)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, update_category_dto_1.UpdateCategoryDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CategoryController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, roles_guard_1.RolesGuard, permissions_guard_1.PermissionsGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
(0, roles_decorator_1.Roles)(user_role_enum_1.UserRole.ADMIN),
|
||||
(0, permissions_decorator_1.Permissions)('categories.manage'),
|
||||
(0, common_1.Delete)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CategoryController.prototype, "remove", null);
|
||||
exports.CategoryController = CategoryController = __decorate([
|
||||
(0, swagger_1.ApiTags)('Categories'),
|
||||
(0, common_1.Controller)('categories'),
|
||||
__metadata("design:paramtypes", [category_service_1.CategoryService])
|
||||
], CategoryController);
|
||||
//# sourceMappingURL=category.controller.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user