|
1 | 1 | /* eslint-disable ts/no-unsafe-function-type */
|
2 | 2 | /**
|
3 | 3 | * Modern Dependency Injection Decorators
|
4 |
| - * |
5 |
| - * Uses standard decorators without reflect-metadata dependency |
6 | 4 | */
|
7 | 5 |
|
8 | 6 | import type { ResolutionContext } from './container'
|
@@ -165,20 +163,20 @@ function createRouteDecorator(method: string, path: string, options?: { middlewa
|
165 | 163 | if (!target.constructor[ROUTE_METADATA_KEY]) {
|
166 | 164 | target.constructor[ROUTE_METADATA_KEY] = []
|
167 | 165 | }
|
168 |
| - |
| 166 | + |
169 | 167 | const metadata: RouteMetadata = {
|
170 | 168 | method,
|
171 | 169 | path,
|
172 | 170 | middleware: options?.middleware || [],
|
173 | 171 | tags: options?.tags || [],
|
174 | 172 | }
|
175 |
| - |
| 173 | + |
176 | 174 | target.constructor[ROUTE_METADATA_KEY].push({
|
177 | 175 | ...metadata,
|
178 | 176 | propertyKey,
|
179 | 177 | handler: descriptor.value,
|
180 | 178 | })
|
181 |
| - |
| 179 | + |
182 | 180 | return descriptor
|
183 | 181 | }
|
184 | 182 | }
|
@@ -238,17 +236,17 @@ function createParamDecorator(
|
238 | 236 | if (!target.constructor[PARAM_METADATA_KEY]) {
|
239 | 237 | target.constructor[PARAM_METADATA_KEY] = new Map()
|
240 | 238 | }
|
241 |
| - |
| 239 | + |
242 | 240 | if (!target.constructor[PARAM_METADATA_KEY].has(propertyKey)) {
|
243 | 241 | target.constructor[PARAM_METADATA_KEY].set(propertyKey, [])
|
244 | 242 | }
|
245 |
| - |
| 243 | + |
246 | 244 | const metadata: ParamMetadata = {
|
247 | 245 | type,
|
248 | 246 | key,
|
249 | 247 | token,
|
250 | 248 | }
|
251 |
| - |
| 249 | + |
252 | 250 | target.constructor[PARAM_METADATA_KEY].get(propertyKey)[parameterIndex] = metadata
|
253 | 251 | }
|
254 | 252 | }
|
@@ -295,7 +293,7 @@ export class MetadataReader {
|
295 | 293 | }
|
296 | 294 |
|
297 | 295 | /**
|
298 |
| - * Modern Decorator Container that works without reflect-metadata |
| 296 | + * Modern Decorator Container |
299 | 297 | */
|
300 | 298 | export class DecoratorContainer extends Container {
|
301 | 299 | /**
|
|
0 commit comments