nestify-js 0.3.4 → 0.3.6

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.
Files changed (2) hide show
  1. package/README.md +18 -14
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # Nestify
2
2
 
3
- [中文版本 README.zh.md](./README.zh.md)
3
+ [![npm version](
4
+ https://img.shields.io/npm/v/nestify-js.svg)](https://www.npmjs.com/package/nestify-js) [![npm downloads](http://img.shields.io/npm/dm/nestify-js.svg)](https://npmcharts.com/compare/nestify-js,token-types?start=1200&interval=30)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/59dd6795e61949fb97066ca52e6097ef)](https://www.codacy.com/app/Borewit/nestify-js?utm_source=github.com&utm_medium=referral&utm_content=Borewit/nestify-js&utm_campaign=Badge_Grade)
6
+
7
+ [中文版本 README.zh.md](../../README.zh.md)
4
8
 
5
9
  > ⚠️ **Warning**: This is not an official release version. APIs may change in the future.
6
10
 
7
- **Injecorator** is a portmanteau of "inject" and "decorator" - a dependency injection framework for Fastify that uses modern Stage 3 decorators instead of the legacy decorators used by NestJS.
11
+ **Nestify** is a NestJS-like dependency injection framework for Fastify that uses modern Stage 3 decorators instead of the legacy decorators used by NestJS.
8
12
 
9
13
  This project was created because NestJS uses the old decorator syntax, but we wanted to leverage the new Stage 3 decorator specification for better type safety and modern JavaScript features.
10
14
 
@@ -187,7 +191,7 @@ Guards control access to routes. Returning `false` or throwing from `canActivate
187
191
 
188
192
  ```typescript
189
193
  @Guard()
190
- class AuthGuard implements InjecoratorGuard {
194
+ class AuthGuard implements NestifyGuard {
191
195
  // Dependency injection works
192
196
  @Inject(AuthService)
193
197
  authService: AuthService;
@@ -235,7 +239,7 @@ Interceptors run before the controller method; the returned function is called a
235
239
 
236
240
  ```typescript
237
241
  @Interceptor()
238
- class LoggingInterceptor implements InjecoratorInterceptor {
242
+ class LoggingInterceptor implements NestifyInterceptor {
239
243
  intercept(context: ExecutionContext) {
240
244
  const start = Date.now();
241
245
  console.log('Request started');
@@ -267,7 +271,7 @@ Pipes validate and transform input data. Each pipe's return value becomes the ne
267
271
 
268
272
  ```typescript
269
273
  @Pipe()
270
- class TrimPipe implements InjecoratorPipe {
274
+ class TrimPipe implements NestifyPipe {
271
275
  async transform(context: ExecutionContext, input: any[], schema?: PipeFullSchema) {
272
276
  // `input` comes from the previous step; the return value goes to the next pipe or the handler
273
277
  return input.map((v) => (typeof v === 'string' ? v.trim() : v));
@@ -338,7 +342,7 @@ Filters handle exceptions thrown by routes. Specify the exception classes to cat
338
342
 
339
343
  ```typescript
340
344
  @Filter(HttpException)
341
- class HttpExceptionFilter implements InjecoratorFilter {
345
+ class HttpExceptionFilter implements NestifyFilter {
342
346
  catch(context: ExecutionContext, exception: HttpException) {
343
347
  const response = context.switchToHttp().getReply();
344
348
  response.status(exception.status).send({
@@ -425,14 +429,14 @@ const app = await nestify(AppModule, {
425
429
 
426
430
  Available options:
427
431
 
428
- | Option | Type | Description |
429
- | --- | --- | --- |
430
- | `logger` | `FastifyServerOptions['logger']` | Shortcut for `fastify.logger` |
431
- | `fastify` | `FastifyServerOptions` | Options passed to the fastify factory (`fastify(options)`) |
432
- | `plugins` | `readonly [plugin, options?][]` | Fastify plugins registered before modules are applied (callback-style and async-style are both accepted) |
433
- | `setup` | `(register: (cls: Constructor) => void) => void` | Setup callback to register auto-created instances (optional; built-in pipes/JwtGuard are auto-registered, usually not needed) |
434
- | `listen` | `boolean \| Partial<FastifyListenOptions>` | Start listening after all modules are registered |
435
- | `allowCrossModuleCircularReference` | `boolean` | Must be `true` to allow **cross-module** circular dependencies (same-module circular references are always allowed). `@default false` |
432
+ | Option | Type | Description |
433
+ | ----------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
434
+ | `logger` | `FastifyServerOptions['logger']` | Shortcut for `fastify.logger` |
435
+ | `fastify` | `FastifyServerOptions` | Options passed to the fastify factory (`fastify(options)`) |
436
+ | `plugins` | `readonly [plugin, options?][]` | Fastify plugins registered before modules are applied (callback-style and async-style are both accepted) |
437
+ | `setup` | `(register: (cls: Constructor) => void) => void` | Setup callback to register auto-created instances (optional; built-in pipes/JwtGuard are auto-registered, usually not needed) |
438
+ | `listen` | `boolean \| Partial<FastifyListenOptions>` | Start listening after all modules are registered |
439
+ | `allowCrossModuleCircularReference` | `boolean` | Must be `true` to allow **cross-module** circular dependencies (same-module circular references are always allowed). `@default false` |
436
440
 
437
441
  #### `apply(app, options)`
438
442
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestify-js",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "A NestJS like fastify plugin for dependency injection",
5
5
  "description_zh": "一个类似于 NestJS 的 Fastify 依赖注入插件",
6
6
  "purpose": "npm",
@@ -41,8 +41,8 @@
41
41
  "@fastify/sensible": "^6.0.4",
42
42
  "@fastify/static": "^9.1.3",
43
43
  "fastify": "^5.0.0",
44
- "@nestify-js/core": "0.3.4",
45
- "@nestify-js/shared": "0.3.4"
44
+ "@nestify-js/core": "0.3.6",
45
+ "@nestify-js/shared": "0.3.6"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@fastify/multipart": "^9.3.0"