feat: add @teacinema/commonm

This commit is contained in:
Sergey Krylov 2026-01-28 04:42:54 +03:00
parent c79381e79c
commit 5a301d38ff
4 changed files with 11 additions and 3 deletions

View File

@ -32,6 +32,7 @@
"@nestjs/platform-express": "^11.0.1", "@nestjs/platform-express": "^11.0.1",
"@prisma/adapter-pg": "^7.3.0", "@prisma/adapter-pg": "^7.3.0",
"@prisma/client": "^7.3.0", "@prisma/client": "^7.3.0",
"@teacinema/common": "^1.0.0",
"@teacinema/contracts": "^1.0.0", "@teacinema/contracts": "^1.0.0",
"dotenv-expand": "^12.0.3", "dotenv-expand": "^12.0.3",
"ioredis": "^5.9.2", "ioredis": "^5.9.2",

View File

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import { RpcException } from '@nestjs/microservices' import { RpcException } from '@nestjs/microservices'
import { Account } from '@prisma/generated/client' import { Account } from '@prisma/generated/client'
import { RpcStatus } from '@teacinema/common'
import { import {
SendOtpRequest, SendOtpRequest,
SendOtpResponse, SendOtpResponse,
@ -62,7 +63,7 @@ export class AuthService {
if (!account) { if (!account) {
throw new RpcException({ throw new RpcException({
code: 5, code: RpcStatus.NOT_FOUND,
details: 'Account not found' details: 'Account not found'
}) })
} }

View File

@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import { RpcException } from '@nestjs/microservices' import { RpcException } from '@nestjs/microservices'
import { RpcStatus } from '@teacinema/common'
import { createHash } from 'node:crypto' import { createHash } from 'node:crypto'
import { RedisService } from '@/infra/redis/redis.service' import { RedisService } from '@/infra/redis/redis.service'
@ -32,7 +33,7 @@ export class OtpService {
if (!stroredHash) { if (!stroredHash) {
throw new RpcException({ throw new RpcException({
code: 5, code: RpcStatus.NOT_FOUND,
details: 'Invalid or expired code' details: 'Invalid or expired code'
}) })
} }
@ -40,7 +41,7 @@ export class OtpService {
const hash = createHash('sha256').update(code).digest('hex') const hash = createHash('sha256').update(code).digest('hex')
if (stroredHash !== hash) { if (stroredHash !== hash) {
throw new RpcException({ throw new RpcException({
code: 5, code: RpcStatus.NOT_FOUND,
details: 'Invalid or expired code' details: 'Invalid or expired code'
}) })
} }

View File

@ -1354,6 +1354,11 @@
resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.1.0.tgz#a79b55dbaf8604812f52d140b2c9ab41bc150bb8" resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.1.0.tgz#a79b55dbaf8604812f52d140b2c9ab41bc150bb8"
integrity sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w== 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": "@teacinema/contracts@^1.0.0":
version "1.0.1" 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" resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcontracts/-/1.0.1/contracts-1.0.1.tgz#25021fecb1d33d0505fd11ca3d8201660cb1bcbe"