@goodie-ts/decorators 0.1.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.
Files changed (2) hide show
  1. package/README.md +46 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @goodie-ts/decorators
2
+
3
+ Stage 3 decorators for [goodie-ts](https://github.com/GOOD-Code-ApS/goodie) compile-time dependency injection.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @goodie-ts/decorators
9
+ ```
10
+
11
+ ## Overview
12
+
13
+ Provides the decorators you use to annotate your classes. These attach metadata via `Symbol.metadata` which the transformer reads at build time — they do **not** wire anything at runtime. No `reflect-metadata` required.
14
+
15
+ ## Decorators
16
+
17
+ | Decorator | Target | Description |
18
+ |-----------|--------|-------------|
19
+ | `@Singleton()` | class | Singleton-scoped bean |
20
+ | `@Injectable()` | class | Prototype-scoped bean (new instance per lookup) |
21
+ | `@Named(name)` | class | Qualifier for disambiguation |
22
+ | `@Eager()` | class | Instantiate at startup instead of on first access |
23
+ | `@Module({ imports? })` | class | Groups `@Provides` factory methods |
24
+ | `@Provides()` | method | Marks a method in a `@Module` as a bean factory |
25
+ | `@Inject(qualifier?)` | accessor field | Field injection |
26
+ | `@Optional()` | accessor field | Marks a field as optional (resolves to `undefined` if missing) |
27
+
28
+ ## Usage
29
+
30
+ ```typescript
31
+ import { Singleton, Inject, Optional } from '@goodie-ts/decorators';
32
+
33
+ @Singleton()
34
+ class UserService {
35
+ @Inject() accessor userRepo!: UserRepository;
36
+ @Optional() accessor logger?: Logger;
37
+
38
+ getUsers() { return this.userRepo.findAll(); }
39
+ }
40
+ ```
41
+
42
+ > **Note:** `@Inject` and `@Optional` require the `accessor` keyword — Stage 3 decorators do not support parameter decorators.
43
+
44
+ ## License
45
+
46
+ [MIT](https://github.com/GOOD-Code-ApS/goodie/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodie-ts/decorators",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Stage 3 decorators for goodie-ts compile-time dependency injection",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@goodie-ts/core": "0.1.0"
24
+ "@goodie-ts/core": "0.1.1"
25
25
  },
26
26
  "files": [
27
27
  "dist"