commit c5aedf698f4f63709ee0fb52d4534e6d4fbda82e Author: Sergey Krylov Date: Wed Jan 21 05:15:53 2026 +0300 feat: add auth contract diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..71c8817 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish + +on: + push: + branches: + - main + +jobs: + Publish npm package action: + runs-on: ubuntu-latest + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + - name: 'Setup dependencies' + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/' + - name: 'Install dependencies' + run: yarn install --frozen-lockfile + - name: 'Generate contracts' + run: yarn generate + - name: 'Publish to Gitea npm registry' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0501cec --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/node_modules/ +dist/ +build/ +pnpm-lock.yaml +.env +.DS_Store +.log +.vscode/ diff --git a/gen/auth.ts b/gen/auth.ts new file mode 100644 index 0000000..fd67837 --- /dev/null +++ b/gen/auth.ts @@ -0,0 +1,47 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.0 +// protoc v6.33.4 +// source: auth.proto + +/* eslint-disable */ +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Observable } from "rxjs"; + +export const protobufPackage = "auth.v1"; + +export interface SendOtpRequest { + identifier: string; + type: string; +} + +export interface SendOtpResponse { + ok: boolean; +} + +export const AUTH_V1_PACKAGE_NAME = "auth.v1"; + +export interface AuthServiceClient { + sendOtp(request: SendOtpRequest): Observable; +} + +export interface AuthServiceController { + sendOtp(request: SendOtpRequest): Promise | Observable | SendOtpResponse; +} + +export function AuthServiceControllerMethods() { + return function (constructor: Function) { + const grpcMethods: string[] = ["sendOtp"]; + for (const method of grpcMethods) { + const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); + GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor); + } + const grpcStreamMethods: string[] = []; + for (const method of grpcStreamMethods) { + const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); + GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor); + } + }; +} + +export const AUTH_SERVICE_NAME = "AuthService"; diff --git a/package.json b/package.json new file mode 100644 index 0000000..ed343ad --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "@teacinema/contracts", + "version": "1.0.0", + "description": "Protocol Buffers contracts for microservices", + "scripts": { + "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit" + }, + "files": [ + "gen", + "proto" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@nestjs/microservices": "^11.1.12", + "rxjs": "^7.8.2" + } +} diff --git a/proto/auth.proto b/proto/auth.proto new file mode 100644 index 0000000..f3b7ba1 --- /dev/null +++ b/proto/auth.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package auth.v1; + +service AuthService { + rpc SendOtp(SendOtpRequest) returns (SendOtpResponse); +} + +message SendOtpRequest { + string identifier = 1; + string type = 2; +} + +message SendOtpResponse { + bool ok = 1; +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..2397cef --- /dev/null +++ b/yarn.lock @@ -0,0 +1,28 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@nestjs/microservices@^11.1.12": + version "11.1.12" + resolved "https://registry.yarnpkg.com/@nestjs/microservices/-/microservices-11.1.12.tgz#05c497eb5ddcae09ae8ac0d3aa1bcd0b7336816b" + integrity sha512-WhkQPvqRJukzWJ0NXE2PJuFcurejRgiPmQ2jumcphkTi/oFu/uEXfTa3Bz6CSKp3eh2fkqtG6YGPoVbUdJS9/A== + dependencies: + iterare "1.2.1" + tslib "2.8.1" + +iterare@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/iterare/-/iterare-1.2.1.tgz#139c400ff7363690e33abffa33cbba8920f00042" + integrity sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q== + +rxjs@^7.8.2: + version "7.8.2" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.2.tgz#955bc473ed8af11a002a2be52071bf475638607b" + integrity sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA== + dependencies: + tslib "^2.1.0" + +tslib@2.8.1, tslib@^2.1.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==