Skip to content

panates/opra

Repository files navigation


What is OPRA?

OPRA is a TypeScript framework for building RICH APIs — APIs that go beyond simple REST endpoints. Define your schema once and get validation, documentation, and a fully typed client for free. Run the same service over HTTP, WebSocket, Kafka, RabbitMQ, or Socket.io without changing your business logic.

@ComplexType({ description: 'Application user' })
export class User {
  @ApiField({ type: 'integer' }) declare id: number;
  @ApiField() declare name: string;
  @ApiField() declare email: string;
}

@HttpController({ path: 'users' })
export class UsersController {
  @HttpOperation.Entity.FindMany({ type: User })
  async findMany() { }

  @HttpOperation.Entity.GetOne({ type: User })
  @HttpOperation.PathParam('id', 'integer')
  async getOne(id: number) { }
}

That's it — schema, validation, docs, and a typed client are all derived automatically.


Why OPRA?

Without OPRA With OPRA
Define models, write OpenAPI spec, add validation — keep all three in sync Define once. Everything else is derived.
Handwrite an HTTP client. Update it every time something changes Run oprimp. Get a fully typed client.
Implement pagination, filtering, sorting for every entity Extend a base service class — it's built in
Separate implementations for HTTP, WebSocket, Kafka, RabbitMQ One schema. All transports.
Write docs separately. Watch them drift Docs are always correct — they can't not be

Packages

OPRA is a monorepo. Pick what you need:

Package Description
@opra/common Core schema model, decorators, type system, filter DSL
@opra/core Runtime engine — request lifecycle, validation, routing
@opra/http Standalone HTTP adapter
@opra/client Auto-generated type-safe HTTP client
@opra/cli CLI tools — oprimp for client generation
@opra/nestjs NestJS integration
@opra/nestjs-http NestJS HTTP adapter
@opra/nestjs-kafka NestJS + Kafka transport
@opra/nestjs-rabbitmq NestJS + RabbitMQ transport
@opra/nestjs-socketio NestJS + Socket.io transport
@opra/kafka Standalone Kafka transport
@opra/rabbitmq Standalone RabbitMQ transport
@opra/socketio Standalone Socket.io transport
@opra/mongodb MongoDB data service base
@opra/elastic Elasticsearch data service base
@opra/sqb SQL (SQB) data service base
@opra/angular Angular client integration
@opra/testing Testing utilities

Quick Start

npm install @opra/common @opra/core @opra/nestjs-http

See the Getting Started guide for a complete walkthrough.


Node Compatibility

  • node >= 20.x

Support

Found a bug or have a question? Open an issue on the GitHub issues page. Please include your Node.js version when reporting bugs.


License

OPRA is available under the MIT license.


Packages

 
 
 

Contributors

Languages