@lerianstudio/sindarian-server 1.0.0 → 1.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 +268 -21
- package/dist/constants/keys.d.ts +2 -0
- package/dist/constants/keys.d.ts.map +1 -1
- package/dist/constants/keys.js +3 -1
- package/dist/constants/keys.js.map +1 -1
- package/dist/controllers/decorators/route-decorator.d.ts +4 -0
- package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
- package/dist/controllers/decorators/route-decorator.js +7 -0
- package/dist/controllers/decorators/route-decorator.js.map +1 -1
- package/dist/dependency-injection/container.d.ts +4 -3
- package/dist/dependency-injection/container.d.ts.map +1 -1
- package/dist/dependency-injection/container.js +14 -3
- package/dist/dependency-injection/container.js.map +1 -1
- package/dist/dependency-injection/injectable-decorator.d.ts +5 -0
- package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -1
- package/dist/dependency-injection/injectable-decorator.js +9 -0
- package/dist/dependency-injection/injectable-decorator.js.map +1 -1
- package/dist/guards/can-activate.d.ts +21 -0
- package/dist/guards/can-activate.d.ts.map +1 -0
- package/dist/guards/can-activate.js +3 -0
- package/dist/guards/can-activate.js.map +1 -0
- package/dist/guards/decorators/index.d.ts +2 -0
- package/dist/guards/decorators/index.d.ts.map +1 -0
- package/dist/guards/decorators/index.js +18 -0
- package/dist/guards/decorators/index.js.map +1 -0
- package/dist/guards/decorators/use-guards-decorator.d.ts +44 -0
- package/dist/guards/decorators/use-guards-decorator.d.ts.map +1 -0
- package/dist/guards/decorators/use-guards-decorator.js +127 -0
- package/dist/guards/decorators/use-guards-decorator.js.map +1 -0
- package/dist/guards/index.d.ts +3 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +19 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -1
- package/dist/interceptor/decorators/use-interceptor-decorator.js +4 -12
- package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -1
- package/dist/logger/console-logger.d.ts.map +1 -1
- package/dist/logger/console-logger.js +6 -0
- package/dist/logger/console-logger.js.map +1 -1
- package/dist/middleware/index.d.ts +3 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +19 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/middleware-handler.d.ts +6 -0
- package/dist/middleware/middleware-handler.d.ts.map +1 -0
- package/dist/middleware/middleware-handler.js +19 -0
- package/dist/middleware/middleware-handler.js.map +1 -0
- package/dist/middleware/middleware.d.ts +6 -0
- package/dist/middleware/middleware.d.ts.map +1 -0
- package/dist/middleware/middleware.js +7 -0
- package/dist/middleware/middleware.js.map +1 -0
- package/dist/modules/module-decorator.d.ts.map +1 -1
- package/dist/modules/module-decorator.js +27 -1
- package/dist/modules/module-decorator.js.map +1 -1
- package/dist/pipes/decorators/use-pipes.js +1 -1
- package/dist/pipes/decorators/use-pipes.js.map +1 -1
- package/dist/server/server-factory.d.ts +38 -1
- package/dist/server/server-factory.d.ts.map +1 -1
- package/dist/server/server-factory.js +129 -14
- package/dist/server/server-factory.js.map +1 -1
- package/dist/services/guards.d.ts +2 -0
- package/dist/services/guards.d.ts.map +1 -0
- package/dist/services/guards.js +5 -0
- package/dist/services/guards.js.map +1 -0
- package/dist/services/middleware.d.ts +2 -0
- package/dist/services/middleware.d.ts.map +1 -0
- package/dist/services/middleware.js +5 -0
- package/dist/services/middleware.js.map +1 -0
- package/dist/utils/routes/route-specificity.d.ts +40 -0
- package/dist/utils/routes/route-specificity.d.ts.map +1 -0
- package/dist/utils/routes/route-specificity.js +89 -0
- package/dist/utils/routes/route-specificity.js.map +1 -0
- package/dist/utils/url/url-match.d.ts.map +1 -1
- package/dist/utils/url/url-match.js +16 -2
- package/dist/utils/url/url-match.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -4,15 +4,16 @@ A lightweight, NestJS-inspired framework designed specifically for Next.js appli
|
|
|
4
4
|
|
|
5
5
|
## ( Features
|
|
6
6
|
|
|
7
|
-
- =� **NestJS-like API** - Familiar decorators and patterns
|
|
8
|
-
- � **Next.js Optimized** - Built for serverless environments
|
|
9
|
-
- =� **Dependency Injection** - Powered by Inversify
|
|
10
|
-
- =� **Decorator-based Routing** - Clean, declarative route definitions
|
|
11
|
-
- =' **Middleware Support** -
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- =� **NestJS-like API** - Familiar decorators and patterns
|
|
8
|
+
- � **Next.js Optimized** - Built for serverless environments
|
|
9
|
+
- =� **Dependency Injection** - Powered by Inversify
|
|
10
|
+
- =� **Decorator-based Routing** - Clean, declarative route definitions
|
|
11
|
+
- =' **Middleware Support** - Guards, interceptors, pipes, and exception filters
|
|
12
|
+
- ✅ **Zod Validation** - Built-in schema validation with Zod
|
|
13
|
+
- =� **TypeScript First** - Full type safety out of the box
|
|
14
|
+
- <� **Lightweight** - Minimal overhead for fast cold starts
|
|
14
15
|
|
|
15
|
-
## =� Quick Start
|
|
16
|
+
## =� Quick Start
|
|
16
17
|
|
|
17
18
|
### Installation
|
|
18
19
|
|
|
@@ -119,7 +120,7 @@ export async function PATCH(request: NextRequest, context: any) {
|
|
|
119
120
|
}
|
|
120
121
|
```
|
|
121
122
|
|
|
122
|
-
## =� Core Concepts
|
|
123
|
+
## =� Core Concepts
|
|
123
124
|
|
|
124
125
|
### Controllers
|
|
125
126
|
|
|
@@ -212,24 +213,41 @@ Create custom exception filters:
|
|
|
212
213
|
export class ValidationFilter implements ExceptionFilter {
|
|
213
214
|
async catch(exception: ValidationError, host: ArgumentsHost) {
|
|
214
215
|
return NextResponse.json(
|
|
215
|
-
{
|
|
216
|
+
{
|
|
216
217
|
message: 'Validation failed',
|
|
217
|
-
errors: exception.errors
|
|
218
|
+
errors: exception.errors
|
|
218
219
|
},
|
|
219
220
|
{ status: 400 }
|
|
220
221
|
)
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
// Apply globally
|
|
225
|
+
// Apply globally via app
|
|
225
226
|
app.useGlobalFilters(new ValidationFilter())
|
|
226
227
|
|
|
228
|
+
// Or register via module providers (supports multiple filters)
|
|
229
|
+
@Module({
|
|
230
|
+
providers: [
|
|
231
|
+
{
|
|
232
|
+
provide: APP_FILTER,
|
|
233
|
+
useClass: ValidationFilter
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
provide: APP_FILTER,
|
|
237
|
+
useClass: DatabaseErrorFilter
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
})
|
|
241
|
+
export class AppModule {}
|
|
242
|
+
|
|
227
243
|
// Or on specific controllers
|
|
228
244
|
@Controller('/users')
|
|
229
245
|
@UseFilters(ValidationFilter)
|
|
230
246
|
export class UserController extends BaseController {}
|
|
231
247
|
```
|
|
232
248
|
|
|
249
|
+
**Note**: When registering multiple filters via `APP_FILTER`, they execute in reverse order (last registered runs first), allowing more specific filters to handle exceptions before general ones.
|
|
250
|
+
|
|
233
251
|
### Interceptors
|
|
234
252
|
|
|
235
253
|
Add cross-cutting concerns with interceptors:
|
|
@@ -240,22 +258,251 @@ export class LoggingInterceptor implements Interceptor {
|
|
|
240
258
|
const start = Date.now()
|
|
241
259
|
const result = await next.handle()
|
|
242
260
|
const duration = Date.now() - start
|
|
243
|
-
|
|
261
|
+
|
|
244
262
|
console.log(`${context.getClass().name}.${context.getHandler().name} - ${duration}ms`)
|
|
245
263
|
return result
|
|
246
264
|
}
|
|
247
265
|
}
|
|
248
266
|
|
|
249
|
-
// Apply globally
|
|
267
|
+
// Apply globally via app
|
|
250
268
|
app.useGlobalInterceptors(new LoggingInterceptor())
|
|
251
269
|
|
|
270
|
+
// Or register via module providers (supports multiple interceptors)
|
|
271
|
+
@Module({
|
|
272
|
+
providers: [
|
|
273
|
+
{
|
|
274
|
+
provide: APP_INTERCEPTOR,
|
|
275
|
+
useClass: LoggingInterceptor
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
provide: APP_INTERCEPTOR,
|
|
279
|
+
useClass: TransformInterceptor
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
})
|
|
283
|
+
export class AppModule {}
|
|
284
|
+
|
|
252
285
|
// Or on specific controllers
|
|
253
286
|
@Controller('/users')
|
|
254
287
|
@UseInterceptors(LoggingInterceptor)
|
|
255
288
|
export class UserController extends BaseController {}
|
|
256
289
|
```
|
|
257
290
|
|
|
258
|
-
|
|
291
|
+
**Note**: Multiple `APP_INTERCEPTOR` and `APP_PIPE` providers are supported and execute in reverse registration order (last registered runs first).
|
|
292
|
+
|
|
293
|
+
### Guards
|
|
294
|
+
|
|
295
|
+
Guards determine whether a request should be handled by the route handler. They're commonly used for authentication and authorization:
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import { CanActivate, ExecutionContext, UseGuards } from '@lerianstudio/sindarian-server'
|
|
299
|
+
import { injectable } from 'inversify'
|
|
300
|
+
|
|
301
|
+
@injectable()
|
|
302
|
+
export class AuthGuard implements CanActivate {
|
|
303
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
304
|
+
const request = context.switchToHttp().getRequest()
|
|
305
|
+
const token = request.headers.get('authorization')
|
|
306
|
+
|
|
307
|
+
if (!token) {
|
|
308
|
+
return false // Will throw ForbiddenApiException
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Validate token...
|
|
312
|
+
return true
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Apply to controller
|
|
317
|
+
@Controller('/admin')
|
|
318
|
+
@UseGuards(AuthGuard)
|
|
319
|
+
export class AdminController extends BaseController {
|
|
320
|
+
@Get()
|
|
321
|
+
async dashboard() {
|
|
322
|
+
return { message: 'Welcome to admin' }
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Or apply to specific methods
|
|
327
|
+
@Controller('/users')
|
|
328
|
+
export class UserController extends BaseController {
|
|
329
|
+
@Get()
|
|
330
|
+
async findAll() {
|
|
331
|
+
return { users: [] } // Public route
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
@Delete(':id')
|
|
335
|
+
@UseGuards(AuthGuard)
|
|
336
|
+
async remove(@Param('id') id: string) {
|
|
337
|
+
return { deleted: id } // Protected route
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Register global guards via module providers:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
@Module({
|
|
346
|
+
providers: [
|
|
347
|
+
{
|
|
348
|
+
provide: APP_GUARD,
|
|
349
|
+
useClass: AuthGuard
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
})
|
|
353
|
+
export class AppModule {}
|
|
354
|
+
|
|
355
|
+
// Or globally via app
|
|
356
|
+
app.useGlobalGuards(new AuthGuard())
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Note**: Guards execute before interceptors and pipes. If a guard returns `false`, a `ForbiddenApiException` is thrown.
|
|
360
|
+
|
|
361
|
+
### Pipes
|
|
362
|
+
|
|
363
|
+
Transform and validate input data with pipes:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { PipeTransform, ArgumentMetadata, UsePipes } from '@lerianstudio/sindarian-server'
|
|
367
|
+
|
|
368
|
+
@injectable()
|
|
369
|
+
export class ParseIntPipe implements PipeTransform {
|
|
370
|
+
transform(value: any, metadata: ArgumentMetadata): number {
|
|
371
|
+
const val = parseInt(value, 10)
|
|
372
|
+
if (isNaN(val)) {
|
|
373
|
+
throw new Error('Validation failed: not a number')
|
|
374
|
+
}
|
|
375
|
+
return val
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Apply to controller or method
|
|
380
|
+
@Controller('/items')
|
|
381
|
+
@UsePipes(ParseIntPipe)
|
|
382
|
+
export class ItemController extends BaseController {
|
|
383
|
+
@Get(':id')
|
|
384
|
+
async findOne(@Param('id') id: number) {
|
|
385
|
+
return this.itemService.findById(id)
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Register global pipes via module providers:
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
@Module({
|
|
394
|
+
providers: [
|
|
395
|
+
{
|
|
396
|
+
provide: APP_PIPE,
|
|
397
|
+
useClass: ValidationPipe
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
})
|
|
401
|
+
export class AppModule {}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Validation with Zod
|
|
405
|
+
|
|
406
|
+
Built-in Zod integration for schema validation:
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
import { createZodDto, ZodValidationPipe, UsePipes } from '@lerianstudio/sindarian-server'
|
|
410
|
+
import { z } from 'zod'
|
|
411
|
+
|
|
412
|
+
// Define your schema
|
|
413
|
+
const CreateUserSchema = z.object({
|
|
414
|
+
name: z.string().min(2),
|
|
415
|
+
email: z.string().email(),
|
|
416
|
+
age: z.number().min(18).optional()
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
// Create a DTO class from the schema
|
|
420
|
+
const CreateUserDto = createZodDto(CreateUserSchema)
|
|
421
|
+
|
|
422
|
+
// Use in your controller with the validation pipe
|
|
423
|
+
@Controller('/users')
|
|
424
|
+
@UsePipes(ZodValidationPipe)
|
|
425
|
+
export class UserController extends BaseController {
|
|
426
|
+
@Post()
|
|
427
|
+
async create(@Body() userData: typeof CreateUserDto) {
|
|
428
|
+
// userData is validated and typed
|
|
429
|
+
return this.userService.create(userData)
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
The `ZodValidationPipe` automatically validates incoming data against Zod schemas and throws a `ValidationApiException` on validation errors.
|
|
435
|
+
|
|
436
|
+
### Logger Service
|
|
437
|
+
|
|
438
|
+
Use the built-in logger for consistent application logging:
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
import { ConsoleLogger, LoggerService } from '@lerianstudio/sindarian-server'
|
|
442
|
+
|
|
443
|
+
// Use the default ConsoleLogger
|
|
444
|
+
const logger = new ConsoleLogger({ prefix: 'MyApp' })
|
|
445
|
+
logger.log('Application started')
|
|
446
|
+
logger.error('Something went wrong')
|
|
447
|
+
logger.warn('This is a warning')
|
|
448
|
+
logger.debug('Debug information')
|
|
449
|
+
|
|
450
|
+
// Or inject as a service
|
|
451
|
+
@injectable()
|
|
452
|
+
export class MyService {
|
|
453
|
+
constructor(private logger: ConsoleLogger) {}
|
|
454
|
+
|
|
455
|
+
doSomething() {
|
|
456
|
+
this.logger.log('Doing something...')
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Available log levels: `verbose`, `debug`, `log`, `warn`, `error`, `fatal`
|
|
462
|
+
|
|
463
|
+
### HttpService
|
|
464
|
+
|
|
465
|
+
Abstract base class for building API client services with built-in error handling:
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
import { HttpService, FetchModuleOptions } from '@lerianstudio/sindarian-server'
|
|
469
|
+
import { injectable } from 'inversify'
|
|
470
|
+
|
|
471
|
+
@injectable()
|
|
472
|
+
export class MyApiService extends HttpService {
|
|
473
|
+
protected async createDefaults(): Promise<FetchModuleOptions> {
|
|
474
|
+
return {
|
|
475
|
+
baseUrl: 'https://api.example.com',
|
|
476
|
+
headers: {
|
|
477
|
+
'Content-Type': 'application/json',
|
|
478
|
+
'Authorization': `Bearer ${this.getToken()}`
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async getUsers() {
|
|
484
|
+
return this.get<User[]>('/users')
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
async createUser(data: CreateUserDto) {
|
|
488
|
+
return this.post<User>('/users', {
|
|
489
|
+
body: JSON.stringify(data)
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async uploadFile(data: { file: File; name: string }) {
|
|
494
|
+
return this.postFormData<UploadResponse>('/upload', data)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
The `HttpService` provides:
|
|
500
|
+
- HTTP methods: `get`, `post`, `put`, `patch`, `delete`, `head`
|
|
501
|
+
- FormData support: `postFormData`, `patchFormData`
|
|
502
|
+
- Automatic error handling with typed exceptions
|
|
503
|
+
- Lifecycle hooks: `onBeforeFetch`, `onAfterFetch`, `catch`
|
|
504
|
+
|
|
505
|
+
## <� Parameter Decorators
|
|
259
506
|
|
|
260
507
|
Extract data from requests with decorators:
|
|
261
508
|
|
|
@@ -333,7 +580,7 @@ export class AuthService {
|
|
|
333
580
|
}
|
|
334
581
|
```
|
|
335
582
|
|
|
336
|
-
## =� Documentation
|
|
583
|
+
## =� Documentation
|
|
337
584
|
|
|
338
585
|
- **[Technical Guide](./TECHNICAL.md)** - Deep dive into the framework's architecture and implementation details
|
|
339
586
|
- **[API Reference](./docs/api.md)** - Complete API documentation
|
|
@@ -343,7 +590,7 @@ export class AuthService {
|
|
|
343
590
|
|
|
344
591
|
Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
345
592
|
|
|
346
|
-
## =� License
|
|
593
|
+
## =� License
|
|
347
594
|
|
|
348
595
|
This project is licensed under the ISC License - see the [LICENSE](./LICENSE) file for details.
|
|
349
596
|
|
|
@@ -353,10 +600,10 @@ This project is licensed under the ISC License - see the [LICENSE](./LICENSE) fi
|
|
|
353
600
|
- Built on [Inversify](https://inversify.io/) - A powerful IoC container for TypeScript
|
|
354
601
|
- Designed for [Next.js](https://nextjs.org/) - The React framework for production
|
|
355
602
|
|
|
356
|
-
## =� What's Next?
|
|
603
|
+
## =� What's Next?
|
|
357
604
|
|
|
358
|
-
- [
|
|
359
|
-
- [
|
|
605
|
+
- [x] Validation pipes with Zod integration
|
|
606
|
+
- [x] Guards system for authentication/authorization
|
|
360
607
|
- [ ] WebSocket support
|
|
361
608
|
- [ ] GraphQL integration
|
|
362
609
|
- [ ] CLI tools for scaffolding
|
|
@@ -364,4 +611,4 @@ This project is licensed under the ISC License - see the [LICENSE](./LICENSE) fi
|
|
|
364
611
|
|
|
365
612
|
---
|
|
366
613
|
|
|
367
|
-
**Sindarian Server** - Building the future of Next.js APIs, one decorator at a time. =�
|
|
614
|
+
**Sindarian Server** - Building the future of Next.js APIs, one decorator at a time. =�
|
package/dist/constants/keys.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export declare const INJECTABLE_KEY: unique symbol;
|
|
2
|
+
export declare const CLASS_NAME_KEY: unique symbol;
|
|
2
3
|
export declare const MODULE_KEY: unique symbol;
|
|
3
4
|
export declare const CONTROLLER_KEY: unique symbol;
|
|
4
5
|
export declare const CATCH_KEY: unique symbol;
|
|
5
6
|
export declare const FILTER_KEY: unique symbol;
|
|
6
7
|
export declare const INTERCEPTOR_KEY: unique symbol;
|
|
7
8
|
export declare const PIPE_KEY: unique symbol;
|
|
9
|
+
export declare const GUARD_KEY: unique symbol;
|
|
8
10
|
export declare const ROUTE_KEY: unique symbol;
|
|
9
11
|
export declare const GET_KEY: unique symbol;
|
|
10
12
|
export declare const POST_KEY: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAuB,CAAA;AAElD,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,cAAc,eAAuB,CAAA;AAClD,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,eAAe,eAAwB,CAAA;AACpD,eAAO,MAAM,QAAQ,eAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAuB,CAAA;AAClD,eAAO,MAAM,cAAc,eAAuB,CAAA;AAElD,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,cAAc,eAAuB,CAAA;AAClD,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,eAAe,eAAwB,CAAA;AACpD,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,SAAS,eAAkB,CAAA;AAExC,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,UAAU,eAAmB,CAAA;AAE1C,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,WAAW,eAAoB,CAAA;AAC5C,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,SAAS,eAAkB,CAAA;AAExC,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAC7C,eAAO,MAAM,eAAe,eAAe,CAAA;AAC3C,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,oBAAoB,oBAAoB,CAAA"}
|
package/dist/constants/keys.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTROLLERS_PROPERTY = exports.PROVIDERS_PROPERTY = exports.MODULE_PROPERTY = exports.IMPORTS_PROPERTY = exports.QUERY_KEY = exports.PARAM_KEY = exports.REQUEST_KEY = exports.BODY_KEY = exports.DELETE_KEY = exports.PATCH_KEY = exports.PUT_KEY = exports.POST_KEY = exports.GET_KEY = exports.ROUTE_KEY = exports.PIPE_KEY = exports.INTERCEPTOR_KEY = exports.FILTER_KEY = exports.CATCH_KEY = exports.CONTROLLER_KEY = exports.MODULE_KEY = exports.INJECTABLE_KEY = void 0;
|
|
3
|
+
exports.CONTROLLERS_PROPERTY = exports.PROVIDERS_PROPERTY = exports.MODULE_PROPERTY = exports.IMPORTS_PROPERTY = exports.QUERY_KEY = exports.PARAM_KEY = exports.REQUEST_KEY = exports.BODY_KEY = exports.DELETE_KEY = exports.PATCH_KEY = exports.PUT_KEY = exports.POST_KEY = exports.GET_KEY = exports.ROUTE_KEY = exports.GUARD_KEY = exports.PIPE_KEY = exports.INTERCEPTOR_KEY = exports.FILTER_KEY = exports.CATCH_KEY = exports.CONTROLLER_KEY = exports.MODULE_KEY = exports.CLASS_NAME_KEY = exports.INJECTABLE_KEY = void 0;
|
|
4
4
|
exports.INJECTABLE_KEY = Symbol('injectable');
|
|
5
|
+
exports.CLASS_NAME_KEY = Symbol('class_name');
|
|
5
6
|
exports.MODULE_KEY = Symbol('module');
|
|
6
7
|
exports.CONTROLLER_KEY = Symbol('controller');
|
|
7
8
|
exports.CATCH_KEY = Symbol('catch');
|
|
8
9
|
exports.FILTER_KEY = Symbol('filter');
|
|
9
10
|
exports.INTERCEPTOR_KEY = Symbol('interceptor');
|
|
10
11
|
exports.PIPE_KEY = Symbol('pipe');
|
|
12
|
+
exports.GUARD_KEY = Symbol('guard');
|
|
11
13
|
exports.ROUTE_KEY = Symbol('route');
|
|
12
14
|
exports.GET_KEY = Symbol('get');
|
|
13
15
|
exports.POST_KEY = Symbol('post');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AAErC,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAA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M,CAAC,CAAA;AACzB,QAAA,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAC/B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAE3B,QAAA,gBAAgB,GAAG,aAAa,CAAA;AAChC,QAAA,eAAe,GAAG,YAAY,CAAA;AAC9B,QAAA,kBAAkB,GAAG,eAAe,CAAA;AACpC,QAAA,oBAAoB,GAAG,iBAAiB,CAAA"}
|
|
@@ -47,6 +47,10 @@ export declare function Patch(path?: string): MethodDecorator;
|
|
|
47
47
|
/**
|
|
48
48
|
* Decorator to define a DELETE route.
|
|
49
49
|
*
|
|
50
|
+
* When the decorated method returns `null` or `undefined`, the response will
|
|
51
|
+
* automatically be HTTP 204 No Content (with no body). If the method returns
|
|
52
|
+
* a non-null value, it will be serialized as JSON with status 200.
|
|
53
|
+
*
|
|
50
54
|
* @param path - The path of the route.
|
|
51
55
|
* @returns A decorator function that can be used to decorate a controller method.
|
|
52
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAMtD,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,GAAG,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5C,SAAS,EAAE,GAAG,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB,CAAA;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa;WAIH,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,GAAG,EAAE,GAClB,OAAO,CAAC,YAAY,EAAE,CAAC;CAa3B;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"route-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAMtD,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,GAAG,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5C,SAAS,EAAE,GAAG,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB,CAAA;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa;WAIH,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,GAAG,EAAE,GAClB,OAAO,CAAC,YAAY,EAAE,CAAC;CAa3B;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAoCxE;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAW,mBAErC;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,MAAW,mBAEtC;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAW,mBAEvC"}
|
|
@@ -47,6 +47,9 @@ function Route(method, path) {
|
|
|
47
47
|
if (response instanceof server_1.NextResponse) {
|
|
48
48
|
return response;
|
|
49
49
|
}
|
|
50
|
+
if (response == null) {
|
|
51
|
+
return new server_1.NextResponse(null, { status: 204 });
|
|
52
|
+
}
|
|
50
53
|
return server_1.NextResponse.json(response);
|
|
51
54
|
};
|
|
52
55
|
};
|
|
@@ -90,6 +93,10 @@ function Patch(path = '') {
|
|
|
90
93
|
/**
|
|
91
94
|
* Decorator to define a DELETE route.
|
|
92
95
|
*
|
|
96
|
+
* When the decorated method returns `null` or `undefined`, the response will
|
|
97
|
+
* automatically be HTTP 204 No Content (with no body). If the method returns
|
|
98
|
+
* a non-null value, it will be serialized as JSON with status 200.
|
|
99
|
+
*
|
|
93
100
|
* @param path - The path of the route.
|
|
94
101
|
* @returns A decorator function that can be used to decorate a controller method.
|
|
95
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":";;;AAiDA,
|
|
1
|
+
{"version":3,"file":"route-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":";;;AAiDA,sBAoCC;AAQD,kBAEC;AAQD,oBAEC;AAQD,kBAEC;AAQD,sBAEC;AAYD,wBAEC;AA3ID,wCAA0C;AAC1C,2CAA4C;AAC5C,2DAAsD;AACtD,2DAAoD;AACpD,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, Container as InversifyContainer, ServiceIdentifier } from 'inversify';
|
|
1
|
+
import { BindToFluentSyntax, GetAllOptions, GetOptions, Container as InversifyContainer, OptionalGetOptions, ServiceIdentifier } from 'inversify';
|
|
2
2
|
/**
|
|
3
3
|
* A Wrapper class for the Inversify Container.
|
|
4
4
|
* Allows the container into a N depth hierarchy module system.
|
|
@@ -15,8 +15,9 @@ export declare class Container {
|
|
|
15
15
|
*/
|
|
16
16
|
load(module: ContainerModule): void;
|
|
17
17
|
bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindToFluentSyntax<T>;
|
|
18
|
-
get<T>(serviceIdentifier: ServiceIdentifier<T
|
|
19
|
-
getAsync<T>(serviceIdentifier: ServiceIdentifier<T
|
|
18
|
+
get<T>(serviceIdentifier: ServiceIdentifier<T>, options?: OptionalGetOptions): T;
|
|
19
|
+
getAsync<T>(serviceIdentifier: ServiceIdentifier<T>, options?: GetOptions): Promise<T>;
|
|
20
|
+
getAllAsync<T>(serviceIdentifier: ServiceIdentifier<T>, options?: GetAllOptions): Promise<T[]>;
|
|
20
21
|
isBound<T>(serviceIdentifier: ServiceIdentifier<T>): boolean;
|
|
21
22
|
unbind<T>(serviceIdentifier: ServiceIdentifier<T>): void;
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,IAAI,kBAAkB,EAC/B,iBAAiB,EAClB,MAAM,WAAW,CAAA;AAElB;;;GAGG;AACH,qBAAa,SAAS;IACb,SAAS,EAAE,kBAAkB,CAAA;IACpC,OAAO,CAAC,aAAa,CAAkC;;
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,SAAS,IAAI,kBAAkB,EAC/B,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,WAAW,CAAA;AAElB;;;GAGG;AACH,qBAAa,SAAS;IACb,SAAS,EAAE,kBAAkB,CAAA;IACpC,OAAO,CAAC,aAAa,CAAkC;;IAQvD;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe;IAgB5B,IAAI,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC;IAIvE,GAAG,CAAC,CAAC,EACH,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC;IAOJ,QAAQ,CAAC,CAAC,EACR,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,CAAC,CAAC;IAOb,WAAW,CAAC,CAAC,EACX,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,CAAC,EAAE,CAAC;IAIf,OAAO,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO;IAI5D,MAAM,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI;CAGzD;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAA;AAEpE;;;;GAIG;AACH,qBAAa,eAAe;IACnB,QAAQ,EAAE,uBAAuB,CAAA;gBAE5B,QAAQ,EAAE,uBAAuB;CAG9C"}
|
|
@@ -9,7 +9,9 @@ const inversify_1 = require("inversify");
|
|
|
9
9
|
class Container {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.loadedModules = new Set();
|
|
12
|
-
this.container = new inversify_1.Container(
|
|
12
|
+
this.container = new inversify_1.Container({
|
|
13
|
+
defaultScope: 'Singleton'
|
|
14
|
+
});
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Loads a module into the container.
|
|
@@ -31,12 +33,21 @@ class Container {
|
|
|
31
33
|
bind(serviceIdentifier) {
|
|
32
34
|
return this.container.bind(serviceIdentifier);
|
|
33
35
|
}
|
|
34
|
-
get(serviceIdentifier) {
|
|
36
|
+
get(serviceIdentifier, options) {
|
|
37
|
+
if (options !== undefined) {
|
|
38
|
+
return this.container.get(serviceIdentifier, options);
|
|
39
|
+
}
|
|
35
40
|
return this.container.get(serviceIdentifier);
|
|
36
41
|
}
|
|
37
|
-
getAsync(serviceIdentifier) {
|
|
42
|
+
getAsync(serviceIdentifier, options) {
|
|
43
|
+
if (options !== undefined) {
|
|
44
|
+
return this.container.getAsync(serviceIdentifier, options);
|
|
45
|
+
}
|
|
38
46
|
return this.container.getAsync(serviceIdentifier);
|
|
39
47
|
}
|
|
48
|
+
getAllAsync(serviceIdentifier, options) {
|
|
49
|
+
return this.container.getAllAsync(serviceIdentifier, options);
|
|
50
|
+
}
|
|
40
51
|
isBound(serviceIdentifier) {
|
|
41
52
|
return this.container.isBound(serviceIdentifier);
|
|
42
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":";;;AAAA,yCAOkB;AAElB;;;GAGG;AACH,MAAa,SAAS;IAIpB;QAFQ,kBAAa,GAAyB,IAAI,GAAG,EAAE,CAAA;QAGrD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAkB,CAAC;YACtC,YAAY,EAAE,WAAW;SAC1B,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAuB;QAC1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,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/C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAC1C,CAAC;CACF;AAtED,8BAsEC;AAID;;;;GAIG;AACH,MAAa,eAAe;IAG1B,YAAY,QAAiC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAND,0CAMC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Scope } from '../constants/scopes';
|
|
2
2
|
export declare function injectableHandler(target: Function): any;
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the original class name stored at decorator-evaluation time.
|
|
5
|
+
* Falls back to constructor.name if no metadata is found (e.g. non-decorated classes).
|
|
6
|
+
*/
|
|
7
|
+
export declare function getClassName(target: Function): string;
|
|
3
8
|
export type InjectableOptions = {
|
|
4
9
|
scope?: Scope;
|
|
5
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectable-decorator.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,OAEjD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"injectable-decorator.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,OAEjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAIrD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAY1E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.injectableHandler = injectableHandler;
|
|
4
|
+
exports.getClassName = getClassName;
|
|
4
5
|
exports.Injectable = Injectable;
|
|
5
6
|
const inversify_1 = require("inversify");
|
|
6
7
|
const keys_1 = require("../constants/keys");
|
|
@@ -8,10 +9,18 @@ const scopes_1 = require("../constants/scopes");
|
|
|
8
9
|
function injectableHandler(target) {
|
|
9
10
|
return Reflect.getOwnMetadata(keys_1.INJECTABLE_KEY, target);
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the original class name stored at decorator-evaluation time.
|
|
14
|
+
* Falls back to constructor.name if no metadata is found (e.g. non-decorated classes).
|
|
15
|
+
*/
|
|
16
|
+
function getClassName(target) {
|
|
17
|
+
return (Reflect.getOwnMetadata(keys_1.CLASS_NAME_KEY, target) ?? target.name ?? 'Unknown');
|
|
18
|
+
}
|
|
11
19
|
function Injectable(options = {}) {
|
|
12
20
|
const { scope = scopes_1.Scope.DEFAULT } = options;
|
|
13
21
|
return (target) => {
|
|
14
22
|
Reflect.defineMetadata(keys_1.INJECTABLE_KEY, { scope }, target);
|
|
23
|
+
Reflect.defineMetadata(keys_1.CLASS_NAME_KEY, target.name, target);
|
|
15
24
|
if (options?.scope) {
|
|
16
25
|
console.warn('Injectable: Scope option is not implemented.');
|
|
17
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectable-decorator.js","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":";;AAIA,8CAEC;AAMD,
|
|
1
|
+
{"version":3,"file":"injectable-decorator.js","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":";;AAIA,8CAEC;AAMD,oCAIC;AAMD,gCAYC;AAlCD,yCAAsC;AACtC,2CAAiE;AACjE,+CAA0C;AAE1C,SAAgB,iBAAiB,CAAC,MAAgB;IAChD,OAAO,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,CAAA;AACvD,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,MAAgB;IAC3C,OAAO,CACL,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,SAAS,CAC3E,CAAA;AACH,CAAC;AAMD,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,EAAE,KAAK,GAAG,cAAK,CAAC,OAAO,EAAE,GAAG,OAAO,CAAA;IACzC,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,CAAA;QACzD,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAE3D,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;QAC9D,CAAC;QAED,IAAA,sBAAU,GAAE,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExecutionContext } from '../context/execution-context';
|
|
2
|
+
/**
|
|
3
|
+
* Interface defining the `canActivate()` function that must be implemented
|
|
4
|
+
* by a guard. Return value indicates whether or not the current request is
|
|
5
|
+
* allowed to proceed.
|
|
6
|
+
*
|
|
7
|
+
* @see [Guards](https://docs.nestjs.com/guards)
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export interface CanActivate {
|
|
12
|
+
/**
|
|
13
|
+
* @param context Current execution context. Provides access to details about
|
|
14
|
+
* the current request pipeline.
|
|
15
|
+
*
|
|
16
|
+
* @returns Value indicating whether or not the current request is allowed to
|
|
17
|
+
* proceed. Can be a boolean or a Promise that resolves to a boolean.
|
|
18
|
+
*/
|
|
19
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=can-activate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can-activate.d.ts","sourceRoot":"","sources":["../../src/guards/can-activate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can-activate.js","sourceRoot":"","sources":["../../src/guards/can-activate.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/guards/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./use-guards-decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|