Skip to content

Latest commit

 

History

History
149 lines (112 loc) · 3.8 KB

README.md

File metadata and controls

149 lines (112 loc) · 3.8 KB

Koatty 🚀

npm version License

Koa2 + Typescript + IOC = koatty. Koatty is a progressive Node.js framework for building efficient and scalable server-side applications. Perfect for crafting enterprise-level APIs, microservices, and full-stack applications with TypeScript excellence.

Why Koatty? 💡

  • 🚄 High Performance: Built on top of Koa2 with optimized architecture
  • 🧩 Full-Featured: Supports gRPC, HTTP, WebSocket, Schedule tasks, and more
  • 🧠 TypeScript First: Native TypeScript support with elegant OOP design
  • 🌀 Spring-like IOC Container: Powerful dependency injection system with autowiring
  • ✂️ AOP Support: Aspect-oriented programming with decorator-based interceptors
  • 🔌 Extensible Architecture: Plugin system with dependency injection
  • 📦 Modern Tooling: CLI scaffolding, testing utilities, and production-ready configs
  • 🌐 Protocol Agnostic: Write once, deploy as HTTP/gRPC/WebSocket services

Quick Start ⚡

  1. Install CLI:
npm install -g koatty_cli
  1. Create Project:
koatty new awesome-app
  1. Run Development Server:
cd awesome-app
npm run dev

Core Features ✨

📡 Multi-Protocol Support

// config/config.ts
export default {
  ...
  protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
  ...
}

💉 Dependency Injection

@Service()
export class UserService {
  async findUser(id: number) {
    return { id, name: 'Koatty User' };
  }
}

@Controller()
export class IndexController {
    app: App;
    ctx: KoattyContext;
    ...

    @Autowired()
    private userService: UserService;

    async test(id: number) {
        const info = await this.userService.findUser(id);
        ...
    }
}

✂️ Aspect-Oriented Programming

@Aspect()
export class LogAspect implements IAspect {
  app: App;

  run() {
    console.log('LogAspect');
  }
}

// Apply aspect to controller
@Controller()
@BeforeEach(LogAspect)
export class UserController {}

🔌 Plugin System

// plugin/logger.ts
export class LoggerPlugin implements IPlugin {
  app: App;

  run() {
    // todo something or hook on app.event
    Logger.Debug("LoggerPlugin");
    return Promise.resolve();
  }
}

New features ✨

  • HTTP、HTTPS、HTTP2、gRPC、WebSocket server.✔️
  • Support loading environment configuration, parsing command line parameters (process.argv) and environment variables (process.env).✔️
  • @ExceptionHandler() Register global exception handling.✔️
  • graceful shutdown and pre-exit event.✔️
  • custom decorator based on app events.✔️
  • GraphQL supporting. 💪
  • OpenTelemetry . 💪

Benchmarks 📊

Framework Requests/sec Latency Memory Usage
Koatty 13,321 1.43ms 54MB
Express 12,456 1.45ms 52MB
NestJS 11,892 1.51ms 63MB

Tested on AWS t3.micro with 100 concurrent connections

Documentation 📚

Community 🌍

Contributors ✨

Thanks to these amazing developers:

License 📄

BSD-3 © Koatty Team