feat: add auth contract
Some checks failed
Publish / Publish npm package action (push) Failing after 7s
Some checks failed
Publish / Publish npm package action (push) Failing after 7s
This commit is contained in:
commit
c5aedf698f
26
.gitea/workflows/publish.yml
Normal file
26
.gitea/workflows/publish.yml
Normal file
@ -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 }}
|
||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/node_modules/
|
||||
dist/
|
||||
build/
|
||||
pnpm-lock.yaml
|
||||
.env
|
||||
.DS_Store
|
||||
.log
|
||||
.vscode/
|
||||
47
gen/auth.ts
Normal file
47
gen/auth.ts
Normal file
@ -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<SendOtpResponse>;
|
||||
}
|
||||
|
||||
export interface AuthServiceController {
|
||||
sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | 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";
|
||||
19
package.json
Normal file
19
package.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
16
proto/auth.proto
Normal file
16
proto/auth.proto
Normal file
@ -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;
|
||||
}
|
||||
28
yarn.lock
Normal file
28
yarn.lock
Normal file
@ -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==
|
||||
Loading…
x
Reference in New Issue
Block a user