@riktajs/core 0.1.0
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/LICENSE +21 -0
- package/README.md +205 -0
- package/dist/core/application.d.ts +28 -0
- package/dist/core/application.d.ts.map +1 -0
- package/dist/core/application.js +321 -0
- package/dist/core/application.js.map +1 -0
- package/dist/core/constants.d.ts +70 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +77 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/container/container.d.ts +101 -0
- package/dist/core/container/container.d.ts.map +1 -0
- package/dist/core/container/container.js +327 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/index.d.ts +3 -0
- package/dist/core/container/index.d.ts.map +1 -0
- package/dist/core/container/index.js +19 -0
- package/dist/core/container/index.js.map +1 -0
- package/dist/core/container/injection-token.d.ts +58 -0
- package/dist/core/container/injection-token.d.ts.map +1 -0
- package/dist/core/container/injection-token.js +37 -0
- package/dist/core/container/injection-token.js.map +1 -0
- package/dist/core/decorators/autowired.decorator.d.ts +72 -0
- package/dist/core/decorators/autowired.decorator.d.ts.map +1 -0
- package/dist/core/decorators/autowired.decorator.js +143 -0
- package/dist/core/decorators/autowired.decorator.js.map +1 -0
- package/dist/core/decorators/controller.decorator.d.ts +33 -0
- package/dist/core/decorators/controller.decorator.d.ts.map +1 -0
- package/dist/core/decorators/controller.decorator.js +50 -0
- package/dist/core/decorators/controller.decorator.js.map +1 -0
- package/dist/core/decorators/index.d.ts +7 -0
- package/dist/core/decorators/index.d.ts.map +1 -0
- package/dist/core/decorators/index.js +24 -0
- package/dist/core/decorators/index.js.map +1 -0
- package/dist/core/decorators/injectable.decorator.d.ts +26 -0
- package/dist/core/decorators/injectable.decorator.d.ts.map +1 -0
- package/dist/core/decorators/injectable.decorator.js +40 -0
- package/dist/core/decorators/injectable.decorator.js.map +1 -0
- package/dist/core/decorators/param.decorator.d.ts +72 -0
- package/dist/core/decorators/param.decorator.d.ts.map +1 -0
- package/dist/core/decorators/param.decorator.js +88 -0
- package/dist/core/decorators/param.decorator.js.map +1 -0
- package/dist/core/decorators/provider.decorator.d.ts +64 -0
- package/dist/core/decorators/provider.decorator.d.ts.map +1 -0
- package/dist/core/decorators/provider.decorator.js +69 -0
- package/dist/core/decorators/provider.decorator.js.map +1 -0
- package/dist/core/decorators/route.decorator.d.ts +53 -0
- package/dist/core/decorators/route.decorator.d.ts.map +1 -0
- package/dist/core/decorators/route.decorator.js +85 -0
- package/dist/core/decorators/route.decorator.js.map +1 -0
- package/dist/core/discovery.d.ts +24 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/core/discovery.js +168 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/exceptions/catch.decorator.d.ts +71 -0
- package/dist/core/exceptions/catch.decorator.d.ts.map +1 -0
- package/dist/core/exceptions/catch.decorator.js +77 -0
- package/dist/core/exceptions/catch.decorator.js.map +1 -0
- package/dist/core/exceptions/exception-filter.d.ts +134 -0
- package/dist/core/exceptions/exception-filter.d.ts.map +1 -0
- package/dist/core/exceptions/exception-filter.js +161 -0
- package/dist/core/exceptions/exception-filter.js.map +1 -0
- package/dist/core/exceptions/exceptions.d.ts +212 -0
- package/dist/core/exceptions/exceptions.d.ts.map +1 -0
- package/dist/core/exceptions/exceptions.js +275 -0
- package/dist/core/exceptions/exceptions.js.map +1 -0
- package/dist/core/exceptions/http-exception.d.ts +79 -0
- package/dist/core/exceptions/http-exception.d.ts.map +1 -0
- package/dist/core/exceptions/http-exception.js +106 -0
- package/dist/core/exceptions/http-exception.js.map +1 -0
- package/dist/core/exceptions/index.d.ts +5 -0
- package/dist/core/exceptions/index.d.ts.map +1 -0
- package/dist/core/exceptions/index.js +38 -0
- package/dist/core/exceptions/index.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +28 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lifecycle/event-bus.d.ts +96 -0
- package/dist/core/lifecycle/event-bus.d.ts.map +1 -0
- package/dist/core/lifecycle/event-bus.js +91 -0
- package/dist/core/lifecycle/event-bus.js.map +1 -0
- package/dist/core/lifecycle/index.d.ts +4 -0
- package/dist/core/lifecycle/index.d.ts.map +1 -0
- package/dist/core/lifecycle/index.js +21 -0
- package/dist/core/lifecycle/index.js.map +1 -0
- package/dist/core/lifecycle/interfaces.d.ts +106 -0
- package/dist/core/lifecycle/interfaces.d.ts.map +1 -0
- package/dist/core/lifecycle/interfaces.js +10 -0
- package/dist/core/lifecycle/interfaces.js.map +1 -0
- package/dist/core/lifecycle/on.decorator.d.ts +62 -0
- package/dist/core/lifecycle/on.decorator.d.ts.map +1 -0
- package/dist/core/lifecycle/on.decorator.js +65 -0
- package/dist/core/lifecycle/on.decorator.js.map +1 -0
- package/dist/core/registry.d.ts +64 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +91 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/router/router.d.ts +39 -0
- package/dist/core/router/router.d.ts.map +1 -0
- package/dist/core/router/router.js +150 -0
- package/dist/core/router/router.js.map +1 -0
- package/dist/core/types.d.ts +161 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 riktaHQ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# 🔧 Rikta Framework
|
|
2
|
+
|
|
3
|
+
A modern TypeScript backend framework with zero-config autowiring, powered by Fastify.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Decorator-based routing** - `@Controller`, `@Get`, `@Post`, etc.
|
|
8
|
+
- 💉 **Full Autowiring** - No modules needed, everything is auto-discovered
|
|
9
|
+
- 🔌 **Single DI decorator** - `@Autowired()` for everything
|
|
10
|
+
- 🔄 **Hybrid Lifecycle** - Interface hooks + EventBus
|
|
11
|
+
- 🛡️ **Exception Handling** - Built-in filters with standardized JSON responses
|
|
12
|
+
- ⚡ **Fastify under the hood** - Maximum performance
|
|
13
|
+
- 🔒 **Type-safe** - Full TypeScript support
|
|
14
|
+
- 🪶 **Zero config** - Just decorate and run
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 🚀 Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Rikta, Controller, Injectable, Get, Autowired } from '@rikta/core';
|
|
26
|
+
|
|
27
|
+
@Injectable()
|
|
28
|
+
class GreetingService {
|
|
29
|
+
getGreeting(): string {
|
|
30
|
+
return 'Hello from Rikta!';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Controller()
|
|
35
|
+
export class AppController {
|
|
36
|
+
@Autowired()
|
|
37
|
+
private greetingService!: GreetingService;
|
|
38
|
+
|
|
39
|
+
@Get('/')
|
|
40
|
+
getHello() {
|
|
41
|
+
return this.greetingService.getGreeting();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// No modules - just create and run!
|
|
46
|
+
const app = await Rikta.create({ port: 3000 });
|
|
47
|
+
await app.listen();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📚 Documentation
|
|
51
|
+
|
|
52
|
+
| Section | Description |
|
|
53
|
+
|---------|-------------|
|
|
54
|
+
| [Core Architecture](./src/core/README.md) | Framework internals |
|
|
55
|
+
| [Dependency Injection](./src/core/container/README.md) | DI, tokens, autowiring |
|
|
56
|
+
| [Lifecycle](./src/core/lifecycle/README.md) | Hooks, events, priority |
|
|
57
|
+
| [Exception Handling](./src/core/exceptions/README.md) | Errors, filters, responses |
|
|
58
|
+
| [Decorators](./src/core/decorators/README.md) | All decorators reference |
|
|
59
|
+
| [Router](./src/core/router/README.md) | Routing and requests |
|
|
60
|
+
| [Example](./example/README.md) | Working code example |
|
|
61
|
+
|
|
62
|
+
## 🏃 Running Example
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm run example # Full-featured CRUD with lifecycle hooks
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## ⚙️ Configuration
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const app = await Rikta.create({
|
|
72
|
+
port: 3000, // Server port
|
|
73
|
+
host: '0.0.0.0', // Server host
|
|
74
|
+
logger: true, // Fastify logging
|
|
75
|
+
prefix: '/api/v1', // Global prefix
|
|
76
|
+
|
|
77
|
+
// Auto-discovery paths (default: ['./**'] - scans all files)
|
|
78
|
+
autowired: ['./src/controllers', './src/services'],
|
|
79
|
+
|
|
80
|
+
// Optional: explicit controller list (skips auto-discovery)
|
|
81
|
+
controllers: [UserController, AppController],
|
|
82
|
+
|
|
83
|
+
// Exception handling configuration
|
|
84
|
+
exceptionFilter: {
|
|
85
|
+
includeStack: process.env.NODE_ENV !== 'production',
|
|
86
|
+
logErrors: true,
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
// Custom exception filters
|
|
90
|
+
exceptionFilters: [ValidationExceptionFilter],
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Auto-Discovery
|
|
95
|
+
|
|
96
|
+
Rikta automatically scans and imports files to discover `@Controller` and `@Injectable` classes:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// Scan specific directories
|
|
100
|
+
await Rikta.create({
|
|
101
|
+
autowired: ['./src/controllers', './src/services']
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Scan with glob patterns
|
|
105
|
+
await Rikta.create({
|
|
106
|
+
autowired: ['./src/**/*.controller.ts', './src/**/*.service.ts']
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Default: scans current directory recursively
|
|
110
|
+
await Rikta.create({ port: 3000 });
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 🔄 Lifecycle Hooks
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
@Injectable({ priority: 100 }) // Higher = initialized first
|
|
117
|
+
class DatabaseService implements OnProviderInit, OnProviderDestroy {
|
|
118
|
+
async onProviderInit() {
|
|
119
|
+
await this.connect();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async onProviderDestroy() {
|
|
123
|
+
await this.disconnect();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Or use @On() decorator for events
|
|
128
|
+
@Injectable()
|
|
129
|
+
class MonitoringService {
|
|
130
|
+
@On('app:listen')
|
|
131
|
+
onServerStart({ address }) {
|
|
132
|
+
console.log(`Server at ${address}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
See [Lifecycle Documentation](./src/core/lifecycle/README.md) for full details.
|
|
138
|
+
|
|
139
|
+
## 🛡️ Exception Handling
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import {
|
|
143
|
+
NotFoundException,
|
|
144
|
+
BadRequestException,
|
|
145
|
+
HttpException
|
|
146
|
+
} from '@rikta/core';
|
|
147
|
+
|
|
148
|
+
@Controller('/users')
|
|
149
|
+
class UserController {
|
|
150
|
+
@Get('/:id')
|
|
151
|
+
async getUser(@Param('id') id: string) {
|
|
152
|
+
const user = await this.userService.findById(id);
|
|
153
|
+
|
|
154
|
+
if (!user) {
|
|
155
|
+
throw new NotFoundException(`User ${id} not found`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return user;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@Post()
|
|
162
|
+
async create(@Body() data: CreateUserDto) {
|
|
163
|
+
if (!data.email) {
|
|
164
|
+
throw new BadRequestException({
|
|
165
|
+
message: 'Validation failed',
|
|
166
|
+
details: { email: 'Email is required' }
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Standard JSON Response:**
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"statusCode": 404,
|
|
177
|
+
"message": "User 123 not found",
|
|
178
|
+
"error": "Not Found",
|
|
179
|
+
"timestamp": "2024-01-15T10:30:00.000Z",
|
|
180
|
+
"path": "/users/123"
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Available Exceptions:** `BadRequestException`, `UnauthorizedException`, `ForbiddenException`, `NotFoundException`, `ConflictException`, `UnprocessableEntityException`, `TooManyRequestsException`, `InternalServerErrorException`, `ServiceUnavailableException`, and more.
|
|
185
|
+
|
|
186
|
+
See [Exception Handling Documentation](./src/core/exceptions/README.md) for full details.
|
|
187
|
+
|
|
188
|
+
## 📁 Project Structure
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
rikta/
|
|
192
|
+
├── src/core/
|
|
193
|
+
│ ├── container/ # Dependency Injection
|
|
194
|
+
│ ├── decorators/ # All decorators
|
|
195
|
+
│ ├── exceptions/ # Error handling & filters
|
|
196
|
+
│ ├── lifecycle/ # Hooks & EventBus
|
|
197
|
+
│ ├── router/ # Route handling
|
|
198
|
+
│ ├── registry.ts # Auto-discovery registry
|
|
199
|
+
│ └── application.ts # Bootstrap
|
|
200
|
+
└── example/ # Full-featured example
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 📜 License
|
|
204
|
+
|
|
205
|
+
MIT
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { RiktaConfig, RiktaApplication } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* RiktaFactory - Bootstrap the application
|
|
5
|
+
*
|
|
6
|
+
* Creates and initializes the Rikta application with auto-discovery.
|
|
7
|
+
* All classes decorated with @Controller are automatically registered.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RiktaFactory {
|
|
10
|
+
/**
|
|
11
|
+
* Create and bootstrap the application
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Auto-discovery from current directory (default)
|
|
16
|
+
* const app = await Rikta.create({ port: 3000 });
|
|
17
|
+
*
|
|
18
|
+
* // Auto-discovery from specific paths
|
|
19
|
+
* const app = await Rikta.create({
|
|
20
|
+
* autowired: ['./src/controllers', './src/services'],
|
|
21
|
+
* port: 3000
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
static create(config?: RiktaConfig): Promise<RiktaApplication>;
|
|
26
|
+
}
|
|
27
|
+
export { RiktaFactory as Rikta };
|
|
28
|
+
//# sourceMappingURL=application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/core/application.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAe1B,OAAO,EAAe,WAAW,EAAE,gBAAgB,EAAqB,MAAM,SAAS,CAAC;AASxF;;;;;GAKG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;OAcG;WACU,MAAM,CAAC,MAAM,GAAE,WAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAkBzE;AAsUD,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Rikta = exports.RiktaFactory = void 0;
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
const fastify_1 = __importDefault(require("fastify"));
|
|
9
|
+
const container_1 = require("./container/container");
|
|
10
|
+
const router_1 = require("./router/router");
|
|
11
|
+
const registry_1 = require("./registry");
|
|
12
|
+
const discovery_1 = require("./discovery");
|
|
13
|
+
const event_bus_1 = require("./lifecycle/event-bus");
|
|
14
|
+
const on_decorator_1 = require("./lifecycle/on.decorator");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
const exceptions_1 = require("./exceptions");
|
|
17
|
+
/**
|
|
18
|
+
* RiktaFactory - Bootstrap the application
|
|
19
|
+
*
|
|
20
|
+
* Creates and initializes the Rikta application with auto-discovery.
|
|
21
|
+
* All classes decorated with @Controller are automatically registered.
|
|
22
|
+
*/
|
|
23
|
+
class RiktaFactory {
|
|
24
|
+
/**
|
|
25
|
+
* Create and bootstrap the application
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Auto-discovery from current directory (default)
|
|
30
|
+
* const app = await Rikta.create({ port: 3000 });
|
|
31
|
+
*
|
|
32
|
+
* // Auto-discovery from specific paths
|
|
33
|
+
* const app = await Rikta.create({
|
|
34
|
+
* autowired: ['./src/controllers', './src/services'],
|
|
35
|
+
* port: 3000
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
static async create(config = {}) {
|
|
40
|
+
const callerDir = (0, discovery_1.getCallerDirectory)();
|
|
41
|
+
let discoveredFiles = [];
|
|
42
|
+
// Auto-discovery: scan for controllers and services
|
|
43
|
+
if (!config.controllers) {
|
|
44
|
+
const patterns = config.autowired ?? ['./**'];
|
|
45
|
+
console.log('\n🔍 Auto-discovering modules...');
|
|
46
|
+
discoveredFiles = await (0, discovery_1.discoverModules)(patterns, callerDir);
|
|
47
|
+
if (discoveredFiles.length > 0) {
|
|
48
|
+
console.log(` Found ${discoveredFiles.length} module(s)`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const app = new RiktaApplicationImpl(config);
|
|
52
|
+
await app.init(discoveredFiles);
|
|
53
|
+
return app;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.RiktaFactory = RiktaFactory;
|
|
57
|
+
exports.Rikta = RiktaFactory;
|
|
58
|
+
/**
|
|
59
|
+
* Internal application implementation
|
|
60
|
+
*/
|
|
61
|
+
class RiktaApplicationImpl {
|
|
62
|
+
server;
|
|
63
|
+
container;
|
|
64
|
+
config;
|
|
65
|
+
router;
|
|
66
|
+
events;
|
|
67
|
+
initializedProviders = [];
|
|
68
|
+
customExceptionFilters = new Map();
|
|
69
|
+
startTime = Date.now();
|
|
70
|
+
isListening = false;
|
|
71
|
+
address = '';
|
|
72
|
+
constructor(config) {
|
|
73
|
+
this.config = {
|
|
74
|
+
port: config.port ?? constants_1.DEFAULT_CONFIG.port,
|
|
75
|
+
host: config.host ?? constants_1.DEFAULT_CONFIG.host,
|
|
76
|
+
logger: config.logger ?? constants_1.DEFAULT_CONFIG.logger,
|
|
77
|
+
prefix: config.prefix ?? constants_1.DEFAULT_CONFIG.prefix,
|
|
78
|
+
controllers: config.controllers,
|
|
79
|
+
providers: config.providers,
|
|
80
|
+
exceptionFilter: config.exceptionFilter,
|
|
81
|
+
exceptionFilters: config.exceptionFilters,
|
|
82
|
+
};
|
|
83
|
+
this.server = (0, fastify_1.default)({ logger: this.config.logger });
|
|
84
|
+
this.container = container_1.Container.getInstance();
|
|
85
|
+
this.router = new router_1.Router(this.server, this.container, this.config.prefix);
|
|
86
|
+
// Create and register EventBus
|
|
87
|
+
this.events = new event_bus_1.EventBus();
|
|
88
|
+
this.container.registerInstance(event_bus_1.EventBus, this.events);
|
|
89
|
+
// Setup global exception handler
|
|
90
|
+
this.setupExceptionHandler();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Setup global exception handler
|
|
94
|
+
*/
|
|
95
|
+
setupExceptionHandler() {
|
|
96
|
+
// Create global exception filter with config
|
|
97
|
+
const globalFilter = new exceptions_1.GlobalExceptionFilter({
|
|
98
|
+
includeStack: this.config.exceptionFilter?.includeStack,
|
|
99
|
+
logErrors: this.config.exceptionFilter?.logErrors,
|
|
100
|
+
});
|
|
101
|
+
// Register custom exception filters
|
|
102
|
+
const customFilters = this.config.exceptionFilters ?? [];
|
|
103
|
+
for (const FilterClass of customFilters) {
|
|
104
|
+
const metadata = (0, exceptions_1.getCatchMetadata)(FilterClass);
|
|
105
|
+
const filterInstance = this.container.resolve(FilterClass);
|
|
106
|
+
if (metadata && metadata.exceptions.length > 0) {
|
|
107
|
+
// Register for specific exception types
|
|
108
|
+
for (const ExceptionType of metadata.exceptions) {
|
|
109
|
+
this.customExceptionFilters.set(ExceptionType, filterInstance);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Catch-all filter (registered as Error)
|
|
114
|
+
this.customExceptionFilters.set(Error, filterInstance);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Set Fastify error handler
|
|
118
|
+
this.server.setErrorHandler((0, exceptions_1.createExceptionHandler)(globalFilter, this.customExceptionFilters));
|
|
119
|
+
console.log('🛡️ Exception handler configured');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Initialize the application
|
|
123
|
+
*/
|
|
124
|
+
async init(discoveredFiles = []) {
|
|
125
|
+
console.log('\n🔧 Rikta Framework Initializing...\n');
|
|
126
|
+
// Emit discovery event
|
|
127
|
+
await this.events.emit('app:discovery', { files: discoveredFiles });
|
|
128
|
+
// 1. Process @Provider classes first
|
|
129
|
+
await this.processCustomProviders();
|
|
130
|
+
await this.events.emit('app:providers', {
|
|
131
|
+
count: registry_1.registry.getCustomProviders().length
|
|
132
|
+
});
|
|
133
|
+
// 2. Get and sort providers by priority
|
|
134
|
+
const providers = this.getSortedProviders();
|
|
135
|
+
// 3. Register additional explicit providers
|
|
136
|
+
const additionalProviders = this.config.providers ?? [];
|
|
137
|
+
for (const provider of additionalProviders) {
|
|
138
|
+
this.registerProvider(provider);
|
|
139
|
+
}
|
|
140
|
+
// 4. Initialize all @Injectable providers
|
|
141
|
+
for (const { target, priority } of providers) {
|
|
142
|
+
await this.initializeProvider(target, priority);
|
|
143
|
+
}
|
|
144
|
+
// 5. Register routes
|
|
145
|
+
const controllers = this.config.controllers ?? registry_1.registry.getControllers();
|
|
146
|
+
console.log('📡 Registering routes:');
|
|
147
|
+
for (const controller of controllers) {
|
|
148
|
+
this.router.registerController(controller);
|
|
149
|
+
}
|
|
150
|
+
await this.events.emit('app:routes', { count: controllers.length });
|
|
151
|
+
// 6. Call onApplicationBootstrap hooks
|
|
152
|
+
await this.callHook('onApplicationBootstrap');
|
|
153
|
+
await this.events.emit('app:bootstrap', {
|
|
154
|
+
providerCount: this.initializedProviders.length
|
|
155
|
+
});
|
|
156
|
+
console.log('\n✅ Application initialized successfully\n');
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Process all @Provider decorated classes
|
|
160
|
+
*/
|
|
161
|
+
async processCustomProviders() {
|
|
162
|
+
const customProviders = registry_1.registry.getCustomProviders();
|
|
163
|
+
if (customProviders.length === 0)
|
|
164
|
+
return;
|
|
165
|
+
for (const ProviderClass of customProviders) {
|
|
166
|
+
const metadata = Reflect.getMetadata(constants_1.PROVIDER_METADATA, ProviderClass);
|
|
167
|
+
if (!metadata)
|
|
168
|
+
continue;
|
|
169
|
+
const providerInstance = this.container.resolve(ProviderClass);
|
|
170
|
+
const value = await providerInstance.provide();
|
|
171
|
+
this.container.registerValue(metadata.token, value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get providers sorted by priority (higher = first)
|
|
176
|
+
*/
|
|
177
|
+
getSortedProviders() {
|
|
178
|
+
const providers = registry_1.registry.getProviders();
|
|
179
|
+
return providers
|
|
180
|
+
.map(target => ({
|
|
181
|
+
target,
|
|
182
|
+
priority: this.getProviderPriority(target),
|
|
183
|
+
}))
|
|
184
|
+
.sort((a, b) => b.priority - a.priority);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get priority from @Injectable() metadata
|
|
188
|
+
*/
|
|
189
|
+
getProviderPriority(target) {
|
|
190
|
+
const options = Reflect.getMetadata(constants_1.INJECTABLE_METADATA, target);
|
|
191
|
+
return options?.priority ?? 0;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Initialize a single provider
|
|
195
|
+
*/
|
|
196
|
+
async initializeProvider(target, priority) {
|
|
197
|
+
const instance = this.container.resolve(target);
|
|
198
|
+
const name = target.name;
|
|
199
|
+
// Track initialized provider
|
|
200
|
+
this.initializedProviders.push({ instance, priority, name });
|
|
201
|
+
// Call onProviderInit hook
|
|
202
|
+
if (this.hasHook(instance, 'onProviderInit')) {
|
|
203
|
+
await instance.onProviderInit();
|
|
204
|
+
}
|
|
205
|
+
// Emit provider:init event
|
|
206
|
+
await this.events.emit('provider:init', { provider: target, name, priority });
|
|
207
|
+
// Register @On() event listeners from this instance
|
|
208
|
+
this.registerEventListeners(target, instance);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Register @On() decorated methods as event listeners
|
|
212
|
+
*/
|
|
213
|
+
registerEventListeners(target, instance) {
|
|
214
|
+
const metadata = Reflect.getMetadata(on_decorator_1.ON_EVENT_METADATA, target) ?? [];
|
|
215
|
+
for (const { event, methodName } of metadata) {
|
|
216
|
+
const method = instance[methodName];
|
|
217
|
+
if (typeof method === 'function') {
|
|
218
|
+
this.events.on(event, method.bind(instance));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Register a provider in the container
|
|
224
|
+
*/
|
|
225
|
+
registerProvider(provider) {
|
|
226
|
+
const instance = this.container.resolve(provider);
|
|
227
|
+
const priority = this.getProviderPriority(provider);
|
|
228
|
+
this.initializedProviders.push({ instance, priority, name: provider.name });
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Call a lifecycle hook on all initialized providers
|
|
232
|
+
*/
|
|
233
|
+
async callHook(hookName) {
|
|
234
|
+
for (const { instance } of this.initializedProviders) {
|
|
235
|
+
if (this.hasHook(instance, hookName)) {
|
|
236
|
+
await instance[hookName]();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Check if an instance has a lifecycle hook
|
|
242
|
+
*/
|
|
243
|
+
hasHook(instance, hookName) {
|
|
244
|
+
return (instance !== null &&
|
|
245
|
+
typeof instance === 'object' &&
|
|
246
|
+
hookName in instance &&
|
|
247
|
+
typeof instance[hookName] === 'function');
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Start listening for requests
|
|
251
|
+
*/
|
|
252
|
+
async listen() {
|
|
253
|
+
if (this.isListening) {
|
|
254
|
+
return this.address;
|
|
255
|
+
}
|
|
256
|
+
this.address = await this.server.listen({
|
|
257
|
+
port: this.config.port,
|
|
258
|
+
host: this.config.host,
|
|
259
|
+
});
|
|
260
|
+
this.isListening = true;
|
|
261
|
+
console.log(`🚀 Server listening on ${this.address}\n`);
|
|
262
|
+
// Call onApplicationListen hooks
|
|
263
|
+
for (const { instance } of this.initializedProviders) {
|
|
264
|
+
if (this.hasHook(instance, 'onApplicationListen')) {
|
|
265
|
+
await instance.onApplicationListen(this.address);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Emit app:listen event
|
|
269
|
+
await this.events.emit('app:listen', {
|
|
270
|
+
address: this.address,
|
|
271
|
+
port: this.config.port
|
|
272
|
+
});
|
|
273
|
+
return this.address;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Close the application
|
|
277
|
+
*/
|
|
278
|
+
async close(signal) {
|
|
279
|
+
// Emit app:shutdown event
|
|
280
|
+
await this.events.emit('app:shutdown', { signal });
|
|
281
|
+
// Call hooks in REVERSE priority order
|
|
282
|
+
const reversed = [...this.initializedProviders].reverse();
|
|
283
|
+
for (const { instance } of reversed) {
|
|
284
|
+
// Call onApplicationShutdown
|
|
285
|
+
if (this.hasHook(instance, 'onApplicationShutdown')) {
|
|
286
|
+
await instance.onApplicationShutdown(signal);
|
|
287
|
+
}
|
|
288
|
+
// Call onProviderDestroy
|
|
289
|
+
if (this.hasHook(instance, 'onProviderDestroy')) {
|
|
290
|
+
await instance.onProviderDestroy();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Close Fastify
|
|
294
|
+
await this.server.close();
|
|
295
|
+
this.isListening = false;
|
|
296
|
+
// Emit app:destroy event
|
|
297
|
+
await this.events.emit('app:destroy', {
|
|
298
|
+
uptime: Date.now() - this.startTime
|
|
299
|
+
});
|
|
300
|
+
console.log('\n👋 Application closed\n');
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get the server URL
|
|
304
|
+
*/
|
|
305
|
+
getUrl() {
|
|
306
|
+
return this.address;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get the EventBus instance
|
|
310
|
+
*/
|
|
311
|
+
getEventBus() {
|
|
312
|
+
return this.events;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get a service from the container
|
|
316
|
+
*/
|
|
317
|
+
get(token) {
|
|
318
|
+
return this.container.resolve(token);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/core/application.ts"],"names":[],"mappings":";;;;;;AAAA,4BAA0B;AAC1B,sDAAmD;AACnD,qDAAkD;AAClD,4CAAyC;AACzC,yCAAsC;AACtC,2CAAkE;AAElE,qDAAiD;AACjD,2DAA8E;AAQ9E,2CAAqF;AACrF,6CAKsB;AAEtB;;;;;GAKG;AACH,MAAa,YAAY;IACvB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAsB,EAAE;QAC1C,MAAM,SAAS,GAAG,IAAA,8BAAkB,GAAE,CAAC;QACvC,IAAI,eAAe,GAAa,EAAE,CAAC;QAEnC,oDAAoD;QACpD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YAChD,eAAe,GAAG,MAAM,IAAA,2BAAe,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC7D,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,GAAG,CAAC,YAAY,eAAe,CAAC,MAAM,YAAY,CAAC,CAA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B,CAAC,MAAM,CAAC,CAAC;YAC1E,CAAC;YAED,yBAAyB;YACzB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAE,CAAC;gBAChD,MAAO,QAA8B,CAAC,iBAAiB,EAAE,CAAC;YAC5D,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAEzB,yBAAyB;QACzB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE;YACpC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS;SACpC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,GAAG,CAAI,KAAqB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key for storing controller metadata (prefix, routes)
|
|
3
|
+
*/
|
|
4
|
+
export declare const CONTROLLER_METADATA: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* Key for storing route definitions on a controller
|
|
7
|
+
*/
|
|
8
|
+
export declare const ROUTES_METADATA: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Key for storing injectable options
|
|
11
|
+
*/
|
|
12
|
+
export declare const INJECTABLE_METADATA: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Key for storing parameter injection metadata
|
|
15
|
+
*/
|
|
16
|
+
export declare const PARAM_METADATA: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* Key for storing guards
|
|
19
|
+
*/
|
|
20
|
+
export declare const GUARDS_METADATA: unique symbol;
|
|
21
|
+
/**
|
|
22
|
+
* Key for storing interceptors
|
|
23
|
+
*/
|
|
24
|
+
export declare const INTERCEPTORS_METADATA: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* Key for storing middleware
|
|
27
|
+
*/
|
|
28
|
+
export declare const MIDDLEWARE_METADATA: unique symbol;
|
|
29
|
+
/**
|
|
30
|
+
* Key for storing response status code
|
|
31
|
+
*/
|
|
32
|
+
export declare const HTTP_CODE_METADATA: unique symbol;
|
|
33
|
+
/**
|
|
34
|
+
* Key for storing response headers
|
|
35
|
+
*/
|
|
36
|
+
export declare const HEADERS_METADATA: unique symbol;
|
|
37
|
+
/**
|
|
38
|
+
* Key for storing @Inject() metadata on constructor parameters
|
|
39
|
+
*/
|
|
40
|
+
export declare const INJECT_METADATA: unique symbol;
|
|
41
|
+
/**
|
|
42
|
+
* Key for storing @Autowired() property injection metadata
|
|
43
|
+
*/
|
|
44
|
+
export declare const AUTOWIRED_METADATA: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* Key for storing @Provider() metadata
|
|
47
|
+
*/
|
|
48
|
+
export declare const PROVIDER_METADATA: unique symbol;
|
|
49
|
+
/**
|
|
50
|
+
* Parameter types for injection
|
|
51
|
+
*/
|
|
52
|
+
export declare enum ParamType {
|
|
53
|
+
BODY = "body",
|
|
54
|
+
QUERY = "query",
|
|
55
|
+
PARAM = "param",
|
|
56
|
+
HEADERS = "headers",
|
|
57
|
+
REQUEST = "request",
|
|
58
|
+
REPLY = "reply",
|
|
59
|
+
CONTEXT = "context"
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default application configuration
|
|
63
|
+
*/
|
|
64
|
+
export declare const DEFAULT_CONFIG: {
|
|
65
|
+
readonly port: 3000;
|
|
66
|
+
readonly host: "0.0.0.0";
|
|
67
|
+
readonly logger: true;
|
|
68
|
+
readonly prefix: "";
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAE7D;;GAEG;AACH,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC"}
|