You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,12 @@
1
1
# Changelog
2
2
3
+
## 1.3.0 (2025-04-12)
4
+
5
+
### Features
6
+
7
+
- Added support for traditional controller imports + explicit HTTP paths
8
+
- Can now call `invoke()` on endpoint instances. Useful for integration testing. [Example](https://github.com/rhyek/nestjs-endpoints/blob/1b1242348ebc77abad5ad0c67ab372690102d736/packages/test/test-app-express-cjs/test/app.e2e-spec.ts#L467).
-**Easy setup:** Automatically scans your project for endpoint files.
37
36
-**Stable:** Produces regular **NestJS Controllers** under the hood.
38
-
-**File-based routing:** Endpoints' HTTP paths are based on their path on disk.
37
+
-**Automatic setup**:
38
+
- Scans your project for endpoint files.
39
+
-**File-based routing:** Endpoints' HTTP paths are based on their path on disk.
40
+
-**Traditional setup**: Explicitly set HTTP paths and import endpoints like regular controlllers.
39
41
-**Schema validation:** Compile and run-time validation of input and output values using Zod schemas.
40
42
-**End-to-end type safety:** Auto-generates `axios` and `@tanstack/react-query` client libraries. Internally uses `@nestjs/swagger`, [nestjs-zod](https://github.com/BenLorantfy/nestjs-zod), and [orval](https://orval.dev/).
41
43
-**HTTP adapter agnostic:** Works with both Express and Fastify NestJS applications.
@@ -66,8 +68,6 @@ import { EndpointsRouterModule } from 'nestjs-endpoints';
66
68
exportclassAppModule {}
67
69
```
68
70
69
-
## Basic Usage
70
-
71
71
`src/endpoints/user/find.endpoint.ts`
72
72
73
73
```typescript
@@ -156,7 +156,7 @@ null%
156
156
{"id":1}%
157
157
```
158
158
159
-
## File-based routing
159
+
###File-based routing
160
160
161
161
HTTP paths for endpoints are derived from the file's path on disk:
162
162
@@ -174,9 +174,36 @@ Examples (assume `rootDirectory` is `./endpoints`):
174
174
175
175
> _**Note:**_ Bundled projects via Webpack or similar are not supported.
176
176
177
+
### Option 2. Traditional imports and paths
178
+
179
+
You can import endpoints like regular NestJS controllers. No need for `EndpointsRouterModule` in this case.
180
+
181
+
`src/app.module.ts`
182
+
183
+
```typescript
184
+
import { Module } from'@nestjs/common';
185
+
import { healthCheck } from'./health-check.ts';
186
+
187
+
@Module({
188
+
controllers: [healthCheck],
189
+
})
190
+
classAppModule {}
191
+
```
192
+
193
+
`src/health-check.ts`
194
+
195
+
```typescript
196
+
import { endpoint, z } from'nestjs-endpoints';
197
+
198
+
exportconst healthCheck =endpoint({
199
+
path: '/status/health',
200
+
handler: () =>'ok',
201
+
});
202
+
```
203
+
177
204
## Codegen (optional)
178
205
179
-
You can automatically generate a client SDK for your API that can be used in other backend or frontend projects with the benefit of end-to-end type safety. It uses [orval](https://orval.dev/) internally.
206
+
You can automatically generate a client SDK for your API that can be used in other backend or frontend projects with the benefit of end-to-end type safety. It uses [orval](https://orval.dev/) internally. It works with both scanned and manually imported endpoints.
0 commit comments