@venizia/ignis-docs 0.0.1-1
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/mcp-server/dist/common/config.d.ts +27 -0
- package/mcp-server/dist/common/config.d.ts.map +1 -0
- package/mcp-server/dist/common/config.js +27 -0
- package/mcp-server/dist/common/config.js.map +1 -0
- package/mcp-server/dist/common/index.d.ts +3 -0
- package/mcp-server/dist/common/index.d.ts.map +1 -0
- package/mcp-server/dist/common/index.js +19 -0
- package/mcp-server/dist/common/index.js.map +1 -0
- package/mcp-server/dist/common/paths.d.ts +13 -0
- package/mcp-server/dist/common/paths.d.ts.map +1 -0
- package/mcp-server/dist/common/paths.js +23 -0
- package/mcp-server/dist/common/paths.js.map +1 -0
- package/mcp-server/dist/helpers/docs.helper.d.ts +81 -0
- package/mcp-server/dist/helpers/docs.helper.d.ts.map +1 -0
- package/mcp-server/dist/helpers/docs.helper.js +171 -0
- package/mcp-server/dist/helpers/docs.helper.js.map +1 -0
- package/mcp-server/dist/helpers/index.d.ts +3 -0
- package/mcp-server/dist/helpers/index.d.ts.map +1 -0
- package/mcp-server/dist/helpers/index.js +19 -0
- package/mcp-server/dist/helpers/index.js.map +1 -0
- package/mcp-server/dist/helpers/logger.helper.d.ts +7 -0
- package/mcp-server/dist/helpers/logger.helper.d.ts.map +1 -0
- package/mcp-server/dist/helpers/logger.helper.js +22 -0
- package/mcp-server/dist/helpers/logger.helper.js.map +1 -0
- package/mcp-server/dist/index.d.ts +3 -0
- package/mcp-server/dist/index.d.ts.map +1 -0
- package/mcp-server/dist/index.js +62 -0
- package/mcp-server/dist/index.js.map +1 -0
- package/mcp-server/dist/tools/base.tool.d.ts +98 -0
- package/mcp-server/dist/tools/base.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/base.tool.js +47 -0
- package/mcp-server/dist/tools/base.tool.js.map +1 -0
- package/mcp-server/dist/tools/get-doc-content.tool.d.ts +30 -0
- package/mcp-server/dist/tools/get-doc-content.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/get-doc-content.tool.js +127 -0
- package/mcp-server/dist/tools/get-doc-content.tool.js.map +1 -0
- package/mcp-server/dist/tools/get-doc-metadata.tool.d.ts +40 -0
- package/mcp-server/dist/tools/get-doc-metadata.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/get-doc-metadata.tool.js +121 -0
- package/mcp-server/dist/tools/get-doc-metadata.tool.js.map +1 -0
- package/mcp-server/dist/tools/index.d.ts +8 -0
- package/mcp-server/dist/tools/index.d.ts.map +1 -0
- package/mcp-server/dist/tools/index.js +18 -0
- package/mcp-server/dist/tools/index.js.map +1 -0
- package/mcp-server/dist/tools/list-categories.tool.d.ts +20 -0
- package/mcp-server/dist/tools/list-categories.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/list-categories.tool.js +105 -0
- package/mcp-server/dist/tools/list-categories.tool.js.map +1 -0
- package/mcp-server/dist/tools/list-docs.tool.d.ts +32 -0
- package/mcp-server/dist/tools/list-docs.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/list-docs.tool.js +121 -0
- package/mcp-server/dist/tools/list-docs.tool.js.map +1 -0
- package/mcp-server/dist/tools/search-docs.tool.d.ts +32 -0
- package/mcp-server/dist/tools/search-docs.tool.d.ts.map +1 -0
- package/mcp-server/dist/tools/search-docs.tool.js +120 -0
- package/mcp-server/dist/tools/search-docs.tool.js.map +1 -0
- package/package.json +102 -0
- package/wiki/get-started/5-minute-quickstart.md +266 -0
- package/wiki/get-started/best-practices/api-usage-examples.md +222 -0
- package/wiki/get-started/best-practices/architectural-patterns.md +129 -0
- package/wiki/get-started/best-practices/code-style-standards.md +122 -0
- package/wiki/get-started/best-practices/common-pitfalls.md +136 -0
- package/wiki/get-started/best-practices/contribution-workflow.md +145 -0
- package/wiki/get-started/best-practices/deployment-strategies.md +121 -0
- package/wiki/get-started/best-practices/performance-optimization.md +88 -0
- package/wiki/get-started/best-practices/security-guidelines.md +97 -0
- package/wiki/get-started/best-practices/troubleshooting-tips.md +100 -0
- package/wiki/get-started/building-a-crud-api.md +717 -0
- package/wiki/get-started/core-concepts/application.md +168 -0
- package/wiki/get-started/core-concepts/components.md +96 -0
- package/wiki/get-started/core-concepts/controllers.md +441 -0
- package/wiki/get-started/core-concepts/dependency-injection.md +160 -0
- package/wiki/get-started/core-concepts/persistent.md +591 -0
- package/wiki/get-started/core-concepts/services.md +88 -0
- package/wiki/get-started/index.md +65 -0
- package/wiki/get-started/mcp-docs-server.md +840 -0
- package/wiki/get-started/philosophy.md +123 -0
- package/wiki/get-started/prerequisites.md +113 -0
- package/wiki/get-started/quickstart.md +382 -0
- package/wiki/index.md +48 -0
- package/wiki/references/base/application.md +67 -0
- package/wiki/references/base/components.md +80 -0
- package/wiki/references/base/controllers.md +361 -0
- package/wiki/references/base/datasources.md +105 -0
- package/wiki/references/base/dependency-injection.md +83 -0
- package/wiki/references/base/models.md +104 -0
- package/wiki/references/base/repositories.md +118 -0
- package/wiki/references/base/services.md +97 -0
- package/wiki/references/components/authentication.md +224 -0
- package/wiki/references/components/health-check.md +190 -0
- package/wiki/references/components/index.md +61 -0
- package/wiki/references/components/request-tracker.md +35 -0
- package/wiki/references/components/socket-io.md +127 -0
- package/wiki/references/components/swagger.md +175 -0
- package/wiki/references/helpers/cron.md +94 -0
- package/wiki/references/helpers/crypto.md +117 -0
- package/wiki/references/helpers/env.md +67 -0
- package/wiki/references/helpers/error.md +80 -0
- package/wiki/references/helpers/index.md +21 -0
- package/wiki/references/helpers/inversion.md +141 -0
- package/wiki/references/helpers/logger.md +98 -0
- package/wiki/references/helpers/network.md +143 -0
- package/wiki/references/helpers/queue.md +131 -0
- package/wiki/references/helpers/redis.md +121 -0
- package/wiki/references/helpers/socket-io.md +103 -0
- package/wiki/references/helpers/storage.md +130 -0
- package/wiki/references/helpers/testing.md +115 -0
- package/wiki/references/helpers/worker-thread.md +162 -0
- package/wiki/references/src-details/core.md +249 -0
- package/wiki/references/src-details/dev-configs.md +302 -0
- package/wiki/references/src-details/docs.md +61 -0
- package/wiki/references/src-details/helpers.md +211 -0
- package/wiki/references/src-details/inversion.md +345 -0
- package/wiki/references/src-details/mcp-server.md +726 -0
- package/wiki/references/utilities/crypto.md +39 -0
- package/wiki/references/utilities/date.md +72 -0
- package/wiki/references/utilities/index.md +12 -0
- package/wiki/references/utilities/module.md +40 -0
- package/wiki/references/utilities/parse.md +68 -0
- package/wiki/references/utilities/performance.md +64 -0
- package/wiki/references/utilities/promise.md +83 -0
- package/wiki/references/utilities/request.md +66 -0
- package/wiki/references/utilities/schema.md +88 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# The Application Class
|
|
2
|
+
|
|
3
|
+
The Application class orchestrates your application's configuration, lifecycle, and resource registration (components, controllers, services).
|
|
4
|
+
|
|
5
|
+
> **Deep Dive:** See [Application Reference](../../references/base/application.md) for technical details.
|
|
6
|
+
|
|
7
|
+
## Creating an Application
|
|
8
|
+
|
|
9
|
+
Extend `BaseApplication` and implement the hook methods:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// src/application.ts
|
|
13
|
+
import {
|
|
14
|
+
BaseApplication,
|
|
15
|
+
IApplicationConfigs,
|
|
16
|
+
IApplicationInfo,
|
|
17
|
+
ValueOrPromise,
|
|
18
|
+
} from "@venizia/ignis";
|
|
19
|
+
import packageJson from "./../package.json";
|
|
20
|
+
|
|
21
|
+
// Application configurations
|
|
22
|
+
export const appConfigs: IApplicationConfigs = {
|
|
23
|
+
host: process.env.APP_ENV_SERVER_HOST,
|
|
24
|
+
port: +(process.env.APP_ENV_SERVER_PORT ?? 3000),
|
|
25
|
+
path: {
|
|
26
|
+
base: process.env.APP_ENV_SERVER_BASE_PATH,
|
|
27
|
+
isStrict: true,
|
|
28
|
+
},
|
|
29
|
+
debug: {
|
|
30
|
+
showRoutes: process.env.NODE_ENV !== "production",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Main Application class
|
|
35
|
+
export class Application extends BaseApplication {
|
|
36
|
+
override getAppInfo(): ValueOrPromise<IApplicationInfo> {
|
|
37
|
+
return packageJson;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
staticConfigure(): void {
|
|
41
|
+
// e.g., this.static({ folderPath: './public' })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
preConfigure(): ValueOrPromise<void> {
|
|
45
|
+
// Register all your resources here
|
|
46
|
+
this.dataSource(MyDataSource);
|
|
47
|
+
this.service(MyService);
|
|
48
|
+
this.controller(MyController);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
postConfigure(): ValueOrPromise<void> {
|
|
52
|
+
// Logic to run after everything is configured
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setupMiddlewares(): ValueOrPromise<void> {
|
|
56
|
+
// Add any custom application-wide middlewares
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Application Lifecycle
|
|
62
|
+
|
|
63
|
+
The `Ignis` application has a well-defined lifecycle, managed primarily by the `start()` and `initialize()` methods.
|
|
64
|
+
|
|
65
|
+
| Method | Description |
|
|
66
|
+
| :--- | :--- |
|
|
67
|
+
| **`constructor(opts)`** | Initializes the application, sets up the Hono server, and detects the runtime (Bun/Node). |
|
|
68
|
+
| **`start()`** | The main entry point. It calls `initialize()`, sets up middlewares, and starts the HTTP server. |
|
|
69
|
+
| **`stop()`** | Stops the application server. |
|
|
70
|
+
| **`initialize()`** | Orchestrates the entire setup process, calling the various configuration and registration methods in the correct order. |
|
|
71
|
+
|
|
72
|
+
The `BaseApplication` class provides several **overridable hook methods** that allow you to customize the startup process. These are the primary places you'll write your application-specific setup code.
|
|
73
|
+
|
|
74
|
+
| Hook Method | Purpose |
|
|
75
|
+
| :--- | :--- |
|
|
76
|
+
| `getAppInfo()` | **Required.** Return application metadata, usually from `package.json`. Used for OpenAPI docs. |
|
|
77
|
+
| `staticConfigure()` | Configure static file serving. |
|
|
78
|
+
| `preConfigure()` | **Most Important Hook.** Set up application resources like components, controllers, services, and datasources. |
|
|
79
|
+
| `postConfigure()` | Perform actions *after* all resources have been configured and instantiated. |
|
|
80
|
+
| `setupMiddlewares()`| Add custom application-level middlewares to the Hono instance. |
|
|
81
|
+
|
|
82
|
+
## Lifecycle Diagram
|
|
83
|
+
|
|
84
|
+
This diagram shows the sequence of operations during application startup. The methods you can override are highlighted.
|
|
85
|
+
|
|
86
|
+
```mermaid
|
|
87
|
+
%%{init: { "flowchart": { "useMaxWidth": true } } }%%
|
|
88
|
+
graph TD
|
|
89
|
+
A["start()"] --> B["initialize()"];
|
|
90
|
+
|
|
91
|
+
subgraph "initialize() Sequence"
|
|
92
|
+
direction TB
|
|
93
|
+
B --> B1["printStartUpInfo"];
|
|
94
|
+
B1 --> B2["validateEnvs"];
|
|
95
|
+
B2 --> B3["registerDefaultMiddlewares"];
|
|
96
|
+
B3 --> B4["staticConfigure()"];
|
|
97
|
+
B4 --> B5["preConfigure()"];
|
|
98
|
+
B5 --> B6["registerDataSources"];
|
|
99
|
+
B6 --> B7["registerComponents"];
|
|
100
|
+
B7 --> B8["registerControllers"];
|
|
101
|
+
B8 --> B9["postConfigure()"];
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
B9 --> C["setupMiddlewares()"];
|
|
105
|
+
C --> D["Mount Root Router"];
|
|
106
|
+
D --> E["Start HTTP Server"];
|
|
107
|
+
|
|
108
|
+
subgraph "Overridable Hooks"
|
|
109
|
+
style B4 fill:#ffc0cb,stroke:#333
|
|
110
|
+
style B5 fill:#ffc0cb,stroke:#333
|
|
111
|
+
style B9 fill:#ffc0cb,stroke:#333
|
|
112
|
+
style C fill:#ffc0cb,stroke:#333
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
classDef default fill:#fff,stroke:#333,stroke-width:2px;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Configuration
|
|
119
|
+
|
|
120
|
+
Application configuration is passed to the `BaseApplication` constructor via an `IApplicationConfigs` object.
|
|
121
|
+
|
|
122
|
+
### Configuration Options
|
|
123
|
+
|
|
124
|
+
| Option | Type | Default | Description |
|
|
125
|
+
| :--- | :--- | :--- | :--- |
|
|
126
|
+
| `host` | `string` | `'localhost'` | The host address to bind the server to. |
|
|
127
|
+
| `port` | `number` | `3000` | The port to listen on. |
|
|
128
|
+
| `path.base`| `string` | `'/'` | The base path for all application routes (e.g., `/api`). |
|
|
129
|
+
| `path.isStrict`| `boolean`| `true` | If `true`, the router is strict about trailing slashes. |
|
|
130
|
+
| `debug.showRoutes`| `boolean`| `false`| If `true`, prints all registered routes to the console on startup. |
|
|
131
|
+
| `favicon` | `string` | `'🔥'` | An emoji to be used as the application's favicon. |
|
|
132
|
+
|
|
133
|
+
### Example Configuration
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
export const appConfigs: IApplicationConfigs = {
|
|
137
|
+
host: "0.0.0.0",
|
|
138
|
+
port: 3000,
|
|
139
|
+
path: {
|
|
140
|
+
base: "/api",
|
|
141
|
+
isStrict: true,
|
|
142
|
+
},
|
|
143
|
+
debug: {
|
|
144
|
+
showRoutes: true,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Registering Resources
|
|
150
|
+
|
|
151
|
+
Register resources in `preConfigure()` to tell the DI container about your classes:
|
|
152
|
+
|
|
153
|
+
| Method | Example | When to Use |
|
|
154
|
+
|--------|---------|-------------|
|
|
155
|
+
| `this.controller(...)` | `this.controller(UserController)` | Register API endpoints |
|
|
156
|
+
| `this.service(...)` | `this.service(UserService)` | Register business logic |
|
|
157
|
+
| `this.repository(...)` | `this.repository(UserRepository)` | Register data access |
|
|
158
|
+
| `this.dataSource(...)` | `this.dataSource(PostgresDataSource)` | Register database connection |
|
|
159
|
+
| `this.component(...)` | `this.component(AuthComponent)` | Register reusable modules |
|
|
160
|
+
|
|
161
|
+
**Registration order:**
|
|
162
|
+
1. DataSources first (database connections)
|
|
163
|
+
2. Repositories (depend on DataSources)
|
|
164
|
+
3. Services (depend on Repositories)
|
|
165
|
+
4. Controllers (depend on Services)
|
|
166
|
+
5. Components last
|
|
167
|
+
|
|
168
|
+
> **Deep Dive:** See [Dependency Injection](./dependency-injection.md) for how registration and injection work together.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
Components are reusable, pluggable modules that encapsulate features like authentication, logging, or API documentation.
|
|
4
|
+
|
|
5
|
+
> **Deep Dive:** See [Components Reference](../../references/base/components.md) for technical details.
|
|
6
|
+
|
|
7
|
+
## What is a Component?
|
|
8
|
+
|
|
9
|
+
A component is a class that extends `BaseComponent` and is responsible for:
|
|
10
|
+
|
|
11
|
+
- **Binding Dependencies**: Registering services, controllers, providers, or other resources with the application's dependency injection container.
|
|
12
|
+
- **Configuring Features**: Setting up middlewares, initializing services, or performing any other setup required for the feature to work.
|
|
13
|
+
|
|
14
|
+
`Ignis` comes with several built-in components, which you can explore in the [**Components Reference**](../../references/components/) section:
|
|
15
|
+
|
|
16
|
+
- **`AuthenticateComponent`**: Sets up JWT-based authentication.
|
|
17
|
+
- **`SwaggerComponent`**: Generates interactive OpenAPI documentation.
|
|
18
|
+
- **`HealthCheckComponent`**: Adds a health check endpoint.
|
|
19
|
+
- **`RequestTrackerComponent`**: Adds request logging and tracing.
|
|
20
|
+
- **`SocketIOComponent`**: Integrates Socket.IO for real-time communication.
|
|
21
|
+
|
|
22
|
+
## Creating a Component
|
|
23
|
+
|
|
24
|
+
To create a new component, extend the `BaseComponent` class. The constructor is the ideal place to define any **default bindings** that the component provides.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { BaseApplication, BaseComponent, inject, CoreBindings, ValueOrPromise, Binding, BindingScopes } from '@venizia/ignis';
|
|
28
|
+
|
|
29
|
+
// An example service that the component will provide
|
|
30
|
+
class MyFeatureService {
|
|
31
|
+
// ... business logic
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A controller that depends on the service
|
|
35
|
+
@controller({ path: '/my-feature' })
|
|
36
|
+
class MyFeatureController {
|
|
37
|
+
constructor(
|
|
38
|
+
@inject({ key: 'services.MyFeatureService' })
|
|
39
|
+
private myFeatureService: MyFeatureService
|
|
40
|
+
) { /* ... */ }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class MyFeatureComponent extends BaseComponent {
|
|
44
|
+
constructor(
|
|
45
|
+
@inject({ key: CoreBindings.APPLICATION_INSTANCE })
|
|
46
|
+
private application: BaseApplication,
|
|
47
|
+
) {
|
|
48
|
+
super({
|
|
49
|
+
scope: MyFeatureComponent.name,
|
|
50
|
+
// Enable default bindings for this component
|
|
51
|
+
initDefault: { enable: true, container: application },
|
|
52
|
+
// Define the default bindings this component provides
|
|
53
|
+
bindings: {
|
|
54
|
+
'services.MyFeatureService': Binding.bind({ key: 'services.MyFeatureService' })
|
|
55
|
+
.toClass(MyFeatureService)
|
|
56
|
+
.setScope(BindingScopes.SINGLETON), // Make it a singleton
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override binding(): ValueOrPromise<void> {
|
|
62
|
+
// This is where you configure logic that USES the bindings.
|
|
63
|
+
// Here, we register a controller that depends on the service
|
|
64
|
+
// we just bound in the constructor.
|
|
65
|
+
this.application.controller(MyFeatureController);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Component Lifecycle
|
|
71
|
+
|
|
72
|
+
Components have a simple, two-stage lifecycle managed by the application.
|
|
73
|
+
|
|
74
|
+
| Stage | Method | Description |
|
|
75
|
+
| :--- | :--- | :--- |
|
|
76
|
+
| **1. Instantiation** | `constructor()` | The component is created by the DI container. This is where you call `super()` and define the component's `bindings`. If `initDefault` is enabled, these bindings are registered with the application container immediately. |
|
|
77
|
+
| **2. Configuration**| `binding()` | Called by the application during the `registerComponents` startup phase. This is where you should set up resources (like controllers) that *depend* on the bindings you defined in the constructor. |
|
|
78
|
+
|
|
79
|
+
## Registering a Component
|
|
80
|
+
|
|
81
|
+
To activate a component, you must register it with the application instance, usually in the `preConfigure` method of your `Application` class.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// in src/application.ts
|
|
85
|
+
import { MyFeatureComponent } from './components/my-feature.component';
|
|
86
|
+
|
|
87
|
+
// ... inside your Application class
|
|
88
|
+
|
|
89
|
+
preConfigure(): ValueOrPromise<void> {
|
|
90
|
+
// ...
|
|
91
|
+
this.component(MyFeatureComponent);
|
|
92
|
+
// ...
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
When the application starts, it will find the `MyFeatureComponent` binding, instantiate it, and then call its `binding()` method at the appropriate time. This modular approach keeps your main application class clean and makes it easy to toggle features on and off.
|