updated README.md
This commit is contained in:
parent
b22a1c973c
commit
ea191bfa60
47
README.md
47
README.md
@ -11,26 +11,27 @@ A simple, secure, and flexible licensing library built for Node.js, React, Next.
|
||||
|
||||
```bash
|
||||
npm install license-lib
|
||||
```
|
||||
|
||||
|
||||
Environment Setup
|
||||
Create a .env file at the root with your database and JWT configuration:
|
||||
|
||||
env
|
||||
JWT_SECRET=your_jwt_secret
|
||||
```JWT_SECRET=your_jwt_secret
|
||||
DB_HOST=localhost
|
||||
DB_NAME=license_db
|
||||
DB_USER_ADMIN=license_admin
|
||||
DB_PASS_ADMIN=secure_admin_password
|
||||
DB_USER_READER=license_reader
|
||||
DB_PASS_READER=secure_reader_password
|
||||
```
|
||||
|
||||
|
||||
⚙️ Database Setup
|
||||
Use the provided SQL script to set up your database:
|
||||
|
||||
sql
|
||||
Copy code
|
||||
```sql
|
||||
CREATE DATABASE license_db;
|
||||
|
||||
USE license_db;
|
||||
@ -52,52 +53,58 @@ CREATE USER 'license_admin'@'%' IDENTIFIED BY 'secure_admin_password';
|
||||
GRANT SELECT, INSERT, UPDATE ON license_db.* TO 'license_admin'@'%';
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
📦 API Endpoints
|
||||
|
||||
Generate License
|
||||
|
||||
POST /generate-license
|
||||
|
||||
Body:
|
||||
|
||||
json
|
||||
Copy code
|
||||
```json
|
||||
{
|
||||
"userId": "user123",
|
||||
"licenseType": "subscription",
|
||||
"tier": "pro",
|
||||
"validUntil": "2024-12-31"
|
||||
}
|
||||
```
|
||||
Response:
|
||||
|
||||
json
|
||||
```json
|
||||
Copy code
|
||||
{
|
||||
"licenseKey": "generated.jwt.token"
|
||||
}
|
||||
```
|
||||
|
||||
Validate License
|
||||
|
||||
POST /validate-license
|
||||
|
||||
Body:
|
||||
|
||||
json
|
||||
```json
|
||||
Copy code
|
||||
{
|
||||
"userId": "user123",
|
||||
"licenseKey": "generated.jwt.token"
|
||||
}
|
||||
```
|
||||
Response:
|
||||
|
||||
json
|
||||
Copy code
|
||||
```json
|
||||
{
|
||||
"valid": true
|
||||
}
|
||||
```
|
||||
|
||||
🎯 Client Integration
|
||||
Import functions directly from the client module:
|
||||
|
||||
javascript
|
||||
Copy code
|
||||
```javascript
|
||||
import { activateLicense, generateFingerprint } from './client';
|
||||
|
||||
// Validate license
|
||||
@ -105,11 +112,12 @@ const valid = await activateLicense(userId, licenseKey);
|
||||
|
||||
// Device fingerprinting
|
||||
const fingerprint = generateFingerprint();
|
||||
```
|
||||
|
||||
⚛️ React Integration
|
||||
Use the provided React hook and provider:
|
||||
|
||||
jsx
|
||||
Copy code
|
||||
```jsx
|
||||
import { LicenseProvider } from './react/LicenseProvider';
|
||||
import useLicense from './react/useLicense';
|
||||
|
||||
@ -123,11 +131,12 @@ const YourApp = () => {
|
||||
const { isLicensed } = useLicense();
|
||||
return <div>{isLicensed ? 'Licensed!' : 'Not Licensed!'}</div>;
|
||||
};
|
||||
```
|
||||
|
||||
▲ Next.js Integration
|
||||
Wrap your component easily:
|
||||
|
||||
jsx
|
||||
Copy code
|
||||
```jsx
|
||||
import withLicense from './nextjs/withLicense';
|
||||
|
||||
const Page = ({ isLicensed }) => (
|
||||
@ -135,10 +144,4 @@ const Page = ({ isLicensed }) => (
|
||||
);
|
||||
|
||||
export default withLicense(Page, { userId: 'user123', licenseKey: 'jwt.token' });
|
||||
📌 License
|
||||
This project is licensed under MIT.
|
||||
|
||||
vbnet
|
||||
Copy code
|
||||
|
||||
Your licensing library is now fully documented and ready for developers to integrate easily into their projects.
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user