From 5a301d38ff502d211e6a0442c27ca7543086f21a Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Wed, 28 Jan 2026 04:42:54 +0300 Subject: [PATCH] feat: add @teacinema/commonm --- package.json | 1 + src/modules/auth/auth.service.ts | 3 ++- src/modules/otp/otp.service.ts | 5 +++-- yarn.lock | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0102969..634bae2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@nestjs/platform-express": "^11.0.1", "@prisma/adapter-pg": "^7.3.0", "@prisma/client": "^7.3.0", + "@teacinema/common": "^1.0.0", "@teacinema/contracts": "^1.0.0", "dotenv-expand": "^12.0.3", "ioredis": "^5.9.2", diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index 8bd6fa5..ed32690 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@nestjs/common' import { RpcException } from '@nestjs/microservices' import { Account } from '@prisma/generated/client' +import { RpcStatus } from '@teacinema/common' import { SendOtpRequest, SendOtpResponse, @@ -62,7 +63,7 @@ export class AuthService { if (!account) { throw new RpcException({ - code: 5, + code: RpcStatus.NOT_FOUND, details: 'Account not found' }) } diff --git a/src/modules/otp/otp.service.ts b/src/modules/otp/otp.service.ts index 119d4d2..d5bebfc 100644 --- a/src/modules/otp/otp.service.ts +++ b/src/modules/otp/otp.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common' import { RpcException } from '@nestjs/microservices' +import { RpcStatus } from '@teacinema/common' import { createHash } from 'node:crypto' import { RedisService } from '@/infra/redis/redis.service' @@ -32,7 +33,7 @@ export class OtpService { if (!stroredHash) { throw new RpcException({ - code: 5, + code: RpcStatus.NOT_FOUND, details: 'Invalid or expired code' }) } @@ -40,7 +41,7 @@ export class OtpService { const hash = createHash('sha256').update(code).digest('hex') if (stroredHash !== hash) { throw new RpcException({ - code: 5, + code: RpcStatus.NOT_FOUND, details: 'Invalid or expired code' }) } diff --git a/yarn.lock b/yarn.lock index a0042af..604be93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1354,6 +1354,11 @@ resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.1.0.tgz#a79b55dbaf8604812f52d140b2c9ab41bc150bb8" integrity sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w== +"@teacinema/common@^1.0.0": + version "1.0.0" + resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcommon/-/1.0.0/common-1.0.0.tgz#3b79ae6eb46352ed1544535be094fe0ead244c36" + integrity sha512-L006mySvhRpUlRHf3ONbXA0RG42gbQ9QAnmQuZx4zejHEsWB9702xe18MSYcBilv+lmYkQpiX/g3p8P7suLfqQ== + "@teacinema/contracts@^1.0.0": version "1.0.1" resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcontracts/-/1.0.1/contracts-1.0.1.tgz#25021fecb1d33d0505fd11ca3d8201660cb1bcbe"