Skip to content

Commit 713dd13

Browse files
committed
docs(readme): enhance usage examples with version parameter and data types 📚
1 parent d85536a commit 713dd13

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ const SecureJWT = require('@neabyte/secure-jwt').default
3737
const jwt = new SecureJWT({
3838
secret: 'your-secret-key-here',
3939
expireIn: '1h',
40+
version: '1.0.0',
4041
cached: 1000
4142
})
4243

44+
// Encode any data type
4345
const data = { userId: 123, role: 'admin' }
4446
const token = jwt.sign(data)
4547
const isValid = jwt.verify(token)
4648
const decoded = jwt.decode(token)
49+
50+
// Also works with strings, numbers, arrays, etc.
51+
const stringToken = jwt.sign('Hello World!')
52+
const numberToken = jwt.sign(42)
53+
const arrayToken = jwt.sign([1, 2, 3])
4754
```
4855

4956
### ES Modules (ESM)
@@ -54,13 +61,20 @@ import SecureJWT from '@neabyte/secure-jwt'
5461
const jwt = new SecureJWT({
5562
secret: 'your-secret-key-here',
5663
expireIn: '1h',
64+
version: '1.0.0',
5765
cached: 1000
5866
})
5967

68+
// Encode any data type
6069
const data = { userId: 123, role: 'admin' }
6170
const token = jwt.sign(data)
6271
const isValid = jwt.verify(token)
6372
const decoded = jwt.decode(token)
73+
74+
// Also works with strings, numbers, arrays, etc.
75+
const stringToken = jwt.sign('Hello World!')
76+
const numberToken = jwt.sign(42)
77+
const arrayToken = jwt.sign([1, 2, 3])
6478
```
6579

6680
### TypeScript
@@ -71,13 +85,20 @@ import SecureJWT from '@neabyte/secure-jwt'
7185
const jwt = new SecureJWT({
7286
secret: 'your-secret-key-here',
7387
expireIn: '1h',
88+
version: '1.0.0',
7489
cached: 1000
7590
})
7691

92+
// Encode any data type
7793
const data: { userId: number; role: string } = { userId: 123, role: 'admin' }
7894
const token: string = jwt.sign(data)
7995
const isValid: boolean = jwt.verify(token)
8096
const decoded: unknown = jwt.decode(token)
97+
98+
// Also works with strings, numbers, arrays, etc.
99+
const stringToken: string = jwt.sign('Hello World!')
100+
const numberToken: string = jwt.sign(42)
101+
const arrayToken: string = jwt.sign([1, 2, 3])
81102
```
82103

83104
---

0 commit comments

Comments
 (0)