Skip to content

Commit d56a275

Browse files
committed
chore: linting
1 parent 4197902 commit d56a275

5 files changed

Lines changed: 105 additions & 81 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ npm install @concepta/rockets-server @concepta/nestjs-typeorm-ext typeorm
3434

3535
### Basic Setup
3636

37-
This is the minimum required setup to get started with Rockets Server. You'll need to create your entities and configure the module as follows:
38-
37+
This is the minimum required setup to get started with Rockets Server.
38+
You'll need to create your entities and configure the module as follows:
3939

4040
```typescript
4141
// app.module.ts

packages/rockets-server/README.md

Lines changed: 77 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ maintaining flexibility for customization and extension.
7272
### Installation
7373

7474
**⚠️ CRITICAL: Alpha Version Issue**:
75-
> **The current alpha version (7.0.0-alpha.4) has a dependency injection issue with AuthJwtGuard that prevents the minimal setup from working. This is a known issue being investigated.**
75+
76+
> **The current alpha version (7.0.0-alpha.4) has a dependency injection
77+
> issue with AuthJwtGuard that prevents the minimal setup from working. This
78+
> is a known issue being investigated.**
7679
7780
**Version Requirements**:
81+
7882
- NestJS: `^10.0.0`
7983
- Node.js: `>=18.0.0`
8084
- TypeScript: `>=4.8.0`
@@ -85,11 +89,12 @@ Let's create a new NestJS project:
8589
npx @nestjs/cli@10 new my-app-with-rockets --package-manager yarn --language TypeScript --strict
8690
```
8791

88-
8992
Install the Rockets SDK and all required dependencies:
9093

9194
```bash
92-
yarn add @bitwild/rockets-server @concepta/nestjs-typeorm-ext @concepta/nestjs-common typeorm @nestjs/typeorm @nestjs/config @nestjs/swagger
95+
yarn add @bitwild/rockets-server @concepta/nestjs-typeorm-ext \
96+
@concepta/nestjs-common typeorm @nestjs/typeorm @nestjs/config \
97+
@nestjs/swagger
9398
```
9499

95100
**Database Support**: Choose your database driver:
@@ -105,7 +110,6 @@ yarn add pg
105110
yarn add mysql2
106111
```
107112

108-
109113
---
110114

111115
## Tutorial
@@ -374,7 +378,8 @@ Expected response (200 OK):
374378
**Note**: The login endpoint returns a 200 OK status (not 201 Created) as it's retrieving
375379
tokens, not creating a new resource.
376380

377-
**Defaults Working**: All authentication endpoints work out-of-the-box with sensible defaults.
381+
**Defaults Working**: All authentication endpoints work out-of-the-box with
382+
sensible defaults.
378383

379384
#### 4. Access Protected Endpoint
380385

@@ -438,30 +443,37 @@ you restart the application. This is perfect for testing and development!
438443

439444
#### Common Issues
440445

441-
**AuthJwtGuard Dependency Error**
446+
#### AuthJwtGuard Dependency Error
442447

443448
If you encounter this error:
444-
```
445-
Nest can't resolve dependencies of the AuthJwtGuard (AUTHENTICATION_MODULE_SETTINGS_TOKEN, ?). Please make sure that the argument Reflector at index [1] is available in the AuthJwtModule context.
449+
450+
```text
451+
Nest can't resolve dependencies of the AuthJwtGuard
452+
(AUTHENTICATION_MODULE_SETTINGS_TOKEN, ?). Please make sure that the
453+
argument Reflector at index [1] is available in the AuthJwtModule context.
446454
```
447455

448-
****Solution: Version Compatibility Issues**
456+
#### Module Resolution Errors
449457

450458
If you're getting dependency resolution errors:
451459

452460
1. **NestJS Version**: Ensure you're using NestJS `^10.0.0`
453-
2. **Alpha Packages**: All `@concepta/*` packages should use the same alpha version (e.g., `^7.0.0-alpha.4`)
454-
3. **Clean Installation**: Try deleting `node_modules` and `package-lock.json`, then run `yarn install`
461+
2. **Alpha Packages**: All `@concepta/*` packages should use the same alpha
462+
version (e.g., `^7.0.0-alpha.4`)
463+
3. **Clean Installation**: Try deleting `node_modules` and `package-lock.json`,
464+
then run `yarn install`
455465

