keyport-nestjs
v1.0.1
Published
NestJS integration for the live KeyPort public API
Downloads
7
Maintainers
Readme
keyport-nestjs
NestJS module, service, guard, and decorators for the live KeyPort public API.
Install
npm install keyport-nestjs keyport-nodeDirect API key usage
import { Module } from '@nestjs/common'
import { KeyPortModule } from 'keyport-nestjs'
@Module({
imports: [KeyPortModule.forRoot({ apiKey: process.env.KEYPORT_API_KEY! })],
})
export class AppModule {}JSON config file usage
{
"api_key": "kp_live_xxx",
"base_url": "https://api.keyport.sbs/api/v1",
"timeout": 10000
}@Module({
imports: [KeyPortModule.forRoot({ configPath: './keyport.json' })],
})
export class AppModule {}API key in code, rest from config
@Module({
imports: [
KeyPortModule.forRoot({
configPath: './keyport.json',
apiKey: process.env.KEYPORT_API_KEY,
}),
],
})
export class AppModule {}Decorator usage
import { Controller, Get } from '@nestjs/common'
import { License, RequireLicense } from 'keyport-nestjs'
@Controller('features')
export class FeaturesController {
@Get()
@RequireLicense({ version: '1.2.0' })
list(@License() license: { status: string }) {
return { status: license.status }
}
}Notes
keyport-nestjswrapskeyport-node; it does not implement its own HTTP client- the guard validates through the live
POST /api/v1/validateendpoint and attaches the payload to the request
