https://github.com/koatty/koatty
Koa2 + Typescript = Koatty. Use Typescript's decorator implement IOC and AOP.
https://github.com/koatty/koatty
aop auto-injection grpc grpc-server http http2 https ioc koa koa2 middleware rpc springboot typescript typescript-decorator websocket ws
Last synced: about 1 month ago
JSON representation
Koa2 + Typescript = Koatty. Use Typescript's decorator implement IOC and AOP.
- Host: GitHub
- URL: https://github.com/koatty/koatty
- Owner: Koatty
- License: bsd-3-clause
- Created: 2018-04-28T16:44:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T01:51:30.000Z (7 months ago)
- Last Synced: 2024-10-30T04:00:47.713Z (7 months ago)
- Topics: aop, auto-injection, grpc, grpc-server, http, http2, https, ioc, koa, koa2, middleware, rpc, springboot, typescript, typescript-decorator, websocket, ws
- Language: TypeScript
- Homepage: https://koatty.org/
- Size: 3.58 MB
- Stars: 124
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Koatty π
[](https://www.npmjs.com/package/koatty)
[](https://opensource.org/licenses/BSD-3-Clause)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## New features β¨
* HTTPγHTTPSγHTTP2γgRPCγWebSocket server.βοΈ
* Support loading configurations based on the environment, support command-line argument parsing(process.argv), and support environment variable parsing(process.env).βοΈ
* `@ExceptionHandler()` Register global exception handling.βοΈ
* Graceful shutdown and pre-exit event.βοΈ
* Supports custom decorators, bound to app events for execution.βοΈ
* GraphQL supporting. βοΈ
* OpenTelemetry . πͺ## Core Features β¨
### π‘ Multi-Protocol Support
```typescript
// config/config.ts
export default {
...
protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
...
}
```### π Dependency Injection
```typescript
@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
```javascript
@Aspect()
export class LogAspect implements IAspect {
app: App;run() {
console.log('LogAspect');
}
}// Apply aspect to controller
@Controller()
@BeforeEach(LogAspect)
export class UserController {}
```### π Plugin System
```javascript
// plugin/logger.ts
export class LoggerPlugin implements IPlugin {
app: App;run() {
// todo something or hook on app.event
Logger.Debug("LoggerPlugin");
return Promise.resolve();
}
}
```## 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 π
- [δΈζζζ‘£](https://koatty.org/)
- [Getting Started Guide](https://github.com/Koatty/koatty_doc/blob/master/docs/README-en.md)
- [API Reference](https://koatty.org/#/?id=api)
- [Recipes & Best Practices](https://github.com/Koatty/koatty_awesome)
- [Example](https://github.com/Koatty/koatty_demo)## Quick Start β‘
1. **Install CLI**:
```bash
npm install -g koatty_cli
```2. **Create Project**:
```bash
koatty new awesome-app
```3. **Run Development Server**:
```bash
cd awesome-app
npm run dev
```## Community π
- [GitHub Discussions](https://github.com/Koatty/koatty/discussions)
## Contributors β¨
Thanks to these amazing developers:
## License π
BSD-3 Β© [Koatty Team](https://github.com/Koatty)