Skip to content

Commit 62216c7

Browse files
authored
Merge pull request #1 from th3hero/RV-ENH
RV-ENH [SEO ENHANCEMENTS] - Enhance docs, metadata, and workflows for v1.1.8
2 parents bc21cd2 + 3cde94c commit 62216c7

10 files changed

Lines changed: 479 additions & 62 deletions

File tree

.github/profile/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Hi there, I'm Alok Kumar 👋
2+
3+
## 🚀 Full-Stack Developer & Open Source Enthusiast
4+
5+
I'm passionate about building robust, scalable applications and contributing to the open-source community. Currently focused on Node.js, TypeScript, and modern web technologies.
6+
7+
### 🔥 Featured Project
8+
9+
**[@th3hero/request-validator](https://github.com/th3hero/request-validator)** - A lightweight, fast & flexible request validation library for Node.js with TypeScript support.
10+
11+
[![npm version](https://img.shields.io/npm/v/@th3hero/request-validator.svg)](https://www.npmjs.com/package/@th3hero/request-validator)
12+
[![npm downloads](https://img.shields.io/npm/dm/@th3hero/request-validator.svg)](https://www.npmjs.com/package/@th3hero/request-validator)
13+
[![GitHub stars](https://img.shields.io/github/stars/th3hero/request-validator.svg)](https://github.com/th3hero/request-validator)
14+
15+
**Key Features:**
16+
- ✅ Zero external dependencies
17+
- ✅ 20+ built-in validation rules
18+
- ✅ Database integration (MySQL)
19+
- ✅ File upload validation
20+
- ✅ TypeScript first
21+
- ✅ Framework agnostic
22+
23+
### 🛠️ Tech Stack
24+
25+
![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
26+
![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)
27+
![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
28+
![Next.js](https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=next.js&logoColor=white)
29+
![Express.js](https://img.shields.io/badge/Express.js-000000?style=for-the-badge&logo=express&logoColor=white)
30+
![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white)
31+
![MySQL](https://img.shields.io/badge/MySQL-00000F?style=for-the-badge&logo=mysql&logoColor=white)
32+
33+
### 📊 GitHub Stats
34+
35+
![GitHub stats](https://github-readme-stats.vercel.app/api?username=th3hero&show_icons=true&theme=radical)
36+
37+
### 📫 Connect with Me
38+
39+
[![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://linkedin.com/in/th3hero)
40+
[![Twitter](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/th3hero)
41+
[![GitHub Sponsors](https://img.shields.io/badge/Sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/th3hero)
42+
43+
---
44+
45+
**Star my repositories if you find them helpful!**

.github/workflows/publish-npm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish Over NPM
22

33
on:
44
release:
5-
types: [ created ]
5+
types: [created]
66

77
permissions:
88
id-token: write
@@ -31,4 +31,4 @@ jobs:
3131
- name: Publish to NPM
3232
run: npm publish --access public --provenance
3333
env:
34-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish Over Github Packages
22

33
on:
44
release:
5-
types: [ created ]
5+
types: [created]
66

77
jobs:
88
build:
@@ -29,9 +29,9 @@ jobs:
2929
- name: Create .npmrc file
3030
run: |
3131
echo "@th3hero:registry=https://npm.pkg.github.com/" >> .npmrc
32-
echo "//npm.pkg.github.com/:_authToken=${{secrets.GITHUB_TOKEN}}" >> .npmrc
32+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
3333
3434
- name: Publish to GitHub Packages
3535
run: npm publish --access public
3636
env:
37-
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
37+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.8] - 2025-10-05
9+
10+
### Added
11+
- Enhanced package description with emojis and key benefits
12+
- Expanded keywords list (30+ targeted terms) for better discoverability
13+
- Added comprehensive examples documentation (EXAMPLES.md)
14+
- Created detailed documentation structure (docs/README.md)
15+
- Added comparison table vs competitors (Joi, Yup, express-validator)
16+
- Enhanced README with better visual hierarchy and badges
17+
- Added GitHub profile README to showcase the package
18+
- Improved package.json metadata (author details, funding, maintainers)
19+
20+
### Changed
21+
- Updated package description for better SEO and marketing
22+
- Enhanced README with "Why choose" section highlighting unique advantages
23+
- Added social links and sponsorship options
24+
- Improved competitive positioning and feature comparison
25+
26+
## [1.1.7] - 2024-06-14
27+
28+
### Changed
29+
- Updated package configuration for dual registry publishing
30+
- Enhanced GitHub Actions workflows
31+
- Improved NPM publishing with provenance
32+
33+
## [1.1.6] - 2024-06-14
34+
35+
### Changed
36+
- Fixed workflow authentication issues
37+
- Updated package configuration
38+
39+
## [1.1.5] - 2024-06-14
40+
41+
### Changed
42+
- Added GitHub Packages publishing support
43+
- Updated repository configuration
44+
45+
## [1.1.4] - 2024-06-14
46+
47+
### Changed
48+
- Updated package.json configuration
49+
- Fixed repository URL format
50+
851
## [1.1.0] - 2024-03-19
952

1053
### Added

EXAMPLES.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# @th3hero/request-validator Examples
2+
3+
## 🚀 Real-World Usage Examples
4+
5+
### E-commerce API Validation
6+
7+
```typescript
8+
import { validateInput } from '@th3hero/request-validator';
9+
import { Request } from 'express';
10+
11+
// Product creation validation
12+
const productRules = {
13+
name: 'required|min:3|max:100',
14+
price: 'required|numeric|min:0',
15+
category: 'required|in:electronics,clothing,books,home',
16+
description: 'max:500',
17+
images: 'file|mimetype:image/jpeg,image/png|max:5',
18+
sku: 'required|unique:products,sku',
19+
stock: 'integer|min:0'
20+
};
21+
22+
app.post('/products', async (req: Request, res) => {
23+
const result = await validateInput(req, productRules);
24+
25+
if (result.failed) {
26+
return res.status(400).json({
27+
success: false,
28+
errors: result.errors
29+
});
30+
}
31+
32+
// Create product...
33+
res.status(201).json({ success: true, product: newProduct });
34+
});
35+
```
36+
37+
### User Registration with Custom Validators
38+
39+
```typescript
40+
const customValidators = {
41+
isStrongPassword: (value: string) => {
42+
const hasUpperCase = /[A-Z]/.test(value);
43+
const hasLowerCase = /[a-z]/.test(value);
44+
const hasNumbers = /\d/.test(value);
45+
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(value);
46+
47+
if (!hasUpperCase || !hasLowerCase || !hasNumbers || !hasSpecialChar) {
48+
return 'Password must contain uppercase, lowercase, number, and special character';
49+
}
50+
return true;
51+
},
52+
53+
isAdult: (value: string) => {
54+
const age = parseInt(value);
55+
const today = new Date();
56+
const birthDate = new Date(value);
57+
const ageDiff = today.getFullYear() - birthDate.getFullYear();
58+
59+
return ageDiff >= 18 || 'Must be at least 18 years old';
60+
}
61+
};
62+
63+
const registrationRules = {
64+
username: 'required|min:3|max:20|unique:users,username',
65+
email: 'required|email|unique:users,email',
66+
password: 'required|min:8|isStrongPassword',
67+
confirmPassword: 'required|same:password',
68+
birthDate: 'required|date|isAdult',
69+
terms: 'required|accepted'
70+
};
71+
72+
app.post('/register', async (req: Request, res) => {
73+
const result = await validateInput(req, {
74+
...registrationRules,
75+
customValidators
76+
});
77+
78+
if (result.failed) {
79+
return res.status(400).json({ errors: result.errors });
80+
}
81+
82+
// Create user account...
83+
});
84+
```
85+
86+
### File Upload with Multiple Types
87+
88+
```typescript
89+
const uploadRules = {
90+
profilePicture: 'file|mimetype:image/jpeg,image/png|max:2',
91+
documents: 'file|mimetype:application/pdf,application/msword|max:10',
92+
video: 'file|mimetype:video/mp4,video/avi|max:50'
93+
};
94+
95+
app.post('/upload', async (req: Request, res) => {
96+
const result = await validateInput(req, uploadRules);
97+
98+
if (result.failed) {
99+
return res.status(400).json({ errors: result.errors });
100+
}
101+
102+
// Process uploads...
103+
const files = result.data;
104+
// files.profilePicture, files.documents, files.video
105+
});
106+
```
107+
108+
### API Rate Limiting with Validation
109+
110+
```typescript
111+
const apiKeyRules = {
112+
'x-api-key': 'required|exists:api_keys,key',
113+
'x-user-id': 'required|exists:users,id'
114+
};
115+
116+
app.use('/api/*', async (req: Request, res, next) => {
117+
const result = await validateInput(req, apiKeyRules);
118+
119+
if (result.failed) {
120+
return res.status(401).json({
121+
error: 'Invalid API credentials',
122+
details: result.errors
123+
});
124+
}
125+
126+
// Add user info to request
127+
req.user = result.data;
128+
next();
129+
});
130+
```
131+
132+
### Form Validation with Conditional Rules
133+
134+
```typescript
135+
const surveyRules = {
136+
name: 'required|min:2',
137+
email: 'required|email',
138+
age: 'required|integer|min:13',
139+
occupation: 'required|in:student,employed,unemployed,retired',
140+
salary: 'required_if:occupation,employed|numeric|min:0',
141+
education: 'required_if:occupation,student|in:high_school,college,university',
142+
interests: 'array|min:1|max:5'
143+
};
144+
145+
app.post('/survey', async (req: Request, res) => {
146+
const result = await validateInput(req, surveyRules);
147+
148+
if (result.failed) {
149+
return res.status(400).json({ errors: result.errors });
150+
}
151+
152+
// Process survey...
153+
});
154+
```
155+
156+
### Database-Driven Validation
157+
158+
```typescript
159+
// Set up database connection
160+
import { setDatabase } from '@th3hero/request-validator';
161+
import mysql from 'mysql';
162+
163+
const pool = mysql.createPool({
164+
host: process.env.DB_HOST,
165+
user: process.env.DB_USER,
166+
password: process.env.DB_PASSWORD,
167+
database: process.env.DB_NAME
168+
});
169+
170+
setDatabase(pool);
171+
172+
// Validation with database checks
173+
const orderRules = {
174+
productId: 'required|exists:products,id',
175+
userId: 'required|exists:users,id',
176+
quantity: 'required|integer|min:1',
177+
shippingAddress: 'required|min:10'
178+
};
179+
180+
app.post('/orders', async (req: Request, res) => {
181+
const result = await validateInput(req, orderRules);
182+
183+
if (result.failed) {
184+
return res.status(400).json({ errors: result.errors });
185+
}
186+
187+
// Create order...
188+
});
189+
```
190+
191+
## 🎯 Best Practices Demonstrated
192+
193+
1. **Specific Validation Rules**: Use detailed rules instead of generic ones
194+
2. **Custom Validators**: For complex business logic
195+
3. **Database Integration**: For data integrity
196+
4. **File Upload Security**: Proper MIME type validation
197+
5. **Error Handling**: Consistent error responses
198+
6. **Conditional Validation**: Based on other field values
199+
200+
## 📚 More Examples
201+
202+
<!-- Link to Express.js Integration Examples removed -->
203+
<!-- Link to Next.js API Routes removed -->
204+
<!-- Link to Fastify Plugin Examples removed -->
205+
<!-- Link to Testing Examples removed -->

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Alok Kumar Singh
3+
Copyright (c) 2024-2025 Alok Kumar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)