zync-nest-library
v1.0.38
Published
NestJS library with database backup and file upload utilities
Downloads
180
Maintainers
Readme
🚀 Zync NestJS Library
A premium NestJS library suite designed for scalability and ease of integration. It provides enterprise-grade utilities for file management, payment gateways, messaging services, and advanced GraphQL support.
✨ Key Features
🛡️ Core Services
- File Upload Service: Powerful file handling with automatic image resizing and multiple storage providers.
- Bucket Service: Native integration with AWS S3 and DigitalOcean Spaces.
- Firebase Service: Robust push notification management using FCM.
- Mailer Service: Sophisticated email dispatch with customizable EJS templates.
💳 Payment Gateways
- Senangpay: Malaysian payment gateway with FPX support.
- Billplz: Seamless Malaysian payment integration.
- Razorpay: Comprehensive Indian payment gateway support.
✉️ Messaging
- Unified Message Service: A single interface to rule all channels (Email, SMS, WhatsApp, Push).
- UltraMsg: Direct WhatsApp messaging via API.
- Exabytes SMS: Reliable SMS gateway integration.
🛠️ Advanced Utilities
- GraphQL Scalars: Custom types like
ApStringOrArray. - GraphQL Directives: Depth limit protection to secure your API.
- HTML Converter: Puppeteer-driven HTML to PDF/String conversion.
- XLSX Service: Easy Excel generation and browser downloads.
- Swagger Decorators: Instant Swagger UI support for file uploads.
📦 Installation
local Setup
# Clone and install
git clone https://github.com/zynctech/zync-nest-library.git
cd zync-nest-library
pnpm install
# Build the library
pnpm run buildIntegration Methods
1. Direct File Link (Recommended for pnpm workspaces)
Add to your project's package.json:
{
"dependencies": {
"zync-nest-library": "file:../path/to/zync-nest-library"
}
}2. Local Linking
# In zync-nest-library
pnpm link --global
# In your project
pnpm link --global zync-nest-library📚 Module Usage
Base Setup
Import the modules you need in your AppModule:
import {
UploadModule,
FirebaseModule,
MailerModule,
ApScalarModule,
HtmlConverterModule
} from 'zync-nest-library';
@Module({
imports: [
UploadModule,
FirebaseModule,
MailerModule,
ApScalarModule,
HtmlConverterModule,
// ...
],
})
export class AppModule {}🧬 GraphQL Scalars
The library includes ApStringOrArray and ApNumber to handle flexible input types in GraphQL.
import { ApStringOrArrayScalar, ApNumberScalar } from 'zync-nest-library';
// In your Resolver or DTO
@Field(() => ApStringOrArrayScalar)
tags: string | string[];
@Field(() => ApNumberScalar)
price: number;📁 Upload Service
Handles local and cloud storage with automatic thumbnail generation.
@Injectable()
export class MyService {
constructor(private readonly uploadService: UploadService) {}
async handleUpload(file: Express.Multer.File) {
return await this.uploadService.uploadFile({
file: file.buffer,
filename: file.originalname,
filetype: file.mimetype,
dir: 'profiles',
transformName: true
});
}
}🔒 Depth Limit Directive
Protect your GraphQL server from circular or overly complex queries.
// app.module.ts
GraphQLModule.forRoot({
transformSchema: (schema) => deptLimitDirectiveTransformer(schema, 'deptLimit'),
})
// schema.graphql
type User {
posts: [Post!]! @deptLimit(value: "5")
}⚙️ Configuration
| Service | Environment Variables |
| :--- | :--- |
| AWS/S3 | aws_access_key_id, aws_secret_access_key, aws_s3_region, aws_bucket |
| Mailer | MAILER_HOST, MAILER_USER, MAILER_PASS, MAILER_FROM, MAILER_PORT |
| WhatsApp | ultramsg_instance, ultramsg_token, ultramsg_url |
| SMS | exabytes_sms_username, exabytes_sms_password, exabytes_sms_url |
[!IMPORTANT] Firebase requires a
serviceAccount.jsonfile in your project root. Google API requires acredentials.jsonfile in your project root.
🛠️ Development
Scripts
pnpm run build: Compile TypeScript files.pnpm run build:watch: Development mode with auto-rebuild.pnpm run clean: Removedistand build artifacts.
Folder Structure
libs/src/
├── billplz/ # Billplz Gateway
├── decorators/ # Swagger File Decorators
├── directives/ # GraphQL Directives
├── exabytes/ # SMS Service
├── firebase/ # Push Notifications
├── googleapi/ # Google Drive Service
├── htmlConverter/ # PDF Generator
├── mailer/ # EJS Email Service
├── message/ # Unified Messenger
├── scalars/ # Custom GQL Scalars
├── senangpay/ # Senangpay Gateway
├── upload/ # Multi-provider Uploads
└── xlsx/ # Excel Exporter🐛 Support
If you encounter issues, please open an issue in the GitHub Repository.
Developed with ❤️ by Zync Tech.
