Skip to content

Commit

Permalink
docs: refine usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
axi92 committed Nov 26, 2024
1 parent 60ee862 commit 2f9bc54
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,55 @@

Client implementation for the EVVA Auth Service.

## Build & Package
```bash
# Nest Build
$ nest build
```
## Install


## Usage

```
import {ConfigService } from '@nestjs/config';
import {
AuthClientModule,
AuthClientService,
AuthClientOptions,
AUTH_ENDPOINT,
AUTH_TENANT,
*In app.module.ts as imports*

```ts
import { ConfigModule, ConfigService } from '@nestjs/config';
import {
AUTH_CLIENT,
AUTH_ENDPOINT,
AUTH_SECRET,
AUTH_TENANT,
AUTH_VALIDITY,
VAULT_JWTROLE_IDENTIFIER,
VAULT_ENDPOINT,
AuthClientModule,
AuthClientModuleOptions,
VAULT_CA,
VAULT_ENDPOINT,
VAULT_JWTROLE_IDENTIFIER,
} from '@evva/nest-auth-client';

AuthClientModule.forRootAsync({
@Module({
imports: [
AuthClientModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) =>
useFactory: async (configService: ConfigService) =>
({
authEndpoint: configService.get<string>(AUTH_ENDPOINT), //use optional
authTenant: configService.get<string>(AUTH_TENANT),
authClientId: configService.get<string>(AUTH_CLIENT),
authClientSecret: configService.get<string>(AUTH_SECRET),
authValidity: parseInt(configService.get(AUTH_VALIDITY)), // in seconds, see spec
vaultRoleId: configService.get<string>(AULT_JWTROLE_IDENTIFIER),
vaultRoleId: configService.get<string>(VAULT_JWTROLE_IDENTIFIER),
vaultEndpoint: configService.get<string>(VAULT_ENDPOINT),
vaultCA: configService.get<string>(VAULT_CA)
}) as AuthClientOptions,
vaultCA: configService.get<string>(VAULT_CA),
}) as AuthClientModuleOptions,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
```

When using the ConfigService, make sure that the variables are loaded before accessing them.
This usually works as follows:
```
```ts
export class MyModule implements OnModuleInit {


Expand All @@ -62,6 +67,12 @@ export class MyModule implements OnModuleInit {
}
```

## Build & Package
```bash
# Nest Build
$ nest build
```

## Support

## Stay in touch
Expand Down

0 comments on commit 2f9bc54

Please sign in to comment.