Skip to main content

Installation

Setup and usage

1

Register the module

Import KeyPortModule and call forRoot inside the imports array of your root AppModule. Supply your API key directly or point to a config file:
2

Protect a route

Add the @RequireLicense() decorator to any controller method to enforce license validation on that endpoint:
Use the @License() parameter decorator to access the validated license payload inside the handler.
@RequireLicense() acts as a guard. Requests without a valid license key are rejected before your handler runs.
Load your API key from an environment variable (process.env.KEYPORT_API_KEY) or the NestJS ConfigModule rather than embedding it in source code.