@forinda/kickjs-core 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @forinda/kickjs-core
|
|
2
|
+
|
|
3
|
+
Core DI container, decorators, module system, logger, and error types for KickJS.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @forinda/kickjs-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Custom lightweight IoC container (no Inversify)
|
|
14
|
+
- 20+ decorators: `@Service`, `@Controller`, `@Autowired`, `@Inject`, `@Value`, `@Get`, `@Post`, `@Middleware`, `@Bean`, `@PostConstruct`, and more
|
|
15
|
+
- Module system with `AppModule` interface
|
|
16
|
+
- Adapter pattern for lifecycle hooks
|
|
17
|
+
- Pino-based structured logger
|
|
18
|
+
- `HttpException` with static factories for all HTTP status codes
|
|
19
|
+
- Circular dependency detection with full resolution chain
|
|
20
|
+
|
|
21
|
+
## Quick Example
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Service, Controller, Get, Autowired } from '@forinda/kickjs-core'
|
|
25
|
+
|
|
26
|
+
@Service()
|
|
27
|
+
class UserService {
|
|
28
|
+
findAll() {
|
|
29
|
+
return [{ id: '1', name: 'Alice' }]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Controller('/users')
|
|
34
|
+
class UserController {
|
|
35
|
+
@Autowired() private userService!: UserService
|
|
36
|
+
|
|
37
|
+
@Get('/')
|
|
38
|
+
async list(ctx: any) {
|
|
39
|
+
ctx.json(this.userService.findAll())
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Sub-path Imports
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { Container } from '@forinda/kickjs-core/container'
|
|
48
|
+
import { Service, Controller, Get } from '@forinda/kickjs-core/decorators'
|
|
49
|
+
import type { AppModule } from '@forinda/kickjs-core/module'
|
|
50
|
+
import { HttpException } from '@forinda/kickjs-core/errors'
|
|
51
|
+
import { Logger } from '@forinda/kickjs-core/logger'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
[Full documentation](https://github.com/forinda/kick-js)
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT
|