@noxfly/noxus 1.0.2 → 1.0.4
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 +45 -0
- package/dist/noxus.d.mts +72 -69
- package/dist/noxus.d.ts +72 -69
- package/dist/noxus.js +119 -113
- package/dist/noxus.js.map +1 -1
- package/dist/noxus.mjs +119 -113
- package/dist/noxus.mjs.map +1 -1
- package/package.json +1 -1
- package/src/{app-injector.ts → DI/app-injector.ts} +2 -2
- package/src/{injector-explorer.ts → DI/injector-explorer.ts} +7 -3
- package/src/app.ts +0 -68
- package/src/bootstrap.ts +5 -3
- package/src/decorators/controller.decorator.ts +26 -0
- package/src/{guards.ts → decorators/guards.decorator.ts} +2 -3
- package/src/decorators/injectable.decorator.ts +20 -0
- package/src/decorators/method.decorator.ts +42 -0
- package/src/decorators/module.decorator.ts +65 -0
- package/src/exceptions.ts +1 -1
- package/src/index.ts +8 -5
- package/src/request.ts +3 -3
- package/src/router.ts +8 -44
- package/src/utils/types.ts +10 -0
- package/src/metadata.ts +0 -52
- package/src/misc.ts +0 -1
- /package/src/{logger.ts → utils/logger.ts} +0 -0
- /package/src/{radix-tree.ts → utils/radix-tree.ts} +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getControllerMetadata } from "src/decorators/controller.decorator";
|
|
2
|
+
import { getInjectableMetadata } from "src/decorators/injectable.decorator";
|
|
3
|
+
import { getRouteMetadata } from "src/decorators/method.decorator";
|
|
4
|
+
import { getModuleMetadata } from "src/decorators/module.decorator";
|
|
5
|
+
import { Lifetime, RootInjector } from "src/DI/app-injector";
|
|
4
6
|
import { Router } from "src/router";
|
|
7
|
+
import { Logger } from "src/utils/logger";
|
|
8
|
+
import { Type } from "src/utils/types";
|
|
5
9
|
|
|
6
10
|
export class InjectorExplorer {
|
|
7
11
|
/**
|
package/src/app.ts
CHANGED
|
@@ -1,72 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
-
|
|
3
|
-
import { Lifetime } from "src/app-injector";
|
|
4
|
-
import { InjectorExplorer } from "src/injector-explorer";
|
|
5
|
-
import { CONTROLLER_METADATA_KEY, INJECTABLE_METADATA_KEY, MODULE_METADATA_KEY, IModuleMetadata, Type } from "src/metadata";
|
|
6
|
-
|
|
7
1
|
export interface IApp {
|
|
8
2
|
dispose(): Promise<void>;
|
|
9
3
|
onReady(): Promise<void>;
|
|
10
4
|
}
|
|
11
|
-
|
|
12
|
-
export function Injectable(lifetime: Lifetime = 'scope'): ClassDecorator {
|
|
13
|
-
return (target) => {
|
|
14
|
-
if(typeof target !== 'function' || !target.prototype) {
|
|
15
|
-
throw new Error(`@Injectable can only be used on classes, not on ${typeof target}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Reflect.defineMetadata(INJECTABLE_METADATA_KEY, lifetime, target);
|
|
19
|
-
InjectorExplorer.register(target as unknown as Type<any>, lifetime);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ---
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export function Module(metadata: IModuleMetadata): ClassDecorator {
|
|
27
|
-
return (target: Function) => {
|
|
28
|
-
// Validate imports and exports: must be decorated with @Module
|
|
29
|
-
const checkModule = (arr?: Type<unknown>[], arrName?: string): void => {
|
|
30
|
-
if(!arr)
|
|
31
|
-
return;
|
|
32
|
-
|
|
33
|
-
for(const clazz of arr) {
|
|
34
|
-
if(!Reflect.getMetadata(MODULE_METADATA_KEY, clazz)) {
|
|
35
|
-
throw new Error(`Class ${clazz.name} in ${arrName} must be decorated with @Module`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Validate providers: must be decorated with @Injectable
|
|
41
|
-
const checkInjectable = (arr?: Type<unknown>[]): void => {
|
|
42
|
-
if(!arr)
|
|
43
|
-
return;
|
|
44
|
-
|
|
45
|
-
for(const clazz of arr) {
|
|
46
|
-
if(!Reflect.getMetadata(INJECTABLE_METADATA_KEY, clazz)) {
|
|
47
|
-
throw new Error(`Class ${clazz.name} in providers must be decorated with @Injectable`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Validate controllers: must be decorated with @Controller
|
|
53
|
-
const checkController = (arr?: Type<unknown>[]): void => {
|
|
54
|
-
if(!arr) return;
|
|
55
|
-
for(const clazz of arr) {
|
|
56
|
-
if(!Reflect.getMetadata(CONTROLLER_METADATA_KEY, clazz)) {
|
|
57
|
-
throw new Error(`Class ${clazz.name} in controllers must be decorated with @Controller`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
checkModule(metadata.imports, 'imports');
|
|
63
|
-
checkModule(metadata.exports, 'exports');
|
|
64
|
-
checkInjectable(metadata.providers);
|
|
65
|
-
checkController(metadata.controllers);
|
|
66
|
-
|
|
67
|
-
Reflect.defineMetadata(MODULE_METADATA_KEY, metadata, target);
|
|
68
|
-
|
|
69
|
-
Injectable('singleton')(target);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
package/src/bootstrap.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ipcMain } from "electron";
|
|
2
2
|
import { app, BrowserWindow, MessageChannelMain } from "electron/main";
|
|
3
3
|
import { IApp } from "src/app";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { getInjectableMetadata } from "src/decorators/injectable.decorator";
|
|
5
|
+
import { getModuleMetadata } from "src/decorators/module.decorator";
|
|
6
|
+
import { RootInjector } from "src/DI/app-injector";
|
|
7
|
+
import { IRequest, IResponse, Request } from "src/request";
|
|
7
8
|
import { Router } from "src/router";
|
|
9
|
+
import { Type } from "src/utils/types";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
*
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getGuardForController, IGuard } from "src/decorators/guards.decorator";
|
|
2
|
+
import { Injectable } from "src/decorators/injectable.decorator";
|
|
3
|
+
import { Type } from "src/utils/types";
|
|
4
|
+
|
|
5
|
+
export interface IControllerMetadata {
|
|
6
|
+
path: string;
|
|
7
|
+
guards: Type<IGuard>[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function Controller(path: string): ClassDecorator {
|
|
11
|
+
return (target) => {
|
|
12
|
+
const data: IControllerMetadata = {
|
|
13
|
+
path,
|
|
14
|
+
guards: getGuardForController(target.name)
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Reflect.defineMetadata(CONTROLLER_METADATA_KEY, data, target);
|
|
18
|
+
Injectable('scope')(target);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const CONTROLLER_METADATA_KEY = Symbol('CONTROLLER_METADATA_KEY');
|
|
23
|
+
|
|
24
|
+
export function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined {
|
|
25
|
+
return Reflect.getMetadata(CONTROLLER_METADATA_KEY, target);
|
|
26
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Logger } from 'src/logger';
|
|
2
|
-
import { Type } from 'src/metadata';
|
|
3
|
-
import { MaybeAsync } from 'src/misc';
|
|
4
1
|
import { Request } from 'src/request';
|
|
2
|
+
import { Logger } from 'src/utils/logger';
|
|
3
|
+
import { MaybeAsync, Type } from 'src/utils/types';
|
|
5
4
|
|
|
6
5
|
export interface IGuard {
|
|
7
6
|
canActivate(request: Request): MaybeAsync<boolean>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Lifetime } from "src/DI/app-injector";
|
|
2
|
+
import { InjectorExplorer } from "src/DI/injector-explorer";
|
|
3
|
+
import { Type } from "src/utils/types";
|
|
4
|
+
|
|
5
|
+
export function Injectable(lifetime: Lifetime = 'scope'): ClassDecorator {
|
|
6
|
+
return (target) => {
|
|
7
|
+
if(typeof target !== 'function' || !target.prototype) {
|
|
8
|
+
throw new Error(`@Injectable can only be used on classes, not on ${typeof target}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Reflect.defineMetadata(INJECTABLE_METADATA_KEY, lifetime, target);
|
|
12
|
+
InjectorExplorer.register(target as unknown as Type<any>, lifetime);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const INJECTABLE_METADATA_KEY = Symbol('INJECTABLE_METADATA_KEY');
|
|
17
|
+
|
|
18
|
+
export function getInjectableMetadata(target: Type<unknown>): Lifetime | undefined {
|
|
19
|
+
return Reflect.getMetadata(INJECTABLE_METADATA_KEY, target);
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getGuardForControllerAction, IGuard } from "src/decorators/guards.decorator";
|
|
2
|
+
import { Type } from "src/utils/types";
|
|
3
|
+
|
|
4
|
+
function createRouteDecorator(verb: HttpMethod): (path: string) => MethodDecorator {
|
|
5
|
+
return (path: string): MethodDecorator => {
|
|
6
|
+
return (target, propertyKey) => {
|
|
7
|
+
const existingRoutes: IRouteMetadata[] = Reflect.getMetadata(ROUTE_METADATA_KEY, target.constructor) || [];
|
|
8
|
+
|
|
9
|
+
const metadata: IRouteMetadata = {
|
|
10
|
+
method: verb,
|
|
11
|
+
path: path.trim().replace(/^\/|\/$/g, ''),
|
|
12
|
+
handler: propertyKey as string,
|
|
13
|
+
guards: getGuardForControllerAction((target.constructor as any).__controllerName, propertyKey as string),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
existingRoutes.push(metadata);
|
|
17
|
+
|
|
18
|
+
Reflect.defineMetadata(ROUTE_METADATA_KEY, existingRoutes, target.constructor);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IRouteMetadata {
|
|
24
|
+
method: HttpMethod;
|
|
25
|
+
path: string;
|
|
26
|
+
handler: string;
|
|
27
|
+
guards: Type<IGuard>[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
31
|
+
|
|
32
|
+
export const Get = createRouteDecorator('GET');
|
|
33
|
+
export const Post = createRouteDecorator('POST');
|
|
34
|
+
export const Put = createRouteDecorator('PUT');
|
|
35
|
+
export const Patch = createRouteDecorator('PATCH');
|
|
36
|
+
export const Delete = createRouteDecorator('DELETE');
|
|
37
|
+
|
|
38
|
+
export const ROUTE_METADATA_KEY = Symbol('ROUTE_METADATA_KEY');
|
|
39
|
+
|
|
40
|
+
export function getRouteMetadata(target: Type<unknown>): IRouteMetadata[] {
|
|
41
|
+
return Reflect.getMetadata(ROUTE_METADATA_KEY, target) || [];
|
|
42
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
+
|
|
3
|
+
import { CONTROLLER_METADATA_KEY } from "src/decorators/controller.decorator";
|
|
4
|
+
import { Injectable, INJECTABLE_METADATA_KEY } from "src/decorators/injectable.decorator";
|
|
5
|
+
import { Type } from "src/utils/types";
|
|
6
|
+
|
|
7
|
+
export function Module(metadata: IModuleMetadata): ClassDecorator {
|
|
8
|
+
return (target: Function) => {
|
|
9
|
+
// Validate imports and exports: must be decorated with @Module
|
|
10
|
+
const checkModule = (arr?: Type<unknown>[], arrName?: string): void => {
|
|
11
|
+
if(!arr)
|
|
12
|
+
return;
|
|
13
|
+
|
|
14
|
+
for(const clazz of arr) {
|
|
15
|
+
if(!Reflect.getMetadata(MODULE_METADATA_KEY, clazz)) {
|
|
16
|
+
throw new Error(`Class ${clazz.name} in ${arrName} must be decorated with @Module`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Validate providers: must be decorated with @Injectable
|
|
22
|
+
const checkInjectable = (arr?: Type<unknown>[]): void => {
|
|
23
|
+
if(!arr)
|
|
24
|
+
return;
|
|
25
|
+
|
|
26
|
+
for(const clazz of arr) {
|
|
27
|
+
if(!Reflect.getMetadata(INJECTABLE_METADATA_KEY, clazz)) {
|
|
28
|
+
throw new Error(`Class ${clazz.name} in providers must be decorated with @Injectable`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Validate controllers: must be decorated with @Controller
|
|
34
|
+
const checkController = (arr?: Type<unknown>[]): void => {
|
|
35
|
+
if(!arr) return;
|
|
36
|
+
for(const clazz of arr) {
|
|
37
|
+
if(!Reflect.getMetadata(CONTROLLER_METADATA_KEY, clazz)) {
|
|
38
|
+
throw new Error(`Class ${clazz.name} in controllers must be decorated with @Controller`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
checkModule(metadata.imports, 'imports');
|
|
44
|
+
checkModule(metadata.exports, 'exports');
|
|
45
|
+
checkInjectable(metadata.providers);
|
|
46
|
+
checkController(metadata.controllers);
|
|
47
|
+
|
|
48
|
+
Reflect.defineMetadata(MODULE_METADATA_KEY, metadata, target);
|
|
49
|
+
|
|
50
|
+
Injectable('singleton')(target);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const MODULE_METADATA_KEY = Symbol('MODULE_METADATA_KEY');
|
|
55
|
+
|
|
56
|
+
export interface IModuleMetadata {
|
|
57
|
+
imports?: Type<unknown>[];
|
|
58
|
+
exports?: Type<unknown>[];
|
|
59
|
+
providers?: Type<unknown>[];
|
|
60
|
+
controllers?: Type<unknown>[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getModuleMetadata(target: Function): IModuleMetadata | undefined {
|
|
64
|
+
return Reflect.getMetadata(MODULE_METADATA_KEY, target);
|
|
65
|
+
}
|
package/src/exceptions.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export * from './app-injector';
|
|
1
|
+
export * from './DI/app-injector';
|
|
2
2
|
export * from './router';
|
|
3
3
|
export * from './app';
|
|
4
4
|
export * from './bootstrap';
|
|
5
5
|
export * from './exceptions';
|
|
6
|
-
export * from './guards';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
6
|
+
export * from './decorators/guards.decorator';
|
|
7
|
+
export * from './decorators/controller.decorator';
|
|
8
|
+
export * from './decorators/injectable.decorator';
|
|
9
|
+
export * from './decorators/method.decorator';
|
|
10
|
+
export * from './decorators/module.decorator';
|
|
11
|
+
export * from './utils/logger';
|
|
12
|
+
export * from './utils/types';
|
|
10
13
|
export * from './request';
|
package/src/request.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IApp } from 'src/app';
|
|
2
|
-
import { RootInjector } from 'src/app-injector';
|
|
3
|
-
import { HttpMethod } from 'src/router';
|
|
4
1
|
import 'reflect-metadata';
|
|
2
|
+
import { IApp } from 'src/app';
|
|
3
|
+
import { HttpMethod } from 'src/decorators/method.decorator';
|
|
4
|
+
import { RootInjector } from 'src/DI/app-injector';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
//
|
package/src/router.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import {
|
|
2
|
+
import { getControllerMetadata } from 'src/decorators/controller.decorator';
|
|
3
|
+
import { getGuardForController, getGuardForControllerAction, IGuard } from 'src/decorators/guards.decorator';
|
|
4
|
+
import { Injectable } from 'src/decorators/injectable.decorator';
|
|
5
|
+
import { getRouteMetadata } from 'src/decorators/method.decorator';
|
|
3
6
|
import { MethodNotAllowedException, NotFoundException, ResponseException, UnauthorizedException } from 'src/exceptions';
|
|
4
|
-
import {
|
|
5
|
-
import { Logger } from 'src/logger';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Request, IResponse } from 'src/request';
|
|
7
|
+
import { IResponse, Request } from 'src/request';
|
|
8
|
+
import { Logger } from 'src/utils/logger';
|
|
9
|
+
import { RadixTree } from 'src/utils/radix-tree';
|
|
10
|
+
import { Type } from 'src/utils/types';
|
|
9
11
|
|
|
10
12
|
// types & interfaces
|
|
11
13
|
|
|
12
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
13
|
-
|
|
14
14
|
export interface IRouteDefinition {
|
|
15
15
|
method: string;
|
|
16
16
|
path: string;
|
|
@@ -21,42 +21,6 @@ export interface IRouteDefinition {
|
|
|
21
21
|
|
|
22
22
|
export type ControllerAction = (request: Request, response: IResponse) => any;
|
|
23
23
|
|
|
24
|
-
export function Controller(path: string): ClassDecorator {
|
|
25
|
-
return (target) => {
|
|
26
|
-
const data: IControllerMetadata = {
|
|
27
|
-
path,
|
|
28
|
-
guards: getGuardForController(target.name)
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
Reflect.defineMetadata(CONTROLLER_METADATA_KEY, data, target);
|
|
32
|
-
Injectable('scope')(target);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createRouteDecorator(verb: HttpMethod): (path: string) => MethodDecorator {
|
|
37
|
-
return (path: string): MethodDecorator => {
|
|
38
|
-
return (target, propertyKey) => {
|
|
39
|
-
const existingRoutes: IRouteMetadata[] = Reflect.getMetadata(ROUTE_METADATA_KEY, target.constructor) || [];
|
|
40
|
-
|
|
41
|
-
const metadata: IRouteMetadata = {
|
|
42
|
-
method: verb,
|
|
43
|
-
path: path.trim().replace(/^\/|\/$/g, ''),
|
|
44
|
-
handler: propertyKey as string,
|
|
45
|
-
guards: getGuardForControllerAction((target.constructor as any).__controllerName, propertyKey as string),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
existingRoutes.push(metadata);
|
|
49
|
-
|
|
50
|
-
Reflect.defineMetadata(ROUTE_METADATA_KEY, existingRoutes, target.constructor);
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const Get = createRouteDecorator('GET');
|
|
56
|
-
export const Post = createRouteDecorator('POST');
|
|
57
|
-
export const Put = createRouteDecorator('PUT');
|
|
58
|
-
export const Patch = createRouteDecorator('PATCH');
|
|
59
|
-
export const Delete = createRouteDecorator('DELETE');
|
|
60
24
|
|
|
61
25
|
@Injectable('singleton')
|
|
62
26
|
export class Router {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
declare const Type: FunctionConstructor;
|
|
5
|
+
export interface Type<T> extends Function {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type MaybeAsync<T> = T | Promise<T>;
|
package/src/metadata.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
-
|
|
3
|
-
import { Lifetime } from "src/app-injector";
|
|
4
|
-
import { IGuard } from "src/guards";
|
|
5
|
-
import { HttpMethod } from "src/router";
|
|
6
|
-
|
|
7
|
-
declare const Type: FunctionConstructor;
|
|
8
|
-
export interface Type<T> extends Function {
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
10
|
-
new (...args: any[]): T;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const MODULE_METADATA_KEY = Symbol('MODULE_METADATA_KEY');
|
|
14
|
-
export const INJECTABLE_METADATA_KEY = Symbol('INJECTABLE_METADATA_KEY');
|
|
15
|
-
export const CONTROLLER_METADATA_KEY = Symbol('CONTROLLER_METADATA_KEY');
|
|
16
|
-
export const ROUTE_METADATA_KEY = Symbol('ROUTE_METADATA_KEY');
|
|
17
|
-
|
|
18
|
-
export interface IModuleMetadata {
|
|
19
|
-
imports?: Type<unknown>[];
|
|
20
|
-
providers?: Type<unknown>[];
|
|
21
|
-
controllers?: Type<unknown>[];
|
|
22
|
-
exports?: Type<unknown>[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface IRouteMetadata {
|
|
26
|
-
method: HttpMethod;
|
|
27
|
-
path: string;
|
|
28
|
-
handler: string;
|
|
29
|
-
guards: Type<IGuard>[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IControllerMetadata {
|
|
33
|
-
path: string;
|
|
34
|
-
guards: Type<IGuard>[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined {
|
|
39
|
-
return Reflect.getMetadata(CONTROLLER_METADATA_KEY, target);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function getRouteMetadata(target: Type<unknown>): IRouteMetadata[] {
|
|
43
|
-
return Reflect.getMetadata(ROUTE_METADATA_KEY, target) || [];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function getModuleMetadata(target: Function): IModuleMetadata | undefined {
|
|
47
|
-
return Reflect.getMetadata(MODULE_METADATA_KEY, target);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getInjectableMetadata(target: Type<unknown>): Lifetime | undefined {
|
|
51
|
-
return Reflect.getMetadata(INJECTABLE_METADATA_KEY, target);
|
|
52
|
-
}
|
package/src/misc.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type MaybeAsync<T> = T | Promise<T>;
|
|
File without changes
|
|
File without changes
|