simpledi-app-generator 0.0.19 → 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/README.md +7 -7
- package/package.json +1 -1
- package/user-guide.md +33 -19
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ my-project/
|
|
|
63
63
|
└── src/
|
|
64
64
|
├── AppModule.ts # Root module
|
|
65
65
|
├── schema.ts # Drizzle schema exports
|
|
66
|
-
├── main.routes.ts #
|
|
66
|
+
├── main.routes.ts # Auto-discovers *Routes.{ts,js} files via Bun glob
|
|
67
67
|
├── core/ # Entity modules (generated)
|
|
68
68
|
├── lib/ # Utilities, types, errors
|
|
69
69
|
└── use-case/ # Use case modules
|
|
@@ -76,16 +76,16 @@ my-project/
|
|
|
76
76
|
Generated projects use [Neon](https://neon.tech) serverless PostgreSQL. Add your connection string to `.env.development`:
|
|
77
77
|
|
|
78
78
|
```env
|
|
79
|
-
|
|
79
|
+
CONNECTION_STRING=postgres://user:password@your-neon-host.neon.tech/dbname?sslmode=require
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
### Environment Variables
|
|
83
83
|
|
|
84
|
-
| Variable
|
|
85
|
-
|
|
|
86
|
-
| `
|
|
87
|
-
| `JWT_SECRET`
|
|
88
|
-
| `PORT`
|
|
84
|
+
| Variable | Description |
|
|
85
|
+
| ------------------- | --------------------------------- |
|
|
86
|
+
| `CONNECTION_STRING` | Neon PostgreSQL connection string |
|
|
87
|
+
| `JWT_SECRET` | Secret key for JWT tokens |
|
|
88
|
+
| `PORT` | Server port (default: 3000) |
|
|
89
89
|
|
|
90
90
|
## Tech Stack
|
|
91
91
|
|
package/package.json
CHANGED
package/user-guide.md
CHANGED
|
@@ -37,7 +37,7 @@ my-app/
|
|
|
37
37
|
└── src/
|
|
38
38
|
├── AppModule.ts # Root DI module
|
|
39
39
|
├── schema.ts # Drizzle schema exports
|
|
40
|
-
├── main.routes.ts #
|
|
40
|
+
├── main.routes.ts # Auto-discovers *Routes.{ts,js} via Bun glob
|
|
41
41
|
├── core/ # Entity modules
|
|
42
42
|
│ └── CoreModule.ts
|
|
43
43
|
├── lib/ # Utilities, types, errors
|
|
@@ -47,6 +47,9 @@ my-app/
|
|
|
47
47
|
└── health-check/
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
> [!NOTE]
|
|
51
|
+
> Routes are **automatically registered** — any file matching `*Routes.{ts,js}` that exports `Route` and `Path` is picked up by the glob scanner. No manual wiring needed.
|
|
52
|
+
|
|
50
53
|
---
|
|
51
54
|
|
|
52
55
|
### `simpledi module <entity-name>`
|
|
@@ -88,7 +91,7 @@ simpledi module blog-post
|
|
|
88
91
|
- Adds export to `src/schema.ts`
|
|
89
92
|
- Adds module to `src/core/CoreModule.ts`
|
|
90
93
|
- Adds use case module to `src/use-case/UseCaseModule.ts`
|
|
91
|
-
-
|
|
94
|
+
- Routes are auto-discovered via `main.routes.ts` glob — no manual registration required
|
|
92
95
|
|
|
93
96
|
---
|
|
94
97
|
|
|
@@ -107,25 +110,36 @@ simpledi use-case assign-role imports=user
|
|
|
107
110
|
|
|
108
111
|
**Generated files** in `src/use-case/<name>/`:
|
|
109
112
|
|
|
110
|
-
| File | Purpose
|
|
111
|
-
| -------------------------- |
|
|
112
|
-
| `<Name>.ts` | Use case class with `@Service` decorator and Module export
|
|
113
|
-
| `<name>Routes.ts` | Hono route handler
|
|
114
|
-
| `outputs/<Name>Success.ts` | Typed success response + payload type
|
|
115
|
-
| `outputs/<Name>Failure.ts` | Typed failure response
|
|
113
|
+
| File | Purpose |
|
|
114
|
+
| -------------------------- | ------------------------------------------------------------------ |
|
|
115
|
+
| `<Name>.ts` | Use case class with `@Service` decorator and Module export |
|
|
116
|
+
| `<name>Routes.ts` | Hono route handler — exports `Route` and `Path` for auto-discovery |
|
|
117
|
+
| `outputs/<Name>Success.ts` | Typed success response + payload type |
|
|
118
|
+
| `outputs/<Name>Failure.ts` | Typed failure response |
|
|
119
|
+
| `<Name>.e2e.spec.ts` | Stub E2E test _(only when `imports=` is provided)_ |
|
|
116
120
|
|
|
117
121
|
**Auto-registration:**
|
|
118
122
|
|
|
119
123
|
- Adds module to `src/use-case/UseCaseModule.ts`
|
|
120
|
-
-
|
|
124
|
+
- Route is auto-discovered via `main.routes.ts` glob — no manual registration required
|
|
125
|
+
|
|
126
|
+
**`imports=` parameter:**
|
|
121
127
|
|
|
122
|
-
|
|
128
|
+
When you specify `imports=user,cohort,enrollment` the generator:
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
1. Adds each entity's `Module` to the use case module's `imports` array
|
|
131
|
+
2. Generates a ready-to-run stub E2E spec (`<Name>.e2e.spec.ts`) that:
|
|
132
|
+
- Imports each entity's `Repository` type and `*_REPOSITORY_INTERFACE` token
|
|
133
|
+
- Declares `let` variables for each repository
|
|
134
|
+
- Wires up `bootstrap()` with all modules + the use case module
|
|
135
|
+
- Calls `inject()` for each repository
|
|
136
|
+
- Cleans up schemas in **reverse** import order (dependencies last)
|
|
137
|
+
- Includes a `test('repos are defined')` smoke test to verify DI is wired correctly
|
|
125
138
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
```bash
|
|
140
|
+
# Generates EnrollStudent.e2e.spec.ts with user, cohort, enrollment repo setup
|
|
141
|
+
simpledi use-case enroll-student imports=user,cohort,enrollment
|
|
142
|
+
```
|
|
129
143
|
|
|
130
144
|
---
|
|
131
145
|
|
|
@@ -191,11 +205,11 @@ bun run prepare
|
|
|
191
205
|
|
|
192
206
|
## Environment Variables
|
|
193
207
|
|
|
194
|
-
| Variable
|
|
195
|
-
|
|
|
196
|
-
| `
|
|
197
|
-
| `JWT_SECRET`
|
|
198
|
-
| `PORT`
|
|
208
|
+
| Variable | Description |
|
|
209
|
+
| ------------------- | --------------------------------- |
|
|
210
|
+
| `CONNECTION_STRING` | Neon PostgreSQL connection string |
|
|
211
|
+
| `JWT_SECRET` | Secret key for JWT tokens |
|
|
212
|
+
| `PORT` | Server port (default: 3000) |
|
|
199
213
|
|
|
200
214
|
---
|
|
201
215
|
|