456-
**Module Resolution Errors**
466+
#### Module Resolution Errors (TypeScript)
457467

458468
If TypeScript can't find modules like `@concepta/nestjs-typeorm-ext`:
459469

460470
```bash
461-
yarn add @concepta/nestjs-typeorm-ext @concepta/nestjs-common --save
471+
yarn add @concepta/nestjs-typeorm-ext @concepta/nestjs-common \
472+
--save
462473
```
463474

464-
All dependencies listed in the installation section are required and must be installed explicitly.
475+
All dependencies listed in the installation section are required and must be
476+
installed explicitly.
465477

466478
---
467479

@@ -510,26 +522,26 @@ interface RocketsServerOptionsInterface {
510522

511523
### settings
512524

513-
**What it does**: Global settings that configure the custom OTP and email
514-
services provided by RocketsServer. These settings are used by the custom OTP
525+
**What it does**: Global settings that configure the custom OTP and email
526+
services provided by RocketsServer. These settings are used by the custom OTP
515527
controller and notification services, not by the core authentication modules.
516528

517-
**Core services it connects to**: RocketsServerOtpService,
529+
**Core services it connects to**: RocketsServerOtpService,
518530
RocketsServerNotificationService
519531

520-
**When to update**: Required when using the custom OTP endpoints
521-
(`POST /otp`, `PATCH /otp`). The defaults use placeholder values that won't
532+
**When to update**: Required when using the custom OTP endpoints
533+
(`POST /otp`, `PATCH /otp`). The defaults use placeholder values that won't
522534
work in real applications.
523535

524-
**Real-world example**: Setting up email configuration for the custom OTP
536+
**Real-world example**: Setting up email configuration for the custom OTP
525537
system:
526538

527539
```typescript
528540
settings: {
529541
email: {
530542
from: 'noreply@mycompany.com',
531543
baseUrl: 'https://app.mycompany.com',
532-
tokenUrlFormatter: (baseUrl, token) =>
544+
tokenUrlFormatter: (baseUrl, token) =>
533545
`${baseUrl}/auth/verify?token=${token}&utm_source=email`,
534546
templates: {
535547
sendOtp: {
@@ -575,6 +587,7 @@ three key services:
575587
**When to update**: When you need to customize core authentication behavior,
576588
provide custom token services or change how the token payload is structured.
577589
Common scenarios include:
590+
578591
- Implementing custom token verification logic
579592
- Adding business-specific token validation rules
580593
- Modifying token generation and payload structure
@@ -594,7 +607,8 @@ authentication: {
594607
}
595608
```
596609

597-
**Note**: All token services have working defaults. Only customize if you need specific business logic.
610+
**Note**: All token services have working defaults. Only customize if you need
611+
specific business logic.
598612

599613
---
600614

@@ -605,30 +619,37 @@ and token services.
605619

606620
**Core modules it connects to**: JwtModule, AuthJwtModule, AuthRefreshModule
607621

608-
**When to update**: Only needed if loading JWT settings from a source other than
622+
**When to update**: Only needed if loading JWT settings from a source other than
609623
environment variables (e.g. config files, external services, etc).
610624

611-
**Environment Variables**: The JWT module automatically uses these environment variables with sensible defaults:
625+
**Environment Variables**: The JWT module automatically uses these environment
626+
variables with sensible defaults:
612627

613628
- `JWT_MODULE_DEFAULT_EXPIRES_IN` (default: `'1h'`)
614629
- `JWT_MODULE_ACCESS_EXPIRES_IN` (default: `'1h'`)
615-
- `JWT_MODULE_REFRESH_EXPIRES_IN` (default: `'99y'`)
616-
- `JWT_MODULE_ACCESS_SECRET` (required in production, auto-generated in development, if not provided)
630+
- `JWT_MODULE_REFRESH_EXPIRES_IN` (default: `'99y'`)
631+
- `JWT_MODULE_ACCESS_SECRET` (required in production, auto-generated in
632+
development, if not provided)
617633
- `JWT_MODULE_REFRESH_SECRET` (defaults to access secret if not provided)
618634

619635
**Default Behavior**:
636+
620637
- **Development**: JWT secrets are auto-generated if not provided
621-
- **Production**: `JWT_MODULE_ACCESS_SECRET` is required (with NODE_ENV=production)
622-
- **Token Services**: Default `JwtIssueTokenService` and `JwtVerifyTokenService` are provided
638+
- **Production**: `JWT_MODULE_ACCESS_SECRET` is required (with
639+
NODE_ENV=production)
640+
- **Token Services**: Default `JwtIssueTokenService` and
641+
`JwtVerifyTokenService` are provided
623642
- **Multiple Token Types**: Separate access and refresh token handling
624643

625644
**Security Notes**:
645+
626646
- Production requires explicit JWT secrets for security
627647
- Development auto-generates secrets for convenience
628648
- Refresh tokens have longer expiration by default
629649
- All token operations are handled automatically
630650

631-
**Real-world example**: Custom JWT configuration (optional - defaults work for most cases):
651+
**Real-world example**: Custom JWT configuration (optional - defaults work
652+
for most cases):
632653

633654
```typescript
634655
jwt: {
@@ -657,9 +678,11 @@ jwt: {
657678
jwtVerifyTokenService: new CustomJwtVerifyService(),
658679
}
659680
```
660-
```
661-
**Note**: Environment variables are automatically used for secrets and expiration times. Only customize `jwt.settings` if you need specific JWT options like issuer/audience, you can also use the environment variables to configure the JWT module.
662-
```
681+
682+
**Note**: Environment variables are automatically used for secrets and
683+
expiration times. Only customize `jwt.settings` if you need specific JWT
684+
options like issuer/audience, you can also use the environment variables to
685+
configure the JWT module.
663686

664687
---
665688

@@ -696,9 +719,9 @@ authJwt: {
696719
userModelService: new CustomUserLookupService(),
697720
}
698721
```
699-
```
700-
**Note**: Default token extraction uses standard Bearer token from Authorization header. Only customize if you need alternative token sources.
701-
```
722+
723+
**Note**: Default token extraction uses standard Bearer token from
724+
Authorization header. Only customize if you need alternative token sources.
702725

703726
---
704727

@@ -728,13 +751,13 @@ authLocal: {
728751
}
729752
```
730753

731-
```
732754
**Environment Variables**:
755+
733756
- `AUTH_LOCAL_USERNAME_FIELD` - defaults to `'username'`
734757
- `AUTH_LOCAL_PASSWORD_FIELD` - defaults to `'password'`
735758

736-
**Note**: The default services work automatically with your TypeORM User entity. Only customize if you need specific validation logic.
737-
```
759+
**Note**: The default services work automatically with your TypeORM User entity.
760+
Only customize if you need specific validation logic.
738761

739762
---
740763

@@ -882,13 +905,14 @@ password: {
882905
```
883906

884907
**Environment Variables**:
885-
- `PASSWORD_MIN_PASSWORD_STRENGTH` - defaults to `4` if production, `0` if development (0-4 scale)
908+
909+
- `PASSWORD_MIN_PASSWORD_STRENGTH` - defaults to `4` if production, `0` if
910+
development (0-4 scale)
886911
- `PASSWORD_MAX_PASSWORD_ATTEMPTS` - defaults to `3`
887912
- `PASSWORD_REQUIRE_CURRENT_TO_UPDATE` - defaults to `false`
888913

889-
```
890-
**Note**: Password strength is automatically calculated using zxcvbn. History tracking is optional and requires additional configuration.
891-
```
914+
**Note**: Password strength is automatically calculated using zxcvbn. History
915+
tracking is optional and requires additional configuration.
892916

893917
---
894918

@@ -915,6 +939,7 @@ interface OtpSettingsInterface {
915939
```
916940

917941
**Environment Variables**:
942+
918943
- `OTP_CLEAR_ON_CREATE` - defaults to `false`
919944
- `OTP_KEEP_HISTORY_DAYS` - no default (optional)
920945
- `OTP_RATE_SECONDS` - no default (optional)
@@ -1170,7 +1195,6 @@ services: {
11701195
}
11711196
```
11721197

1173-
11741198
---
11751199

11761200
## Explanation
@@ -1279,7 +1303,8 @@ const userModule = new UserModule(userConfig);
12791303
- Facilitates testing with mock repositories
12801304
- Provides flexibility for future data layer changes
12811305

1282-
**Implementation**: Uses the adapter pattern with a standardized repository interface to support multiple database types and ORMs.
1306+
**Implementation**: Uses the adapter pattern with a standardized repository
1307+
interface to support multiple database types and ORMs.
12831308

12841309
#### 4. Service Injection Pattern
12851310

@@ -1319,7 +1344,6 @@ services: {
13191344

13201345
The Rockets SDK implements a comprehensive authentication flow:
13211346

1322-
13231347
#### 1a. User Registration Flow
13241348

13251349
```mermaid
@@ -1341,6 +1365,7 @@ sequenceDiagram
13411365
```
13421366

13431367
**Services to customize for registration:**
1368+
13441369
- `PasswordStorageService` - Custom password hashing algorithms
13451370
- `UserModelService` - Custom user creation logic, validation, external systems integration
13461371

@@ -1373,6 +1398,7 @@ sequenceDiagram
13731398
```
13741399

13751400
**Services to customize for authentication:**
1401+
13761402
- `AuthLocalValidateUserService` - Custom credential validation logic
13771403
- `UserModelService` - Custom user lookup by username, email, or other fields
13781404
- `PasswordValidationService` - Custom password verification algorithms
@@ -1398,6 +1424,7 @@ sequenceDiagram
13981424
```
13991425

14001426
**Services to customize for token generation:**
1427+
14011428
- `IssueTokenService` - Custom JWT payload, token expiration, additional claims
14021429
- `JwtService` - Custom signing algorithms, token structure
14031430

@@ -1429,12 +1456,12 @@ sequenceDiagram
14291456
```
14301457

14311458
**Services to customize for protected routes:**
1459+
14321460
- `VerifyTokenService` - Custom token verification logic, blacklist checking
14331461
- `UserModelService` - Custom user lookup by subject/ID, user status validation
14341462

14351463
#### 2. OTP Verification Flow
14361464

1437-
14381465
```mermaid
14391466
sequenceDiagram
14401467
participant C as Client
@@ -1490,6 +1517,7 @@ sequenceDiagram
14901517
```
14911518

14921519
**Services to customize for token refresh:**
1520+
14931521
- `VerifyTokenService` - Custom refresh token verification, token rotation logic
14941522
- `UserModelService` - Custom user validation, account status checking
14951523
- `IssueTokenService` - Custom new token generation, token rotation policies
@@ -1527,6 +1555,7 @@ sequenceDiagram
15271555
```
15281556

15291557
**Services to customize for recovery request:**
1558+
15301559
- `UserModelService` - Custom user lookup by email
15311560
- `OtpService` - Custom OTP generation, expiry logic
15321561
- `NotificationService` - Custom email templates, delivery methods
@@ -1553,6 +1582,7 @@ sequenceDiagram
15531582
```
15541583

15551584
**Services to customize for passcode validation:**
1585+
15561586
- `OtpService` - Custom OTP validation, rate limiting
15571587

15581588
#### 4c. Password Update Flow
@@ -1589,14 +1619,14 @@ sequenceDiagram
15891619
```
15901620

15911621
**Services to customize for password update:**
1622+
15921623
- `OtpService` - Custom OTP validation and cleanup
15931624
- `UserModelService` - Custom user lookup validation
15941625
- `UserPasswordService` - Custom password hashing, policies
15951626
- `NotificationService` - Custom success notifications
15961627

15971628
---
15981629

1599-
16001630
This comprehensive documentation provides developers with everything they need
16011631
to understand, implement, and extend the Rockets SDK in their applications.
16021632
The modular design and extensive configuration options make it suitable for

0 commit comments

Comments
 (0)