@3d-outlet/common 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +157 -0
  2. package/package.json +29 -0
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ <div align="center">
2
+
3
+ # 🛠️ @3d-outlet/common
4
+
5
+ **Common Utilities and Modules for 3D OUTLET Microservices**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@3d-outlet/common?style=for-the-badge)](https://www.npmjs.com/package/@3d-outlet/common)
8
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=for-the-badge)](https://opensource.org/licenses/ISC)
9
+
10
+ </div>
11
+
12
+ ---
13
+
14
+ ## ✨ Features
15
+
16
+ - 🔌 **gRPC Client Integration** - Simplified setup and usage of gRPC clients in NestJS.
17
+ - 🛠️ **gRPC Client Factory** - Centralized creation and management of gRPC clients.
18
+ - 🏗️ **Injection Decorators** - Convenient decorators for injecting gRPC clients into NestJS services.
19
+ - 📦 **RPC Statuses** - Common RPC status enumeration for error handling.
20
+ - 🔄 **Conversion Utilities** - Helper functions for data manipulation, such as converting `Timestamp` to ISO format.
21
+
22
+ ---
23
+
24
+ ## 📦 Installation
25
+
26
+ ```bash
27
+ npm install @3d-outlet/common
28
+ # or
29
+ pnpm add @3d-outlet/common
30
+ # or
31
+ yarn add @3d-outlet/common
32
+ # or
33
+ bun add @3d-outlet/common
34
+ ```
35
+
36
+ ---
37
+
38
+ ## 🚀 Quick Start
39
+
40
+ ### Registering gRPC Clients
41
+
42
+ ```typescript
43
+ import { GrpcModule } from '@3d-outlet/common'
44
+ import { GRPC_CLIENTS } from '@3d-outlet/common/lib/grpc/registry/grpc.registry'
45
+
46
+ @Module({
47
+ imports: [
48
+ GrpcModule.register([
49
+ 'AUTH_PACKAGE', // Example of registering a client for AUTH_PACKAGE
50
+ ]),
51
+ ],
52
+ })
53
+ export class AppModule {}
54
+ ```
55
+
56
+ ### Injecting gRPC Clients
57
+
58
+ ```typescript
59
+ import { Injectable } from '@nestjs/common'
60
+ import { ClientGrpc } from '@nestjs/microservices'
61
+ import { InjectGrpcClient } from '@3d-outlet/common'
62
+ import { AuthServiceClient } from '@3d-outlet/contracts' // Example client
63
+
64
+ @Injectable()
65
+ export class AuthService {
66
+ constructor(
67
+ @InjectGrpcClient('AUTH_PACKAGE') private readonly authClient: ClientGrpc,
68
+ ) {}
69
+
70
+ onModuleInit() {
71
+ this.authServiceClient =
72
+ this.authClient.getService<AuthServiceClient>('AuthService')
73
+ }
74
+
75
+ // ... use authServiceClient
76
+ }
77
+ ```
78
+
79
+ ### Using Utilities
80
+
81
+ ```typescript
82
+ import { timestampToISO, RpcStatus } from '@3d-outlet/common'
83
+ import { Timestamp } from '@3d-outlet/contracts/gen/ts/google/protobuf/timestamp'
84
+
85
+ const grpcTimestamp: Timestamp = { seconds: 1678886400, nanos: 0 } // Example
86
+ const isoString = timestampToISO(grpcTimestamp)
87
+ console.log(isoString) // "2023-03-15T00:00:00.000Z"
88
+
89
+ console.log(RpcStatus.OK) // 0
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 📁 Project Structure
95
+
96
+ ```
97
+ common/
98
+ ├── lib/ # TypeScript source files
99
+ │ ├── enums/ # Common enumerations, such as RpcStatus
100
+ │ ├── grpc/ # Modules and utilities for working with gRPC
101
+ │ │ ├── constants/ # gRPC constants
102
+ │ │ ├── decorators/ # Decorators for injecting gRPC clients
103
+ │ │ ├── factory/ # Factory for creating gRPC clients
104
+ │ │ └── registry/ # Registry of gRPC clients
105
+ │ └── utils/ # General utility functions
106
+ └── dist/ # Compiled JavaScript (after build)
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 🛠️ Development
112
+
113
+ ### Prerequisites
114
+
115
+ - **Node.js**: >= 16.0.0
116
+ - **TypeScript**: ^5.9.3
117
+
118
+ ### Building the Package
119
+
120
+ ```bash
121
+ # Install dependencies
122
+ npm install
123
+ # or
124
+ pnpm install
125
+ # or
126
+ bun install
127
+
128
+ # Build TypeScript
129
+ npm run build
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 📝 License
135
+
136
+ ISC © [TeaCoder](mailto:admin@teacoder.ru) & [Ilnaz Mingaleev](mailto:development@teamkaif.com)
137
+
138
+ ---
139
+
140
+ ## 👨‍💻 Authors
141
+
142
+ **TeaCoder (Vadim)**
143
+
144
+ - Email: [admin@teacoder.ru](mailto:admin@teacoder.ru)
145
+
146
+ **Ilnaz Mingaleev**
147
+
148
+ - Email: [development@teamkaif.com](mailto:development@teamkaif.com)
149
+
150
+ ---
151
+
152
+ <div align="center">
153
+
154
+ **Made with ❤️ for the 3D OUTLET project (private repo)**
155
+ Internal use only.
156
+
157
+ </div>
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@3d-outlet/common",
3
+ "version": "1.2.0",
4
+ "description": "Core shared components for Face3D microservice ecosystem",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "build": "tsc -p tsconfig.build.json",
15
+ "format": "prettier --write \"src/**/*.ts\""
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^24.10.1",
19
+ "@3d-outlet/core": "^1.0.1",
20
+ "prettier": "^3.7.3",
21
+ "typescript": "^5.9.3"
22
+ },
23
+ "dependencies": {
24
+ "@3d-outlet/contracts": "^1.0.0",
25
+ "@nestjs/common": "^11.1.9",
26
+ "@nestjs/config": "^4.0.2",
27
+ "@nestjs/microservices": "^11.1.9"
28
+ }
29
+ }