Search…
Driving License

Driving License Client

About

This library implements a client to use Ríkislögreglustjóri's Driver's license API v1 and v2 through x-road
The client is generated from a copy of the openApi document provided in x-road.

Quickstart

Run the following and start developing:
1
yarn nx run clients-driving-license:dev
Copied!
This command bundles updating the api definition and regenerating the client.

Usage

Updating the open api definition (clientConfig.json)

1
yarn nx run clients-driving-license:update-openapi-document --apiVersion=v1
Copied!
or
1
yarn nx run clients-driving-license:update-openapi-document --apiVersion=v2
Copied!

Regenerating the client:

1
yarn nx run clients-driving-license:schemas/external-openapi-generator
Copied!

Import into other NestJS modules

Add the service to your module imports:
1
import { DrivingLicenseApiModule } from '@island.is/clients/driving-license'
2
3
@Module({
4
imports: [
5
DrivingLicenseApiModule.register({
6
xroadBaseUrl: XROAD_BASE_URL,
7
xroadClientId: XROAD_CLIENT_ID,
8
secret: DRIVING_LICENSE_SECRET,
9
xroadPathV1: DRIVING_LICENSE_XROAD_PATH,
10
xroadPathV2: DRIVING_LICENSE_XROAD_PATH_V2,
11
}),
12
],
13
})
Copied!
Since the generated class names are pretty similar for v1 / v2 of the API, and neither is a subset of the other, all the API calls are wrapped, so that they share a uniform API, and the intent is that the consumer of the client does not need to be aware of which version of the API they are communicating with
1
import { DrivingLicenseApi } from '@island.is/clients/driving-license'
2
3
@Injectable()
4
export class SomeService {
5
constructor(private readonly drivingLicenseApi: DrivingLicenseApi) {}
6
7
// etc...
8
}
Copied!

Code owners and maintainers