@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,123 @@
|
|
|
1
|
+
# Philosophy: The Best of Two Worlds
|
|
2
|
+
|
|
3
|
+
Ignis combines the structured, enterprise-grade development experience of **LoopBack 4** with the speed and simplicity of **Hono**.
|
|
4
|
+
|
|
5
|
+
## The Problem
|
|
6
|
+
|
|
7
|
+
When building REST APIs with Node.js/Bun, developers face a choice:
|
|
8
|
+
|
|
9
|
+
| Aspect | Minimal Frameworks | Enterprise Frameworks | **Ignis** |
|
|
10
|
+
|--------|-------------------|----------------------|-----------|
|
|
11
|
+
| **Examples** | Express, Hono, Fastify | NestJS, LoopBack | **Ignis** |
|
|
12
|
+
| **Performance** | ⚡ Very fast | 🐌 Slower | ⚡ Very fast (Hono) |
|
|
13
|
+
| **Architecture** | ❌ No structure | ✅ Structured | ✅ Structured |
|
|
14
|
+
| **Learning Curve** | ✅ Easy | ❌ Steep | ✅ Gradual |
|
|
15
|
+
| **Dependency Injection** | ❌ Manual | ✅ Built-in | ✅ Built-in |
|
|
16
|
+
| **Boilerplate** | ✅ Minimal | ❌ Heavy | ✅ Moderate |
|
|
17
|
+
| **Best For** | Prototypes, tiny APIs | Large enterprise apps | Growing APIs, teams |
|
|
18
|
+
|
|
19
|
+
### Ignis: The Middle Ground
|
|
20
|
+
|
|
21
|
+
Ignis provides the architectural benefits of enterprise frameworks while maintaining Hono's speed:
|
|
22
|
+
|
|
23
|
+
- ✅ **Enterprise patterns** (DI, layered architecture) without the bloat
|
|
24
|
+
- ✅ **Hono's performance** - one of the fastest frameworks
|
|
25
|
+
- ✅ **Gradual complexity** - start simple, add structure as you grow
|
|
26
|
+
- ✅ **TypeScript-first** with excellent type safety
|
|
27
|
+
|
|
28
|
+
## Inspired By The Best
|
|
29
|
+
|
|
30
|
+
### From LoopBack 4
|
|
31
|
+
|
|
32
|
+
[LoopBack 4](https://loopback.io/doc/en/lb4/index.html) proved that enterprise patterns work:
|
|
33
|
+
|
|
34
|
+
| Pattern | Benefit |
|
|
35
|
+
|---------|---------|
|
|
36
|
+
| **Dependency Injection** | Loosely coupled, testable code |
|
|
37
|
+
| **Layered Architecture** | Clear separation (Controllers → Services → Repositories) |
|
|
38
|
+
| **Component-Based** | Modular, reusable features |
|
|
39
|
+
| **Decorators** | Declarative metadata for routes and DI |
|
|
40
|
+
|
|
41
|
+
### From Hono
|
|
42
|
+
|
|
43
|
+
[Hono](https://hono.dev/) provides the performance foundation:
|
|
44
|
+
|
|
45
|
+
| Feature | Why It Matters |
|
|
46
|
+
|---------|----------------|
|
|
47
|
+
| **Ultrafast** | One of the fastest web frameworks |
|
|
48
|
+
| **Lightweight** | Minimal core, fast startup |
|
|
49
|
+
| **Modern API** | Clean, intuitive developer experience |
|
|
50
|
+
| **Multi-Runtime** | Works on Node.js, Bun, Deno, Cloudflare Workers |
|
|
51
|
+
|
|
52
|
+
### The Ignis Synthesis
|
|
53
|
+
|
|
54
|
+
Ignis = LoopBack patterns + Hono performance:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
┌─────────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
58
|
+
│ LoopBack 4 │ + │ Hono │ = │ Ignis │
|
|
59
|
+
│ │ │ │ │ │
|
|
60
|
+
│ • DI Container │ │ • Speed │ │ • DI + Speed │
|
|
61
|
+
│ • Layered Arch │ │ • Minimal │ │ • Structure │
|
|
62
|
+
│ • Components │ │ • Modern API │ │ • Components │
|
|
63
|
+
└─────────────────┘ └──────────────┘ └──────────────┘
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**What you get:**
|
|
67
|
+
- Familiar structure for LoopBack/NestJS developers
|
|
68
|
+
- Hono's performance and flexibility
|
|
69
|
+
- Pre-built components (auth, logging, database, etc.)
|
|
70
|
+
|
|
71
|
+
## When Should You Use Ignis?
|
|
72
|
+
|
|
73
|
+
### Decision Matrix
|
|
74
|
+
|
|
75
|
+
| Your Situation | Use Ignis? | Why |
|
|
76
|
+
|----------------|------------|-----|
|
|
77
|
+
| Building 10+ endpoint API | ✅ Yes | Structure prevents spaghetti code |
|
|
78
|
+
| Team of 2+ developers | ✅ Yes | Patterns improve collaboration |
|
|
79
|
+
| Need database + auth + docs | ✅ Yes | Built-in components save time |
|
|
80
|
+
| Coming from NestJS/LoopBack | ✅ Yes | Familiar patterns, better performance |
|
|
81
|
+
| Prototyping quickly | ❌ No | Use plain Hono for speed |
|
|
82
|
+
| Simple proxy/webhook | ❌ No | Too much structure |
|
|
83
|
+
| 3-5 endpoints, solo dev | 🤔 Maybe | Start with Hono, migrate later if needed |
|
|
84
|
+
|
|
85
|
+
### ✅ Perfect For
|
|
86
|
+
|
|
87
|
+
**E-commerce Backends:**
|
|
88
|
+
- Controllers for products, orders, users, payments
|
|
89
|
+
- Services for business logic (tax, inventory)
|
|
90
|
+
- Repository pattern for data access
|
|
91
|
+
- JWT authentication + OpenAPI docs
|
|
92
|
+
|
|
93
|
+
**SaaS Platform APIs:**
|
|
94
|
+
- Multi-tenant architecture
|
|
95
|
+
- Complex business rules
|
|
96
|
+
- Modular components
|
|
97
|
+
- Easy testing with DI
|
|
98
|
+
|
|
99
|
+
**Enterprise Tools:**
|
|
100
|
+
- CRUD operations via `ControllerFactory`
|
|
101
|
+
- Team collaboration with clear patterns
|
|
102
|
+
- Type-safe database operations
|
|
103
|
+
- Automatic validation
|
|
104
|
+
|
|
105
|
+
## The Trade-off
|
|
106
|
+
|
|
107
|
+
| You Gain | You Give Up |
|
|
108
|
+
|----------|-------------|
|
|
109
|
+
| Clear architecture | ~100 lines setup boilerplate |
|
|
110
|
+
| Built-in DI, validation, docs | Learning curve for patterns |
|
|
111
|
+
| Faster for medium/large projects | Slightly more abstraction than Hono |
|
|
112
|
+
| Easier testing | Initial time investment |
|
|
113
|
+
| Team scalability | Convention over total freedom |
|
|
114
|
+
|
|
115
|
+
**Bottom line:** If you're building more than a simple API, the structure pays off in maintainability and productivity.
|
|
116
|
+
|
|
117
|
+
## Next Steps
|
|
118
|
+
|
|
119
|
+
Ready to get started?
|
|
120
|
+
|
|
121
|
+
1. [Check Prerequisites](./prerequisites.md) - Install required tools
|
|
122
|
+
2. [Quickstart Guide](./quickstart.md) - Build your first endpoint
|
|
123
|
+
3. [CRUD Tutorial](./building-a-crud-api.md) - Build a complete API
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
|
|
3
|
+
Before starting with Ignis, ensure you have the following installed and configured.
|
|
4
|
+
|
|
5
|
+
> **New to Ignis?** This is a TypeScript REST API framework that combines enterprise patterns with high performance. [Learn more about the philosophy](./philosophy.md).
|
|
6
|
+
|
|
7
|
+
## Required Software
|
|
8
|
+
|
|
9
|
+
| Tool | Version | Purpose | Installation |
|
|
10
|
+
|------|---------|---------|--------------|
|
|
11
|
+
| **Bun** | ≥ 1.3 | JavaScript runtime & package manager | [bun.sh](https://bun.sh) |
|
|
12
|
+
| **PostgreSQL** | ≥ 14.x | Database server for storing your data | [postgresql.org/download](https://www.postgresql.org/download/) |
|
|
13
|
+
|
|
14
|
+
### Installation Quick Links
|
|
15
|
+
|
|
16
|
+
**Bun:**
|
|
17
|
+
```bash
|
|
18
|
+
# macOS/Linux
|
|
19
|
+
curl -fsSL https://bun.sh/install | bash
|
|
20
|
+
|
|
21
|
+
# Windows (requires WSL)
|
|
22
|
+
# First install WSL, then run the command above
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**PostgreSQL:**
|
|
26
|
+
- **macOS:** `brew install postgresql@14` (requires [Homebrew](https://brew.sh))
|
|
27
|
+
- **Ubuntu/Debian:** `sudo apt-get install postgresql-14`
|
|
28
|
+
- **Windows:** Download installer from [postgresql.org](https://www.postgresql.org/download/windows/)
|
|
29
|
+
|
|
30
|
+
### Verify Installation
|
|
31
|
+
|
|
32
|
+
After installing, verify everything works:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Check Bun
|
|
36
|
+
bun --version
|
|
37
|
+
# Expected: 1.3.0 or higher
|
|
38
|
+
|
|
39
|
+
# Check PostgreSQL
|
|
40
|
+
psql --version
|
|
41
|
+
# Expected: psql (PostgreSQL) 14.x or higher
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Required Knowledge
|
|
45
|
+
|
|
46
|
+
You should be comfortable with:
|
|
47
|
+
|
|
48
|
+
- **TypeScript basics** - Variables, functions, classes, interfaces
|
|
49
|
+
- **REST APIs** - What GET, POST, PUT, DELETE mean
|
|
50
|
+
- **Async/await** - Handling asynchronous code in JavaScript
|
|
51
|
+
- **SQL basics** - What a database table is, basic SELECT/INSERT/UPDATE/DELETE
|
|
52
|
+
|
|
53
|
+
**Don't have these?** You can still follow along, but consider bookmarking these resources:
|
|
54
|
+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html)
|
|
55
|
+
- [REST API Tutorial](https://restfulapi.net/)
|
|
56
|
+
|
|
57
|
+
## Database Setup
|
|
58
|
+
|
|
59
|
+
Create a database for your application:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Start PostgreSQL service (if not already running)
|
|
63
|
+
# macOS with Homebrew:
|
|
64
|
+
brew services start postgresql@14
|
|
65
|
+
|
|
66
|
+
# Ubuntu/Debian:
|
|
67
|
+
sudo service postgresql start
|
|
68
|
+
|
|
69
|
+
# Connect to PostgreSQL
|
|
70
|
+
psql -U postgres
|
|
71
|
+
|
|
72
|
+
# Inside psql, create your database:
|
|
73
|
+
CREATE DATABASE my_app_db;
|
|
74
|
+
|
|
75
|
+
# Verify it was created:
|
|
76
|
+
\l
|
|
77
|
+
|
|
78
|
+
# Exit psql:
|
|
79
|
+
\q
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**What just happened?**
|
|
83
|
+
- `psql -U postgres` - Connect as the default "postgres" superuser
|
|
84
|
+
- `CREATE DATABASE my_app_db;` - Creates an empty database to store your app's data
|
|
85
|
+
- `\l` - Lists all databases (you should see `my_app_db` in the list)
|
|
86
|
+
|
|
87
|
+
**Troubleshooting:**
|
|
88
|
+
- **"postgres" user doesn't exist?** Try `psql -U your_username` (your system username)
|
|
89
|
+
- **Password prompt?** Default PostgreSQL installations often have no password. If prompted, check your installation docs.
|
|
90
|
+
- **Connection refused?** PostgreSQL service isn't running. Check the `brew services start` or `sudo service postgresql start` command.
|
|
91
|
+
|
|
92
|
+
## Text Editor Setup (Optional but Recommended)
|
|
93
|
+
|
|
94
|
+
Any editor works, but **VS Code** has the best TypeScript support:
|
|
95
|
+
|
|
96
|
+
1. Install [VS Code](https://code.visualstudio.com/)
|
|
97
|
+
2. Install these extensions:
|
|
98
|
+
- **ESLint** - Catches code errors
|
|
99
|
+
- **Prettier** - Auto-formats code
|
|
100
|
+
- **TypeScript + JavaScript** - Built-in, enables autocomplete
|
|
101
|
+
|
|
102
|
+
## Ready to Start?
|
|
103
|
+
|
|
104
|
+
✅ Bun installed and working
|
|
105
|
+
✅ PostgreSQL installed and running
|
|
106
|
+
✅ Database created
|
|
107
|
+
✅ Basic TypeScript knowledge
|
|
108
|
+
|
|
109
|
+
Continue to the [Quickstart Guide](./quickstart.md) to build your first API!
|
|
110
|
+
|
|
111
|
+
**Alternative paths:**
|
|
112
|
+
- Want to understand "why Ignis"? Read [Philosophy](./philosophy.md) first
|
|
113
|
+
- Want to see the full picture? Check [Getting Started Overview](./index.md)
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Quickstart Guide
|
|
2
|
+
|
|
3
|
+
This guide walks you through creating a new web application with Ignis and setting up a professional development environment.
|
|
4
|
+
|
|
5
|
+
> **Prerequisites:** Ensure you have [Bun installed and basic TypeScript knowledge](./prerequisites.md) before starting.
|
|
6
|
+
|
|
7
|
+
## 1. Initialize Your Project
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
mkdir my-app
|
|
11
|
+
cd my-app
|
|
12
|
+
bun init -y
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 2. Install Dependencies
|
|
16
|
+
|
|
17
|
+
### Production Dependencies
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun add hono @hono/zod-openapi @scalar/hono-api-reference @venizia/ignis dotenv-flow
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**What each package does:**
|
|
24
|
+
- `hono` - High-performance web framework
|
|
25
|
+
- `@hono/zod-openapi` - OpenAPI schema generation with Zod validation
|
|
26
|
+
- `@scalar/hono-api-reference` - Interactive API documentation UI
|
|
27
|
+
- `@venizia/ignis` - Core Ignis framework
|
|
28
|
+
- `dotenv-flow` - Environment variable management
|
|
29
|
+
|
|
30
|
+
### Development Dependencies
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
bun add -d typescript @types/bun @venizia/dev-configs tsc-alias tsconfig-paths
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**What `@venizia/dev-configs` provides:**
|
|
37
|
+
- Centralized ESLint configuration
|
|
38
|
+
- Centralized Prettier configuration
|
|
39
|
+
- Shared TypeScript base configs
|
|
40
|
+
- Consistent code style across all Ignis projects
|
|
41
|
+
|
|
42
|
+
> **Note:** Database dependencies (drizzle-orm, pg, etc.) will be added later in the [CRUD Tutorial](./building-a-crud-api.md).
|
|
43
|
+
|
|
44
|
+
## 3. Configure Development Tools
|
|
45
|
+
|
|
46
|
+
All development configurations are centralized in the `@venizia/dev-configs` package for consistency and ease of maintenance.
|
|
47
|
+
|
|
48
|
+
### TypeScript
|
|
49
|
+
|
|
50
|
+
Create `tsconfig.json` in your project root:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"$schema": "http://json.schemastore.org/tsconfig",
|
|
55
|
+
"extends": "@venizia/dev-configs/tsconfig.common.json",
|
|
56
|
+
"compilerOptions": {
|
|
57
|
+
"outDir": "dist",
|
|
58
|
+
"rootDir": "src",
|
|
59
|
+
"baseUrl": "src",
|
|
60
|
+
"paths": {
|
|
61
|
+
"@/*": ["./*"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"include": ["src", "./*.config.*", ".prettierrc.*"],
|
|
65
|
+
"exclude": ["node_modules", "dist"]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> **Note:** The `extends` field pulls in all TypeScript configuration from `@venizia/dev-configs/tsconfig.common.json`, which includes decorator support, strict mode, and ES2022 target settings.
|
|
70
|
+
|
|
71
|
+
### Prettier
|
|
72
|
+
|
|
73
|
+
Create `.prettierrc.mjs` for code formatting:
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
import { prettierConfigs } from '@venizia/dev-configs';
|
|
77
|
+
|
|
78
|
+
export default prettierConfigs;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Create `.prettierignore`:
|
|
82
|
+
```
|
|
83
|
+
dist
|
|
84
|
+
node_modules
|
|
85
|
+
*.log
|
|
86
|
+
.*-audit.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> **Customization:** To override Prettier settings, merge with the base config:
|
|
90
|
+
> ```javascript
|
|
91
|
+
> import { prettierConfigs } from '@venizia/dev-configs';
|
|
92
|
+
> export default { ...prettierConfigs, printWidth: 120 };
|
|
93
|
+
> ```
|
|
94
|
+
|
|
95
|
+
### ESLint
|
|
96
|
+
|
|
97
|
+
Create `eslint.config.mjs` for code linting:
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
import { eslintConfigs } from '@venizia/dev-configs';
|
|
101
|
+
|
|
102
|
+
export default eslintConfigs;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> **Customization:** To add project-specific rules:
|
|
106
|
+
> ```javascript
|
|
107
|
+
> import { eslintConfigs } from '@venizia/dev-configs';
|
|
108
|
+
> export default [...eslintConfigs, { rules: { 'no-console': 'warn' } }];
|
|
109
|
+
> ```
|
|
110
|
+
|
|
111
|
+
> **Deep Dive:** See [Code Style Standards](./best-practices/code-style-standards.md) for detailed configuration options.
|
|
112
|
+
|
|
113
|
+
:::tip A Note on Setup for Express/Hono/Fastify Developers
|
|
114
|
+
If you're coming from a minimal framework like Express, Hono, or Fastify, you might be thinking: "This is a lot of setup just to get started!"
|
|
115
|
+
|
|
116
|
+
You're right—and it's intentional. Here's why:
|
|
117
|
+
|
|
118
|
+
**In Express/Hono/Fastify, you might start with:**
|
|
119
|
+
```javascript
|
|
120
|
+
const app = require('express')();
|
|
121
|
+
app.get('/', (req, res) => res.json({ hello: 'world' }));
|
|
122
|
+
app.listen(3000);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
That's 3 lines. Beautiful and fast.
|
|
126
|
+
|
|
127
|
+
**The problem comes later:**
|
|
128
|
+
- Where do you put database logic?
|
|
129
|
+
- How do you organize routes when you have 50+ endpoints?
|
|
130
|
+
- How do you share code between routes?
|
|
131
|
+
- How do you validate requests?
|
|
132
|
+
- How do you generate API docs?
|
|
133
|
+
- How do you test business logic in isolation?
|
|
134
|
+
|
|
135
|
+
`Ignis` answers these questions upfront with:
|
|
136
|
+
- **Type Safety (`tsconfig.json`):** Catches errors before they reach production
|
|
137
|
+
- **Consistent Formatting (`.prettierrc.mjs`):** No more debates about code style in PRs
|
|
138
|
+
- **Code Quality (`eslint.config.mjs`):** Prevents common bugs and enforces best practices
|
|
139
|
+
|
|
140
|
+
**The trade-off:** You write 50-100 lines of config once. In return, you get a scalable architecture that handles projects with 10, 100, or 1000+ endpoints without becoming spaghetti code.
|
|
141
|
+
|
|
142
|
+
If you're building a quick prototype or tiny API (< 5 endpoints), stick with plain Hono. But if your API will grow or be maintained by a team, this setup pays for itself within a week.
|
|
143
|
+
:::
|
|
144
|
+
|
|
145
|
+
## 4. Build Your First Application
|
|
146
|
+
|
|
147
|
+
### Create Project Structure
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
mkdir -p src/controllers
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Your structure will look like:
|
|
154
|
+
```
|
|
155
|
+
src/
|
|
156
|
+
├── application.ts
|
|
157
|
+
├── index.ts
|
|
158
|
+
└── controllers/
|
|
159
|
+
└── hello.controller.ts
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Create Application Class
|
|
163
|
+
|
|
164
|
+
Create `src/application.ts` - this is where you configure and register all your application resources:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { BaseApplication, IApplicationConfigs, IApplicationInfo, ValueOrPromise } from '@venizia/ignis';
|
|
168
|
+
import { HelloController } from './controllers/hello.controller';
|
|
169
|
+
import packageJson from '../package.json';
|
|
170
|
+
|
|
171
|
+
// Define application configurations
|
|
172
|
+
export const appConfigs: IApplicationConfigs = {
|
|
173
|
+
host: process.env.HOST ?? '0.0.0.0', // Where your server listens
|
|
174
|
+
port: +(process.env.PORT ?? 3000), // Port number
|
|
175
|
+
path: { base: '/api', isStrict: true }, // All routes will be under /api
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export class Application extends BaseApplication {
|
|
179
|
+
// Required: Tell the framework about your app (used for API docs)
|
|
180
|
+
override getAppInfo(): ValueOrPromise<IApplicationInfo> {
|
|
181
|
+
return packageJson;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Hook 1: Configure static file serving (e.g., serve images from /public)
|
|
185
|
+
staticConfigure(): void {
|
|
186
|
+
// Example: this.static({ folderPath: './public' })
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Hook 2: Add global middlewares (CORS, compression, etc.)
|
|
190
|
+
setupMiddlewares(): ValueOrPromise<void> {
|
|
191
|
+
// Example: this.server.use(cors())
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Hook 3: Register your resources (THIS IS THE MOST IMPORTANT ONE)
|
|
195
|
+
preConfigure(): ValueOrPromise<void> {
|
|
196
|
+
// As your app grows, you'll add:
|
|
197
|
+
// this.dataSource(PostgresDataSource); // Database connection
|
|
198
|
+
// this.repository(UserRepository); // Data access layer
|
|
199
|
+
// this.service(UserService); // Business logic
|
|
200
|
+
// this.component(AuthComponent); // Auth setup
|
|
201
|
+
|
|
202
|
+
// For now, just register our controller
|
|
203
|
+
this.controller(HelloController);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Hook 4: Do cleanup or extra work after everything is set up
|
|
207
|
+
postConfigure(): ValueOrPromise<void> {
|
|
208
|
+
// Example: Seed database, start background jobs, etc.
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Key takeaway:** You'll mostly work in `preConfigure()` when building your app. The other hooks are there when you need them.
|
|
214
|
+
|
|
215
|
+
**Application Lifecycle Hooks:**
|
|
216
|
+
| Hook | Purpose | Usage |
|
|
217
|
+
|------|---------|-------|
|
|
218
|
+
| `getAppInfo()` | Application metadata | Required - used for API docs |
|
|
219
|
+
| `staticConfigure()` | Static file serving | Optional |
|
|
220
|
+
| `setupMiddlewares()` | Global middlewares | Optional |
|
|
221
|
+
| `preConfigure()` | **Register resources** | **Main hook** - register controllers, services, etc. |
|
|
222
|
+
| `postConfigure()` | Post-initialization | Optional - seed data, background jobs |
|
|
223
|
+
|
|
224
|
+
> **Deep Dive:** See [Application Class Reference](./core-concepts/application.md) for detailed lifecycle documentation.
|
|
225
|
+
|
|
226
|
+
### Create Controller
|
|
227
|
+
|
|
228
|
+
Create `src/controllers/hello.controller.ts` - controllers handle HTTP requests and return responses:
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import {
|
|
232
|
+
BaseController,
|
|
233
|
+
controller,
|
|
234
|
+
get, // Import the 'get' decorator
|
|
235
|
+
HTTP,
|
|
236
|
+
jsonContent,
|
|
237
|
+
} from '@venizia/ignis';
|
|
238
|
+
import { z } from '@hono/zod-openapi';
|
|
239
|
+
import { Context } from 'hono';
|
|
240
|
+
|
|
241
|
+
const BASE_PATH = '/hello';
|
|
242
|
+
|
|
243
|
+
// The @controller decorator registers this class as a controller
|
|
244
|
+
// All routes in this controller will be under /api/hello (remember path.base: '/api')
|
|
245
|
+
@controller({ path: BASE_PATH })
|
|
246
|
+
export class HelloController extends BaseController {
|
|
247
|
+
constructor() {
|
|
248
|
+
super({ scope: HelloController.name, path: BASE_PATH });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// The @get decorator defines a GET route at /api/hello/
|
|
252
|
+
@get({
|
|
253
|
+
configs: {
|
|
254
|
+
path: '/',
|
|
255
|
+
// This 'responses' config does two things:
|
|
256
|
+
// 1. Generates OpenAPI/Swagger documentation automatically
|
|
257
|
+
// 2. Validates that your handler returns the correct shape
|
|
258
|
+
responses: {
|
|
259
|
+
[HTTP.ResultCodes.RS_2.Ok]: jsonContent({
|
|
260
|
+
description: 'A simple hello message',
|
|
261
|
+
schema: z.object({ message: z.string() }), // Zod schema for validation
|
|
262
|
+
}),
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
sayHello(c: Context) {
|
|
267
|
+
// This looks just like Hono! Because it IS Hono under the hood.
|
|
268
|
+
return c.json({ message: 'Hello, World!' });
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// You can add more routes here:
|
|
272
|
+
// @post({ configs: { ... } })
|
|
273
|
+
// createSomething(c: Context) { ... }
|
|
274
|
+
|
|
275
|
+
// For authenticated endpoints, add 'authStrategies' to the configs:
|
|
276
|
+
// @get({ configs: { path: '/secure', authStrategies: [Authentication.STRATEGY_JWT] } })
|
|
277
|
+
// secureMethod(c: Context) { /* ... */ }
|
|
278
|
+
|
|
279
|
+
// For database CRUD operations, use ControllerFactory (covered in the CRUD tutorial)
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Controller Decorators:**
|
|
284
|
+
- `@controller` - Registers the class as a controller with a base path
|
|
285
|
+
- `@get`, `@post`, `@put`, `@patch`, `@del` - Define HTTP endpoints
|
|
286
|
+
- Zod schemas provide automatic validation and OpenAPI docs
|
|
287
|
+
|
|
288
|
+
> **Deep Dive:** See [Controllers Reference](./core-concepts/controllers.md) for advanced routing patterns and validation.
|
|
289
|
+
|
|
290
|
+
### Create Entry Point
|
|
291
|
+
|
|
292
|
+
Create `src/index.ts` - this starts your application:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { Application, appConfigs } from './application';
|
|
296
|
+
import { LoggerFactory } from '@venizia/ignis';
|
|
297
|
+
|
|
298
|
+
const logger = LoggerFactory.getLogger(['main']);
|
|
299
|
+
|
|
300
|
+
const main = async () => {
|
|
301
|
+
const application = new Application({
|
|
302
|
+
scope: 'MyApp',
|
|
303
|
+
config: appConfigs,
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const applicationName = process.env.APP_ENV_APPLICATION_NAME?.toUpperCase() ?? 'My-App';
|
|
307
|
+
logger.info('[main] Getting ready to start up %s Application...', applicationName);
|
|
308
|
+
await application.start();
|
|
309
|
+
return application;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export default main();
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## 5. Run Your Application
|
|
316
|
+
|
|
317
|
+
Add common application scripts to your `package.json`:
|
|
318
|
+
|
|
319
|
+
```json
|
|
320
|
+
"scripts": {
|
|
321
|
+
"lint": "bun run eslint && bun run prettier:cli",
|
|
322
|
+
"lint:fix": "bun run eslint --fix && bun run prettier:fix",
|
|
323
|
+
"prettier:cli": "prettier \"**/*.{js,ts}\" -l",
|
|
324
|
+
"prettier:fix": "bun run prettier:cli --write",
|
|
325
|
+
"eslint": "eslint --report-unused-disable-directives .",
|
|
326
|
+
"build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
|
|
327
|
+
"compile:linux": "bun build --compile --minify --sourcemap --target=bun-linux-x64 ./src/index.ts --outfile ./dist/my_app",
|
|
328
|
+
"clean": "sh ./scripts/clean.sh",
|
|
329
|
+
"rebuild": "bun run clean && bun run build",
|
|
330
|
+
"migrate:dev": "NODE_ENV=development drizzle-kit push --config=src/migration.ts",
|
|
331
|
+
"generate-migration:dev": "NODE_ENV=development drizzle-kit generate --config=src/migration.ts",
|
|
332
|
+
"preserver:dev": "bun run rebuild",
|
|
333
|
+
"server:dev": "NODE_ENV=development bun .",
|
|
334
|
+
"server:prod": "NODE_ENV=production bun ."
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Create a cleanup script at `scripts/clean.sh`:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
#!/bin/bash
|
|
342
|
+
|
|
343
|
+
echo "START | Clean up..."
|
|
344
|
+
|
|
345
|
+
rm -rf dist *.tsbuildinfo .eslintcache
|
|
346
|
+
rm -rf artifact.zip
|
|
347
|
+
|
|
348
|
+
echo "DONE | Clean up..."
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Now, start your application:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
bun run server:dev
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Your server will be running on `http://localhost:3000`. You can access your new endpoint at `http://localhost:3000/api/hello`.
|
|
359
|
+
|
|
360
|
+
Test with curl:
|
|
361
|
+
```bash
|
|
362
|
+
curl http://localhost:3000/api/hello
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Response:
|
|
366
|
+
```json
|
|
367
|
+
{"message":"Hello, World!"}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Congratulations! You have successfully created and configured your first application with the `Ignis` framework.
|
|
371
|
+
|
|
372
|
+
## Continue Your Journey
|
|
373
|
+
|
|
374
|
+
✅ You now have a working Ignis application!
|
|
375
|
+
|
|
376
|
+
**Next steps:**
|
|
377
|
+
|
|
378
|
+
1. **[Building a CRUD API](./building-a-crud-api.md)** - Add database, create full REST API with CRUD operations
|
|
379
|
+
2. **[Core Concepts](./core-concepts/application.md)** - Deep dive into application architecture
|
|
380
|
+
3. **[Best Practices](./best-practices/architectural-patterns.md)** - Learn recommended patterns and practices
|
|
381
|
+
|
|
382
|
+
> **Deep Dive:** See [API Usage Examples](./best-practices/api-usage-examples.md) for more routing patterns and controller techniques.
|
package/wiki/index.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
# https://vitepress.dev/reference/default-theme-home-page
|
|
3
|
+
layout: home
|
|
4
|
+
|
|
5
|
+
hero:
|
|
6
|
+
name: "🔥 IGNIS"
|
|
7
|
+
text: "A TypeScript Server Infrastructure with Hono"
|
|
8
|
+
tagline: Enterprise-grade architecture meets Hono's ultrafast performance. Build scalable REST APIs with TypeScript.
|
|
9
|
+
actions:
|
|
10
|
+
- theme: brand
|
|
11
|
+
text: Get Started
|
|
12
|
+
link: /get-started/
|
|
13
|
+
- theme: alt
|
|
14
|
+
text: Quickstart
|
|
15
|
+
link: /get-started/quickstart
|
|
16
|
+
- theme: alt
|
|
17
|
+
text: Philosophy
|
|
18
|
+
link: /get-started/philosophy
|
|
19
|
+
|
|
20
|
+
features:
|
|
21
|
+
- icon: <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-zap"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>
|
|
22
|
+
title: Ultrafast Hono Performance
|
|
23
|
+
details: Leverage Hono's speed for high-performance APIs and serverless environments, ensuring your applications are always responsive.
|
|
24
|
+
|
|
25
|
+
- icon: <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-branch"><line x1="6" y1="3" x2="6" y2="15"></line><path d="M18 6l-6 6-6-6"></path><path d="M12 18V6"></path><path d="M18 12l-6 6-6-6"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="6" r="3"></circle></svg>
|
|
26
|
+
title: Modular Package Architecture
|
|
27
|
+
details: Built as a monorepo with independent packages (@venizia/ignis, @venizia/ignis-helpers, @venizia/ignis-inversion, @venizia/dev-configs) for flexible, granular consumption.
|
|
28
|
+
|
|
29
|
+
- icon: <svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-share-2"><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="12" r="3"></circle><circle cx="18" cy="18" r="3"></circle><line x1="8.59" y1="13.51" x2="15.42" y2="16.49"></line><line x1="15.41" y1="7.51" x2="8.59" y2="10.49"></line></svg>
|
|
30
|
+
title: Powerful Dependency Injection
|
|
31
|
+
details: Utilize a custom, lightweight DI container to promote loose coupling, enhanced testability, and flexible code organization.
|
|
32
|
+
|
|
33
|
+
- icon: <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-layers"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
|
|
34
|
+
title: Clear Layered Architecture
|
|
35
|
+
details: Organize your code with a strict separation of concerns (Controllers, Services, Repositories) for maintainability and clarity.
|
|
36
|
+
|
|
37
|
+
- icon: <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-book-open"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path></svg>
|
|
38
|
+
title: Automated OpenAPI Documentation
|
|
39
|
+
details: Generate interactive Swagger UI documentation effortlessly from your Zod schemas, simplifying API consumption and understanding.
|
|
40
|
+
|
|
41
|
+
- icon: <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tool"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-2.06 2.06A7.5 7.5 0 0 1 1.07 11.24a7.5 7.5 0 0 1 10.6-10.6z"></path></svg>
|
|
42
|
+
title: Rich & Extensible Ecosystem
|
|
43
|
+
details: Benefit from comprehensive built-in helpers for Authentication, Logging, Database interactions, Queues, Worker Threads, and more.
|
|
44
|
+
|
|
45
|
+
footer:
|
|
46
|
+
message: Released under the MIT License.
|
|
47
|
+
copyright: Copyright © 2024-present VENIZIA-AI
|
|
48
|
+
---
|