Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@neoskop/nem

Package Overview
Dependencies
Maintainers
8
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoskop/nem - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

docs/assets/js/search.js
var typedoc = typedoc || {};
typedoc.search = typedoc.search || {};
typedoc.search.data = {"kinds":{"128":"Class","65536":"Type literal"},"rows":[{"id":0,"kind":65536,"name":"__type","url":"classes/abstractparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"AbstractParam.resolve"},{"id":1,"kind":65536,"name":"__type","url":"interfaces/queryparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"QueryParam.resolve"},{"id":2,"kind":65536,"name":"__type","url":"interfaces/queryparams.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"QueryParams.resolve"},{"id":3,"kind":65536,"name":"__type","url":"interfaces/param.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Param.resolve"},{"id":4,"kind":65536,"name":"__type","url":"interfaces/params.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Params.resolve"},{"id":5,"kind":65536,"name":"__type","url":"interfaces/bodyparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"BodyParam.resolve"},{"id":6,"kind":65536,"name":"__type","url":"interfaces/body.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Body.resolve"},{"id":7,"kind":65536,"name":"__type","url":"interfaces/headerparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"HeaderParam.resolve"},{"id":8,"kind":65536,"name":"__type","url":"interfaces/headers.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Headers.resolve"},{"id":9,"kind":65536,"name":"__type","url":"interfaces/sessionparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"SessionParam.resolve"},{"id":10,"kind":65536,"name":"__type","url":"interfaces/session.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Session.resolve"},{"id":11,"kind":65536,"name":"__type","url":"interfaces/sessionid.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"SessionId.resolve"},{"id":12,"kind":65536,"name":"__type","url":"interfaces/req.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Req.resolve"},{"id":13,"kind":65536,"name":"__type","url":"interfaces/res.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Res.resolve"},{"id":14,"kind":128,"name":"NemBootstrap","url":"classes/nembootstrap.html","classes":"tsd-kind-class"}]};
typedoc.search.data = {"kinds":{"65536":"Type literal"},"rows":[{"id":0,"kind":65536,"name":"__type","url":"classes/abstractparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"AbstractParam.resolve"},{"id":1,"kind":65536,"name":"__type","url":"interfaces/queryparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"QueryParam.resolve"},{"id":2,"kind":65536,"name":"__type","url":"interfaces/queryparams.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"QueryParams.resolve"},{"id":3,"kind":65536,"name":"__type","url":"interfaces/param.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Param.resolve"},{"id":4,"kind":65536,"name":"__type","url":"interfaces/params.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Params.resolve"},{"id":5,"kind":65536,"name":"__type","url":"interfaces/bodyparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"BodyParam.resolve"},{"id":6,"kind":65536,"name":"__type","url":"interfaces/body.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Body.resolve"},{"id":7,"kind":65536,"name":"__type","url":"interfaces/headerparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"HeaderParam.resolve"},{"id":8,"kind":65536,"name":"__type","url":"interfaces/headers.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Headers.resolve"},{"id":9,"kind":65536,"name":"__type","url":"interfaces/sessionparam.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"SessionParam.resolve"},{"id":10,"kind":65536,"name":"__type","url":"interfaces/session.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Session.resolve"},{"id":11,"kind":65536,"name":"__type","url":"interfaces/sessionid.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"SessionId.resolve"},{"id":12,"kind":65536,"name":"__type","url":"interfaces/req.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Req.resolve"},{"id":13,"kind":65536,"name":"__type","url":"interfaces/res.html#resolve.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"Res.resolve"}]};

@@ -9,8 +9,25 @@ /// <reference types="express" />

import { Server } from 'http';
/**
* Bootstraping options
*/
export interface INemOptions {
/**
* Providers for bootstrapping
*/
providers?: Provider[];
/**
* Injector to create the bootstrap injector from
*/
injector?: Injector;
}
/**
* Bootstrap factory
*/
export declare function nem(options?: INemOptions): NemBootstrap;
export declare const BOOTSTRAP_PROVIDER: Provider[];
/**
* Required providers for root injector
*
* @internal
* @hidden
*/
export declare const ROOT_PROVIDER: Provider[];

@@ -26,4 +43,13 @@ export declare class NemBootstrap {

}
/**
* The public api for the bootstrapped root module
*/
export declare class NemBootstrappedModule {
/**
* The root injector
*/
readonly injector: Injector;
/**
* The root module context
*/
readonly context: Readonly<IModuleContext>;

@@ -30,0 +56,0 @@ constructor(injector: Injector, context: Readonly<IModuleContext>);

@@ -14,2 +14,5 @@ "use strict";

var http_1 = require("http");
/**
* Bootstrap factory
*/
function nem(options) {

@@ -20,3 +23,9 @@ if (options === void 0) { options = {}; }

exports.nem = nem;
exports.BOOTSTRAP_PROVIDER = [
/**
* Required providers for bootstrapping
*
* @internal
* @hidden
*/
var BOOTSTRAP_PROVIDER = [
param_1.ParamFactory,

@@ -28,2 +37,8 @@ module_router_1.ModuleRouterFactory,

];
/**
* Required providers for root injector
*
* @internal
* @hidden
*/
exports.ROOT_PROVIDER = [

@@ -59,3 +74,3 @@ {

name: 'BootstrapInjector',
providers: tslib_1.__spread(exports.BOOTSTRAP_PROVIDER, (this.options.providers || [])),
providers: tslib_1.__spread(BOOTSTRAP_PROVIDER, (this.options.providers || [])),
parent: this.options.injector

@@ -111,2 +126,5 @@ });

exports.NemBootstrap = NemBootstrap;
/**
* The public api for the bootstrapped root module
*/
var NemBootstrappedModule = /** @class */ (function () {

@@ -113,0 +131,0 @@ function NemBootstrappedModule(injector, context) {

/// <reference types="express" />
import { ErrorRequestHandler } from 'express';
export declare const defaultErrorHandler: ErrorRequestHandler;
/** @internal */
import { NextFunction, Request, Response } from 'express';
/**
* Default error middleware to handle express errors
*
* @internal
* @hidden
*/
export declare function defaultErrorHandler(error: any, _request: Request, response: Response, _next: NextFunction): Promise<void>;
"use strict";
/** @internal */
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var http_1 = require("./http");
exports.defaultErrorHandler = function defaultErrorHandler(error, _request, response, _next) {
/**
* Default error middleware to handle express errors
*
* @internal
* @hidden
*/
function defaultErrorHandler(error, _request, response, _next) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -21,3 +28,4 @@ return tslib_1.__generator(this, function (_a) {

});
};
}
exports.defaultErrorHandler = defaultErrorHandler;
//# sourceMappingURL=error-handler.js.map

@@ -1,4 +0,5 @@

export interface HttpError extends Error {
}
export declare class HttpError {
/**
* Generic http error
*/
export declare class HttpError implements Error {
code: number;

@@ -8,30 +9,58 @@ error: any;

stack: string;
name: string;
constructor(code: number, message?: string | null, error?: any);
}
/**
* Error class for http status 400
*/
export declare class BadRequestError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 401
*/
export declare class UnauthorizedError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 403
*/
export declare class ForbiddenError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 404
*/
export declare class NotFoundError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 406
*/
export declare class NotAcceptableError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 412
*/
export declare class PreconditionFailedError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 415
*/
export declare class UnsupportedMediaTypeError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 500
*/
export declare class InternalServerError extends HttpError {
constructor(message?: string | null, error?: any);
}
/**
* Error class for http status 501
*/
export declare class NotImplementedError extends HttpError {
constructor(message?: string | null, error?: any);
}

@@ -5,2 +5,5 @@ "use strict";

var HttpStatus = require("http-status");
/**
* Generic http error
*/
var HttpError = /** @class */ (function () {

@@ -13,2 +16,3 @@ function HttpError(code, message, error) {

.replace(/\r?\n[^\r\n]+/, '');
this.name = this.constructor.name;
}

@@ -18,2 +22,5 @@ return HttpError;

exports.HttpError = HttpError;
/**
* Error class for http status 400
*/
var BadRequestError = /** @class */ (function (_super) {

@@ -27,2 +34,5 @@ tslib_1.__extends(BadRequestError, _super);

exports.BadRequestError = BadRequestError;
/**
* Error class for http status 401
*/
var UnauthorizedError = /** @class */ (function (_super) {

@@ -36,2 +46,5 @@ tslib_1.__extends(UnauthorizedError, _super);

exports.UnauthorizedError = UnauthorizedError;
/**
* Error class for http status 403
*/
var ForbiddenError = /** @class */ (function (_super) {

@@ -45,2 +58,5 @@ tslib_1.__extends(ForbiddenError, _super);

exports.ForbiddenError = ForbiddenError;
/**
* Error class for http status 404
*/
var NotFoundError = /** @class */ (function (_super) {

@@ -54,2 +70,5 @@ tslib_1.__extends(NotFoundError, _super);

exports.NotFoundError = NotFoundError;
/**
* Error class for http status 406
*/
var NotAcceptableError = /** @class */ (function (_super) {

@@ -63,2 +82,5 @@ tslib_1.__extends(NotAcceptableError, _super);

exports.NotAcceptableError = NotAcceptableError;
/**
* Error class for http status 412
*/
var PreconditionFailedError = /** @class */ (function (_super) {

@@ -72,2 +94,5 @@ tslib_1.__extends(PreconditionFailedError, _super);

exports.PreconditionFailedError = PreconditionFailedError;
/**
* Error class for http status 415
*/
var UnsupportedMediaTypeError = /** @class */ (function (_super) {

@@ -81,2 +106,5 @@ tslib_1.__extends(UnsupportedMediaTypeError, _super);

exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
/**
* Error class for http status 500
*/
var InternalServerError = /** @class */ (function (_super) {

@@ -90,2 +118,5 @@ tslib_1.__extends(InternalServerError, _super);

exports.InternalServerError = InternalServerError;
/**
* Error class for http status 501
*/
var NotImplementedError = /** @class */ (function (_super) {

@@ -92,0 +123,0 @@ tslib_1.__extends(NotImplementedError, _super);

@@ -20,8 +20,26 @@ /// <reference types="express" />

}
export interface IControllerContext {
cls: Type<any>;
export interface IControllerContext<T = any> {
/**
* The controller type class
*/
controllerType: Type<T>;
/**
* The controller metadata
*/
metadata: AbstractController;
/**
* The controller injector
*/
injector: Injector;
instance: any;
/**
* The controller instance
*/
instance: T;
/**
* The controller methods and annotations
*/
methods: Map<string, MethodAnnotationMap>;
/**
* The express router instance
*/
router: Router;

@@ -34,10 +52,10 @@ }

constructor(injector: Injector, zone: NemRootZone, paramFactory: ParamFactory);
createRouterFromController(cls: Type<any>, {providers}?: {
createRouterFromController(controllerType: Type<any>, {providers}?: {
providers?: Provider[];
}): Router;
protected initContext(cls: Type<any>, providers: Provider[]): IControllerContext;
protected assertControllerAnnotation(cls: Type<any>): AbstractController;
protected createMethodAnnotationMap(cls: Type<any>): Map<string, MethodAnnotationMap>;
protected getParamsForMethod(cls: Type<any>, method: string): AbstractParam[];
protected initContext(controllerType: Type<any>, providers: Provider[]): IControllerContext;
protected assertControllerAnnotation(controllerType: Type<any>): AbstractController;
protected createMethodAnnotationMap(controllerType: Type<any>): Map<string, MethodAnnotationMap>;
protected getParamsForMethod(controllerType: Type<any>, method: string): AbstractParam[];
protected createHandler(ctx: IControllerContext, method: string, params: AbstractParam[], annotations: MethodAnnotationMap): RequestHandler[];
}

@@ -15,2 +15,3 @@ "use strict";

var middleware_1 = require("../metadata/middleware");
/** @hidden */
var debug = require('debug')('nem:factory:controller');

@@ -23,10 +24,10 @@ var ControllerRouterFactory = /** @class */ (function () {

}
ControllerRouterFactory.prototype.createRouterFromController = function (cls, _a) {
ControllerRouterFactory.prototype.createRouterFromController = function (controllerType, _a) {
var _b = (_a === void 0 ? {} : _a).providers, providers = _b === void 0 ? [] : _b;
debug('create router from controller', cls.name);
var ctx = this.initContext(cls, providers);
debug('create router from controller', controllerType.name);
var ctx = this.initContext(controllerType, providers);
try {
for (var _c = tslib_1.__values(ctx.methods), _d = _c.next(); !_d.done; _d = _c.next()) {
var _e = tslib_1.__read(_d.value, 2), method = _e[0], annotations = _e[1];
var params = this.getParamsForMethod(cls, method);
var params = this.getParamsForMethod(controllerType, method);
try {

@@ -57,17 +58,17 @@ for (var _f = tslib_1.__values(annotations.get(controller_1.AbstractMethod)), _g = _f.next(); !_g.done; _g = _f.next()) {

};
ControllerRouterFactory.prototype.initContext = function (cls, providers) {
var ctx = { router: express_1.Router(), cls: cls };
ctx.metadata = this.assertControllerAnnotation(cls);
ControllerRouterFactory.prototype.initContext = function (controllerType, providers) {
var ctx = { router: express_1.Router(), controllerType: controllerType };
ctx.metadata = this.assertControllerAnnotation(controllerType);
ctx.injector = injector_1.InjectorFactory.create({
parent: this.injector,
providers: tslib_1.__spread(misc_1.copyMultiProvider(tokens_1.MULTI_TOKENS_FROM_PARENT, this.injector), providers, (ctx.metadata.providers || []), [
cls
controllerType
])
});
ctx.instance = ctx.injector.get(cls);
ctx.methods = this.createMethodAnnotationMap(cls);
ctx.instance = ctx.injector.get(controllerType);
ctx.methods = this.createMethodAnnotationMap(controllerType);
return ctx;
};
ControllerRouterFactory.prototype.assertControllerAnnotation = function (cls) {
var annotations = annotations_1.Annotator.getCtorAnnotations(cls);
ControllerRouterFactory.prototype.assertControllerAnnotation = function (controllerType) {
var annotations = annotations_1.Annotator.getCtorAnnotations(controllerType);
try {

@@ -88,7 +89,7 @@ for (var annotations_2 = tslib_1.__values(annotations), annotations_2_1 = annotations_2.next(); !annotations_2_1.done; annotations_2_1 = annotations_2.next()) {

}
throw new Error("Class \"" + cls.name + "\" has no controller annotation");
throw new Error("Class \"" + controllerType.name + "\" has no controller annotation");
var e_3, _a;
};
ControllerRouterFactory.prototype.createMethodAnnotationMap = function (cls) {
var annotations = annotations_1.Annotator.getPropAnnotations(cls);
ControllerRouterFactory.prototype.createMethodAnnotationMap = function (controllerType) {
var annotations = annotations_1.Annotator.getPropAnnotations(controllerType);
var methods = new Map();

@@ -134,4 +135,4 @@ var types = [controller_1.AbstractMethod, controller_1.ApplicableAnnotation, middleware_1.Use];

};
ControllerRouterFactory.prototype.getParamsForMethod = function (cls, method) {
var annotations = annotations_1.Annotator.getParamAnnotations(cls, method);
ControllerRouterFactory.prototype.getParamsForMethod = function (controllerType, method) {
var annotations = annotations_1.Annotator.getParamAnnotations(controllerType, method);
var result = [];

@@ -143,6 +144,6 @@ try {

if (p.length === 0) {
throw new Error("Missing param annotation for param " + index + " of method " + cls.name + ":" + method);
throw new Error("Missing param annotation for param " + index + " of method " + controllerType.name + ":" + method);
}
else if (p.length > 1) {
throw new Error("Too many param annotations for param " + index + " of method " + cls.name + ":" + method);
throw new Error("Too many param annotations for param " + index + " of method " + controllerType.name + ":" + method);
}

@@ -214,3 +215,2 @@ result.push(p[0]);

_d.sent();
next();
return [3 /*break*/, 8];

@@ -261,2 +261,6 @@ case 7:

exports.ControllerRouterFactory = ControllerRouterFactory;
/**
* @internal
* @hidden
*/
function applyApplicableAnnotations(app, type, args, _a) {

@@ -263,0 +267,0 @@ var stopAfterFirst = (_a === void 0 ? {} : _a).stopAfterFirst;

@@ -7,10 +7,32 @@ /// <reference types="express" />

import { ControllerRouterFactory } from './controller-router';
/**
* @internal
* @hidden
*/
export declare const MODULE_FACTORY_PROVIDER: Provider[];
export interface IModuleContext {
moduleType: Type<any>;
export interface IModuleContext<T = any> {
/**
* The module type class
*/
moduleType: Type<T>;
/**
* The module metadata
*/
metadata: NemModule;
/**
* The module injector
*/
injector: Injector;
/**
* The controller factory
*/
factory: ControllerRouterFactory;
/**
* The use router
*/
router: IRouter<any>;
module?: any;
/**
* The module instance
*/
module?: T;
}

@@ -17,0 +39,0 @@ export declare class ModuleRouterFactory {

@@ -11,3 +11,8 @@ "use strict";

var misc_1 = require("../utils/misc");
/** @hidden */
var debug = require('debug')('nem:factory:module');
/**
* @internal
* @hidden
*/
exports.MODULE_FACTORY_PROVIDER = [

@@ -14,0 +19,0 @@ { provide: tokens_1.VIEW_PREFIX, useValue: undefined },

@@ -11,10 +11,49 @@ /// <reference types="express" />

}
/**
* Type of Controller decorator
*/
export interface ControllerDecorator {
/**
* Defines a class as controller
* @example
* ```
*
* @Controller()
* export class TestController() {}
* ```
*/
(options?: IControllerOptions): any;
new (options?: IControllerOptions): Controller;
}
export interface Controller {
/**
* Type of Controller metadata
* @see {@link ControllerDecorator}
*/
export interface Controller extends AbstractController {
}
export declare const Controller: ControllerDecorator;
export declare const JsonController: ControllerDecorator;
/**
* Type of Controller decorator
*/
export interface JsonControllerDecorator {
/**
* Defines a class as json controller
* @example
* ```
*
*
* @JsonController()
* export class JsonController() {}
* ```
*/
(options?: IControllerOptions): any;
new (options?: IControllerOptions): JsonController;
}
/**
* Type of JsonController metadata
* @see {@link JsonControllerDecorator}
*/
export interface JsonController extends AbstractController {
}
export declare const JsonController: JsonControllerDecorator;
export declare abstract class AbstractMethod {

@@ -24,2 +63,5 @@ abstract method: 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';

}
/**
* Type of Method decorator
*/
export interface MethodDecorator<T extends AbstractMethod> {

@@ -29,27 +71,127 @@ (path: RegExp | string): any;

}
export declare const MethodFactory: (method: string) => (path: string | RegExp) => {
method: string;
path: string | RegExp;
};
/**
* Type of All metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @All('/')
* index() {}
* }
* ```
*/
export interface All extends AbstractMethod {
}
export declare const All: MethodDecorator<All>;
/**
* Type of Get metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Get('/')
* index() {}
* }
* ```
*/
export interface Get extends AbstractMethod {
}
export declare const Get: MethodDecorator<Get>;
/**
* Type of Post metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Post('/')
* index() {}
* }
* ```
*/
export interface Post extends AbstractMethod {
}
export declare const Post: MethodDecorator<Post>;
/**
* Type of Put metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Put('/')
* index() {}
* }
* ```
*/
export interface Put extends AbstractMethod {
}
export declare const Put: MethodDecorator<Put>;
/**
* Type of Delete metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Delete('/')
* index() {}
* }
* ```
*/
export interface Delete extends AbstractMethod {
}
export declare const Delete: MethodDecorator<Delete>;
/**
* Type of Patch metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Patch('/')
* index() {}
* }
* ```
*/
export interface Patch extends AbstractMethod {
}
export declare const Patch: MethodDecorator<Patch>;
/**
* Type of Options metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Options('/')
* index() {}
* }
* ```
*/
export interface Options extends AbstractMethod {
}
export declare const Options: MethodDecorator<Options>;
/**
* Type of Head metadata
* @see {@link MethodDecorator}
* @example
* ```
*
* @Controller()
* export class TestController {
* @Head('/')
* index() {}
* }
* ```
*/
export interface Head extends AbstractMethod {

@@ -74,2 +216,5 @@ }

}
/**
* Type of ContentType decorator
*/
export interface ContentTypeDecorator {

@@ -79,2 +224,5 @@ (contentType: string): any;

}
/**
* Type of ContentType metadata
*/
export interface ContentType extends ApplicableAnnotation {

@@ -84,6 +232,29 @@ contentType: string;

export declare const ContentType: ContentTypeDecorator;
/**
* Type of StatusCode decorator
*/
export interface StatusCodeDecorator {
/**
* Defines a status code
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @StatusCode(202)
* index() {}
*
* @Get('/test')
* test() {
* return Result([ new StatusCode(201) ]);
* }
* }
* ```
*/
(status: number): any;
new (status: number): StatusCode;
}
/**
* Type of StatusCode metadata
*/
export interface StatusCode extends ApplicableAnnotation {

@@ -96,6 +267,29 @@ status: number;

}
/**
* Type of Redirect decorator
*/
export interface RedirectDecorator {
/**
* Defines a redirect
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Redirect('https://example.com')
* index() {}
*
* @Get('/test')
* test() {
* return Result([ new Redirect('https://example.com') ]);
* }
* }
* ```
*/
(url: string, options?: IRedirectOptions): any;
new (url: string, options?: IRedirectOptions): Redirect;
}
/**
* Type of Redirect metadata
*/
export interface Redirect extends ApplicableAnnotation, IRedirectOptions {

@@ -106,6 +300,29 @@ url: string;

export declare const Redirect: RedirectDecorator;
/**
* Type of Header decorator
*/
export interface HeaderDecorator {
/**
* Defines a header
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Header('ETag', 'foobar')
* index() {}
*
* @Get('/test')
* test() {
* return Result([ new Header('ETag', 'foobar') ]);
* }
* }
* ```
*/
(name: string, value: string): any;
new (name: string, value: string): Header;
}
/**
* Type of Header metadata
*/
export interface Header extends ApplicableAnnotation {

@@ -116,6 +333,29 @@ headerName: string;

export declare const Header: HeaderDecorator;
/**
* Type of View decorator
*/
export interface ViewDecorator {
/**
* Defines the view to render
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @View('index')
* index() {}
*
* @Get('/test')
* test() {
* return Result([ new View('test) ]);
* }
* }
* ```
*/
(view: string): any;
new (view: string): View;
}
/**
* Type of View metadata
*/
export interface View extends ApplicableAnnotation {

@@ -125,6 +365,29 @@ view: string;

export declare const View: ViewDecorator;
/**
* Type of Locals decorator
*/
export interface LocalsDecorator {
/**
* Defines local view variables
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Locals({ foo: 'bar' })
* index() {}
*
* @Get('/test')
* test() {
* return Result([ new Locals({ foo: 'bar' }) ]);
* }
* }
* ```
*/
(locals: Object): any;
new (locals: Object): Locals;
}
/**
* Type of Locals metadata
*/
export interface Locals extends ApplicableAnnotation {

@@ -134,27 +397,126 @@ locals: Object;

export declare const Locals: LocalsDecorator;
/**
* Type of Json decorator
*/
export interface JsonDecorator {
/**
* Defines controller handler to return json
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Json()
* index() {
* return null;
* }
*
* @Get('/test')
* test() {
* return Result([ new Json() ], null);
* }
* }
* ```
*/
(): any;
new (): Json;
}
/**
* Type of Json metadata
*/
export interface Json extends ApplicableAnnotation {
}
export declare const Json: JsonDecorator;
/**
* Type of Raw decorator
*/
export interface RawDecorator {
/**
* Defines controller handler to return raw data
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Raw()
* index() {
* return 'string';
* }
*
* @Get('/test')
* test() {
* return Result([ new Raw() ], new Buffer('buffer'));
* }
* }
* ```
*/
(): any;
new (): Raw;
}
/**
* Type of Raw metadata
*/
export interface Raw extends ApplicableAnnotation {
}
export declare const Raw: RawDecorator;
/**
* Type of Text decorator
*/
export interface TextDecorator {
/**
* Defines controller handler to return text
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @Text()
* index() {
* return null;
* }
*
* @Get('/test')
* test() {
* return Result([ new Text() ], null); // throw an error
* }
* }
* ```
*/
(): any;
new (): Text;
}
/**
* Type of Text metadata
*/
export interface Text extends ApplicableAnnotation {
}
export declare const Text: TextDecorator;
/**
* Type of OnUndefined decorator
*/
export interface OnUndefinedDecorator {
/**
* Defines what to do on `undefined` return value
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @OnUndefined(404)
* index() {
* }
*
* @Get('/test')
* test() {
* return Result([ new OnUndefined(new NotFoundError()) ]);
* }
* }
* ```
*/
(statusOrError: number | HttpError): any;
new (statusOrError: number | HttpError): OnUndefined;
}
/**
* Type of OnUndefined metadata
*/
export interface OnUndefined extends ApplicableAnnotation {

@@ -164,6 +526,31 @@ statusOrError: number | HttpError;

export declare const OnUndefined: OnUndefinedDecorator;
/**
* Type of OnNull decorator
*/
export interface OnNullDecorator {
/**
* Defines what to do on `null` return value
* @example
* ```
* @Controller()
* export class TestController {
* @Get('/')
* @OnUndefined(404)
* index() {
* return null
* }
*
* @Get('/test')
* test() {
* return Result([ new OnUndefined(new NotFoundError()) ], null);
* }
* }
* ```
*/
(statusOrError: number | HttpError): any;
new (statusOrError: number | HttpError): OnNull;
}
/**
* Type of OnNull metadata
*/
export interface OnNull extends ApplicableAnnotation {

@@ -170,0 +557,0 @@ statusOrError: number | HttpError;

@@ -33,11 +33,11 @@ "use strict";

exports.AbstractMethod = AbstractMethod;
exports.MethodFactory = function (method) { return function (path) { return ({ method: method, path: path }); }; };
exports.All = annotations_1.Annotator.makePropDecorator('All', exports.MethodFactory('all'), AbstractMethod);
exports.Get = annotations_1.Annotator.makePropDecorator('Get', exports.MethodFactory('get'), AbstractMethod);
exports.Post = annotations_1.Annotator.makePropDecorator('Post', exports.MethodFactory('post'), AbstractMethod);
exports.Put = annotations_1.Annotator.makePropDecorator('Put', exports.MethodFactory('put'), AbstractMethod);
exports.Delete = annotations_1.Annotator.makePropDecorator('Delete', exports.MethodFactory('delete'), AbstractMethod);
exports.Patch = annotations_1.Annotator.makePropDecorator('Patch', exports.MethodFactory('patch'), AbstractMethod);
exports.Options = annotations_1.Annotator.makePropDecorator('Options', exports.MethodFactory('options'), AbstractMethod);
exports.Head = annotations_1.Annotator.makePropDecorator('Head', exports.MethodFactory('head'), AbstractMethod);
var MethodFactory = function (method) { return function (path) { return ({ method: method, path: path }); }; };
exports.All = annotations_1.Annotator.makePropDecorator('All', MethodFactory('all'), AbstractMethod);
exports.Get = annotations_1.Annotator.makePropDecorator('Get', MethodFactory('get'), AbstractMethod);
exports.Post = annotations_1.Annotator.makePropDecorator('Post', MethodFactory('post'), AbstractMethod);
exports.Put = annotations_1.Annotator.makePropDecorator('Put', MethodFactory('put'), AbstractMethod);
exports.Delete = annotations_1.Annotator.makePropDecorator('Delete', MethodFactory('delete'), AbstractMethod);
exports.Patch = annotations_1.Annotator.makePropDecorator('Patch', MethodFactory('patch'), AbstractMethod);
exports.Options = annotations_1.Annotator.makePropDecorator('Options', MethodFactory('options'), AbstractMethod);
exports.Head = annotations_1.Annotator.makePropDecorator('Head', MethodFactory('head'), AbstractMethod);
var ApplicableAnnotation = /** @class */ (function () {

@@ -44,0 +44,0 @@ function ApplicableAnnotation() {

/// <reference types="express" />
import { Type } from '../utils/annotations';
import { RequestHandler } from 'express';
/**
* Type of Middleware decorator
*/
export interface MiddlewareDecorator {
/**
* Defines a class as middleware and should implement {@link IMiddleware}
* @example
* ```
*
* @Middleware()
* export class TestMiddleware implements IMiddleware {
* use(request : Request, response : Response, next : NextFunction) : any {
* console.log('Test middleware...');
* next();
* }
* }
* ```
*/
(): any;
new (): Middleware;
}
/**
* Type of Middleware metadata
* @see {@link MiddlewareDecorator}
*/
export interface Middleware {

@@ -14,6 +35,27 @@ }

}
/**
* Type of Use decorator
*/
export interface UseDecorator {
/**
* Defines a middleware to use for controller handler
* @example
* ```
*
* @Controller()
* export class TestController {
* @Get('/')
* @Use(TestMiddleware)
* index() {
* }
* }
* ```
*/
(middleware: Type<any> | RequestHandler, options?: IUseOptions): any;
new (middleware: Type<any> | RequestHandler, options?: IUseOptions): Use;
}
/**
* Type of Use metadata
* @see {@link UseDecorator}
*/
export interface Use {

@@ -20,0 +62,0 @@ middleware: Type<any> | RequestHandler;

@@ -5,2 +5,5 @@ /// <reference types="express" />

import { Router } from 'express';
/**
* Type of NemModule decorator
*/
export interface NemModuleDecorator {

@@ -10,2 +13,6 @@ (obj?: NemModule): TypeDecorator;

}
/**
* Type of NemModule metadata
* @see {@link NemModuleDecorator}
*/
export interface NemModule {

@@ -20,2 +27,20 @@ modules?: ([string | RegExp, Type<any> | NemModuleWithProviders] | Type<any> | NemModuleWithProviders)[];

export declare const NemModule: NemModuleDecorator;
/**
* Type of module factory return value
* @example
* ```
*
* @NemModule()
* export class TestModule {
* static forValue(value : any) {
* return {
* nemModule: TestModule,
* providers: [
* { provide: 'VALUE', useValue: value }
* ]
* }
* }
* }
* ```
*/
export interface NemModuleWithProviders {

@@ -22,0 +47,0 @@ nemModule: Type<any>;

/// <reference types="node" />
import { Request } from 'express';
export interface Resolver {
export declare abstract class AbstractParam {
resolve: (options: this, req: Request) => any;
}
export declare abstract class AbstractParam implements Resolver {
abstract resolve: (options: this, req: Request) => any;
parse?: (arg: any, options: this, req: Request) => any;

@@ -19,22 +16,82 @@ required?: boolean;

}
/**
* Type of QueryParam decorator
*/
export interface QueryParamDecorator {
/**
* Injects a query parameter into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@QueryParam('param') param : string) {
* // param is "foobar" for url "/?param=foobar"
* }
* }
* ```
*/
(paramName: string, options?: ParamOptions): any;
new (paramName: string, options?: ParamOptions): QueryParam;
}
export interface QueryParam extends AbstractParam, ParamOptions, Resolver {
/**
* Type of QueryParam metadata
* @see {@link QueryParamDecorator}
*/
export interface QueryParam extends AbstractParam, ParamOptions {
paramName: string;
}
export declare const QueryParam: QueryParamDecorator;
/**
* Type of QueryParams decorator
*/
export interface QueryParamsDecorator {
/**
* Injects all query parameters as object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@QueryParams() params : object) {
* // params is `{ param: "foobar" }` for url "/?param=foobar"
* }
* }
* ```
*/
(options?: ParamsOptions): any;
new (options?: ParamsOptions): QueryParams;
}
export interface QueryParams extends AbstractParam, ParamsOptions, Resolver {
/**
* Type of QueryParams metadata
* @see {@link QueryParamsDecorator}
*/
export interface QueryParams extends AbstractParam, ParamsOptions {
}
export declare const QueryParams: QueryParamsDecorator;
/**
* Type of Param decorator
*/
export interface ParamDecorator {
/**
* Injects a path parameter into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/:id')
* index(@Param('id') id : string) {
* // id is "foobar" for url "/foobar"
* }
* }
* ```
*/
(paramName: string, options?: ParamOptions): any;
new (paramName: string, options?: ParamOptions): Param;
}
export interface Param extends AbstractParam, ParamOptions, Resolver {
/**
* Type of the Param metadata
* @see {@link ParamDecorator}
*/
export interface Param extends AbstractParam, ParamOptions {
paramName: string;

@@ -44,13 +101,51 @@ }

export interface ParamsDecorator {
/**
* Injects all path parameters as object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/:arg0/:arg1')
* index(@Params() params : object) {
* // params is `{ arg0: "foo", arg1: "bar" }` for url "/foo/bar"
* }
* }
* ```
*/
(options?: ParamsOptions): any;
new (options?: ParamsOptions): Params;
}
export interface Params extends AbstractParam, ParamsOptions, Resolver {
/**
* Type of the Params metadata
* @see {@link ParamsDecorator}
*/
export interface Params extends AbstractParam, ParamsOptions {
}
export declare const Params: ParamsDecorator;
/**
* Type of the BodyParam decorator
*/
export interface BodyParamDecorator {
/**
* Injects a body parameter into controller handler
* Requires an express body-parser
* @example
* ```
*
* class ExampleController {
* @Post('/')
* index(@BodyParam('id') id : string) {
* // id is "foobar" for post body '{"id":"foobar"}'
* }
* }
* ```
*/
(paramName: string, options?: ParamOptions): any;
new (paramName: string, options?: ParamOptions): BodyParam;
}
export interface BodyParam extends AbstractParam, ParamOptions, Resolver {
/**
* Type of the BodyParam metadata
* @see {@link BodyParamDecorator}
*/
export interface BodyParam extends AbstractParam, ParamOptions {
paramName: string;

@@ -64,59 +159,215 @@ }

}
/**
* Type of the Body decorator
*/
export interface BodyDecorator {
/**
* Injects the complete body as object, string or Buffer depends on the body-parser middleware
* Requires an express body-parser
* @example
* ```
*
* class ExampleController {
* @Post('/:arg0/:arg1')
* index(@Body() params : object) {
* // params is `{ id: "foobar" }` for post body "{"id":"foobar"}"
* }
* }
* ```
*/
(options?: BodyOptions): any;
new (options?: BodyOptions): Body;
}
export interface Body extends AbstractParam, BodyOptions, Resolver {
/**
* Type of the Body metadata
* @see {@link BodyDecorator}
*/
export interface Body extends AbstractParam, BodyOptions {
}
export declare const Body: BodyDecorator;
/**
* Type of the HeaderParam decorator
*/
export interface HeaderParamDecorator {
/**
* Injects a header parameter into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@HeaderParam('if-none-match') etag: string) {
* // etag contains the given 'If-None-Match' header
* }
* }
* ```
*/
(headerName: string, options?: ParamOptions): any;
new (headerName: string, options?: ParamOptions): HeaderParam;
}
export interface HeaderParam extends AbstractParam, ParamOptions, Resolver {
/**
* Type of the HeaderParam metadata
* @see {@link HeaderParamDecorator}
*/
export interface HeaderParam extends AbstractParam, ParamOptions {
headerName: string;
}
export declare const HeaderParam: HeaderParamDecorator;
/**
* Type of the Headers decorator
*/
export interface HeadersDecorator {
/**
* Injects all header parameters as object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@Headers() headers: IncomingHttpHeaders) {
* // headers contains all request headers
* }
* }
* ```
*/
(options?: ParamOptions): any;
new (options?: ParamOptions): Headers;
}
export interface Headers extends AbstractParam, ParamsOptions, Resolver {
/**
* Type of the Headers metadata
* @see {@link HeadersDecorator}
*/
export interface Headers extends AbstractParam, ParamsOptions {
}
export declare const Headers: HeadersDecorator;
/**
* Type of the SessionParam decorator
*/
export interface SessionParamDecorator {
/**
* Injects a session parameter into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@SessionParam('foobar') foobar: string) {
* }
* }
* ```
*/
(paramName: string, options?: ParamOptions): any;
new (paramName: string, options?: ParamOptions): SessionParam;
}
export interface SessionParam extends AbstractParam, ParamOptions, Resolver {
/**
* Type of the SessionParam metadata
* @see {@link SessionParamDecorator}
*/
export interface SessionParam extends AbstractParam, ParamOptions {
paramName: string;
}
export declare const SessionParam: SessionParamDecorator;
/**
* Type of the Session decorator
*/
export interface SessionDecorator {
/**
* Injects the session object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@Session() session: Express.Session) {
* }
* }
* ```
*/
(options?: ParamOptions): any;
new (options?: ParamOptions): Session;
}
export interface Session extends AbstractParam, ParamsOptions, Resolver {
/**
* Type of the Session metadata
* @see {@link SessionDecorator}
*/
export interface Session extends AbstractParam, ParamsOptions {
}
export declare const Session: SessionDecorator;
/**
* Type of the SessionId decorator
*/
export interface SessionIdDecorator {
/**
* Injects the session id into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@SessionId() sessId: string) {
* }
* }
* ```
*/
(): any;
new (): Session;
}
export interface SessionId extends AbstractParam, Resolver {
/**
* Type of the SessionId metadata
* @see {@link SessionIdDecorator}
*/
export interface SessionId extends AbstractParam {
}
export declare const SessionId: SessionIdDecorator;
/**
* Type of the Req decorator
*/
export interface ReqDecorator {
/**
* Injects the express request object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@Req() req : Express.Request) {
* }
* }
* ```
*/
(): any;
new (): Req;
}
export interface Req extends AbstractParam, Resolver {
/**
* Type of the Req metadata
* @see {@link ReqDecorator}
*/
export interface Req extends AbstractParam {
}
export declare const Req: ReqDecorator;
/**
* Type of the Res decorator
*/
export interface ResDecorator {
/**
* Injects the express response object into controller handler
* @example
* ```
*
* class ExampleController {
* @Get('/')
* index(@Res() req : Express.Response) {
* }
* }
* ```
*/
(): any;
new (): Res;
}
export interface Res extends AbstractParam, Resolver {
/**
* Type of the Res metadata
* @see {@link ResDecorator}
*/
export interface Res extends AbstractParam {
}
export declare const Res: ResDecorator;
import { ApplicableAnnotation } from './controller';
/**
* @see {@link Result}
*/
export interface ResultCtor<T> {

@@ -7,2 +10,33 @@ ensure<T>(arg: Result<T> | T): Result<T>;

}
/**
* To return metadata and a result from a controller
* @example
* ```
*
* @Controller()
* export class ExampleController {
*
* @Get('/')
* index() {
* return Result([
* new Header('ETag', '"foobar"'),
* new Json()
* ], { foo: 'bar' });
* }
* }
*
* // equivalent to
*
* @Controller()
* export class ExampleController {
*
* @Get('/')
* @Header('ETag', '"foobar"')
* @Json()
* index() {
* return { foo: 'bar' };
* }
* }
* ```
*/
export interface Result<T> {

@@ -9,0 +43,0 @@ readonly args: ApplicableAnnotation[];

@@ -5,2 +5,16 @@ /// <reference types="express" />

import { Provider } from '@neoskop/injector';
/**
* Provide a middleware for a controller
*
* @example
* ```
*
* @Controller({
* providers: [
* middleware(ExampleMiddleware)
* ]
* })
* export class ExampleController {}
* ```
*/
export declare function middleware(middleware: Type<any> | RequestHandler, placement?: 'before' | 'after'): Provider;

@@ -6,2 +6,16 @@ "use strict";

var middleware_1 = require("../metadata/middleware");
/**
* Provide a middleware for a controller
*
* @example
* ```
*
* @Controller({
* providers: [
* middleware(ExampleMiddleware)
* ]
* })
* export class ExampleController {}
* ```
*/
function middleware(middleware, placement) {

@@ -8,0 +22,0 @@ if (placement === void 0) { placement = 'before'; }

import { Provider } from '@neoskop/injector';
/**
* Provide an additional view directory
* @usage
* ```
*
* nem({
* providers: [
* viewDirectory('./views')
* ]
* }).bootstrap(ExampleModule).listen(8000);
*
*
* @NemModule({
* rootProviders: [
* viewDirectory('./views/example')
* ]
* })
* export class ExampleModule {}
* ```
*/
export declare function viewDirectory(dir: string): Provider;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tokens_1 = require("../tokens");
/**
* Provide an additional view directory
* @usage
* ```
*
* nem({
* providers: [
* viewDirectory('./views')
* ]
* }).bootstrap(ExampleModule).listen(8000);
*
*
* @NemModule({
* rootProviders: [
* viewDirectory('./views/example')
* ]
* })
* export class ExampleModule {}
* ```
*/
function viewDirectory(dir) {

@@ -5,0 +25,0 @@ return { provide: tokens_1.VIEWS, useValue: dir, multi: true };

import { Provider } from '@neoskop/injector';
/**
* Provide an view prefix
* @usage
* ```
*
* @NemModule({
* providers: [
* viewPrefix('example-')
* ]
* })
* export class ExampleModule {}
*
* @Controller({
* providers: [
* viewPrefix('example-')
* ]
* })
* export class ExampleController {
* @Get('/')
* @View('index')
* index() { // renders template `example-index`
* return {}
* }
* }
* ```
*/
export declare function viewPrefix(prefix: string): Provider;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tokens_1 = require("../tokens");
/**
* Provide an view prefix
* @usage
* ```
*
* @NemModule({
* providers: [
* viewPrefix('example-')
* ]
* })
* export class ExampleModule {}
*
* @Controller({
* providers: [
* viewPrefix('example-')
* ]
* })
* export class ExampleController {
* @Get('/')
* @View('index')
* index() { // renders template `example-index`
* return {}
* }
* }
* ```
*/
function viewPrefix(prefix) {

@@ -5,0 +31,0 @@ return { provide: tokens_1.VIEW_PREFIX, useValue: prefix };

@@ -8,14 +8,62 @@ /// <reference types="express" />

import { Server } from 'http';
/**
* Provides an array of path parts to current controller/module
*/
export declare const BASE_PATHS: InjectionToken<(string | RegExp)[]>;
/**
* Provides the default error handler
* @see {@link defaultErrorHandler}
*/
export declare const ERROR_HANDLER: InjectionToken<ErrorRequestHandler>;
export declare const VIEWS: InjectionToken<string | string[]>;
/**
* Provides an array of view directories
*/
export declare const VIEWS: InjectionToken<string[]>;
/**
* Provides the name of the default view engine
*/
export declare const VIEW_ENGINE: InjectionToken<string>;
/**
* Provides a end handler for the current request
*
* @internal
* @hidden
* @see {@link ApplicableAnnotation}
*/
export declare const DEFAULT_END_HANDLER: InjectionToken<ApplicableAnnotation>;
/**
* Provides a path prefix for the views in the current module/controller
*/
export declare const VIEW_PREFIX: InjectionToken<string | undefined>;
/**
* Provides the middleware to invoke before to controller action handler
*/
export declare const MIDDLEWARE_BEFORE: InjectionToken<(IMiddleware | RequestHandler)[]>;
/**
* Provides the middleware to invoke after to controller action handler
*/
export declare const MIDDLEWARE_AFTER: InjectionToken<(IMiddleware | RequestHandler)[]>;
/**
* Provides the express Application
*/
export declare const APP: InjectionToken<Application>;
/**
* Provides the http server
*/
export declare const SERVER: InjectionToken<Server>;
/**
* Provides an array of functions to call before the root module is created
*/
export declare const BOOTSTRAP_LISTENER_BEFORE: InjectionToken<Function[]>;
/**
* Provides an array of functions to call after the root module is created
*/
export declare const BOOTSTRAP_LISTENER_AFTER: InjectionToken<Function[]>;
/**
* Defines the injection tokens to copy to child provider
* Useful for multi providers
*
* @internal
* @hidden
*/
export declare const MULTI_TOKENS_FROM_PARENT: InjectionToken<(string | RegExp)[]>[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var injector_1 = require("@neoskop/injector");
/**
* Provides an array of path parts to current controller/module
*/
exports.BASE_PATHS = new injector_1.InjectionToken('BasePaths');
/**
* Provides the default error handler
* @see {@link defaultErrorHandler}
*/
exports.ERROR_HANDLER = new injector_1.InjectionToken('ErrorHandler');
/**
* Provides an array of view directories
*/
exports.VIEWS = new injector_1.InjectionToken('Views');
/**
* Provides the name of the default view engine
*/
exports.VIEW_ENGINE = new injector_1.InjectionToken('View Engine');
/**
* Provides a end handler for the current request
*
* @internal
* @hidden
* @see {@link ApplicableAnnotation}
*/
exports.DEFAULT_END_HANDLER = new injector_1.InjectionToken('Default End Handler');
/**
* Provides a path prefix for the views in the current module/controller
*/
exports.VIEW_PREFIX = new injector_1.InjectionToken('View Prefix');
/**
* Provides the middleware to invoke before to controller action handler
*/
exports.MIDDLEWARE_BEFORE = new injector_1.InjectionToken('Middleware Before');
/**
* Provides the middleware to invoke after to controller action handler
*/
exports.MIDDLEWARE_AFTER = new injector_1.InjectionToken('Middleware After');
/**
* Provides the express Application
*/
exports.APP = new injector_1.InjectionToken('Express Application');
/**
* Provides the http server
*/
exports.SERVER = new injector_1.InjectionToken('Http Server');
/**
* Provides an array of functions to call before the root module is created
*/
exports.BOOTSTRAP_LISTENER_BEFORE = new injector_1.InjectionToken('Bootstrap Listener Before');
/**
* Provides an array of functions to call after the root module is created
*/
exports.BOOTSTRAP_LISTENER_AFTER = new injector_1.InjectionToken('Bootstrap Listener After');
/**
* Defines the injection tokens to copy to child provider
* Useful for multi providers
*
* @internal
* @hidden
*/
exports.MULTI_TOKENS_FROM_PARENT = [
exports.BASE_PATHS,
exports.VIEWS,
exports.BOOTSTRAP_LISTENER_BEFORE,

@@ -19,0 +68,0 @@ exports.BOOTSTRAP_LISTENER_AFTER

"use strict";
/*
/**
* Inspired and copied from @angular/core

@@ -10,6 +10,22 @@ * @see https://github.com/angular/angular/blob/master/packages/core/src/util/decorators.ts

var tslib_1 = require("tslib");
exports.ANNOTATIONS = '__ANNOTATIONS__';
exports.PROPS = '__PROPS__';
exports.CTOR_PARAMS = '__CTOR_PARAMS__';
exports.PARAMS = '__PARAMS__';
/**
* @internal
* @hidden
*/
var ANNOTATIONS = '__ANNOTATIONS__';
/**
* @internal
* @hidden
*/
var PROPS = '__PROPS__';
/**
* @internal
* @hidden
*/
var CTOR_PARAMS = '__CTOR_PARAMS__';
/**
* @internal
* @hidden
*/
var PARAMS = '__PARAMS__';
var Annotator = /** @class */ (function () {

@@ -19,15 +35,15 @@ function Annotator() {

Annotator.getCtorAnnotations = function (cls) {
return cls[exports.ANNOTATIONS] || [];
return cls[ANNOTATIONS] || [];
};
Annotator.getPropAnnotations = function (cls, prop) {
if (prop) {
return (cls[exports.PROPS] && cls[exports.PROPS][prop] || []);
return (cls[PROPS] && cls[PROPS][prop] || []);
}
return cls[exports.PROPS] || {};
return cls[PROPS] || {};
};
Annotator.getCtorParamAnnotations = function (cls) {
return cls[exports.CTOR_PARAMS] || [];
return cls[CTOR_PARAMS] || [];
};
Annotator.getParamAnnotations = function (cls, prop) {
return (cls[exports.PARAMS] && cls[exports.PARAMS][prop] || []);
return (cls[PARAMS] && cls[PARAMS][prop] || []);
};

@@ -43,5 +59,5 @@ Annotator.makeCtorDecorator = function (name, props, parentClass) {

var TypeDecorator = function TypeDecorator(cls) {
var annotations = cls.hasOwnProperty(exports.ANNOTATIONS) ?
cls[exports.ANNOTATIONS] :
Object.defineProperty(cls, exports.ANNOTATIONS, { value: [] })[exports.ANNOTATIONS];
var annotations = cls.hasOwnProperty(ANNOTATIONS) ?
cls[ANNOTATIONS] :
Object.defineProperty(cls, ANNOTATIONS, { value: [] })[ANNOTATIONS];
annotations.push(instance);

@@ -76,5 +92,5 @@ return cls;

var instance = new ((_a = PropDecoratorFactory).bind.apply(_a, tslib_1.__spread([void 0], args)))();
var meta = constructor.hasOwnProperty(exports.PROPS) ?
constructor[exports.PROPS] :
Object.defineProperty(constructor, exports.PROPS, { value: {} })[exports.PROPS];
var meta = constructor.hasOwnProperty(PROPS) ?
constructor[PROPS] :
Object.defineProperty(constructor, PROPS, { value: {} })[PROPS];
meta[name] = meta.hasOwnProperty(name) && meta[name] || [];

@@ -110,5 +126,5 @@ meta[name].unshift(instance);

if (method) {
var parameters = cls.constructor.hasOwnProperty(exports.PARAMS) ?
cls.constructor[exports.PARAMS] :
Object.defineProperty(cls.constructor, exports.PARAMS, { value: {} })[exports.PARAMS];
var parameters = cls.constructor.hasOwnProperty(PARAMS) ?
cls.constructor[PARAMS] :
Object.defineProperty(cls.constructor, PARAMS, { value: {} })[PARAMS];
parameters[method] = parameters.hasOwnProperty(method) && parameters[method] || [];

@@ -121,5 +137,5 @@ while (parameters[method].length <= index) {

else {
var parameters = cls.hasOwnProperty(exports.CTOR_PARAMS) ?
cls[exports.CTOR_PARAMS] :
Object.defineProperty(cls, exports.CTOR_PARAMS, { value: [] })[exports.CTOR_PARAMS];
var parameters = cls.hasOwnProperty(CTOR_PARAMS) ?
cls[CTOR_PARAMS] :
Object.defineProperty(cls, CTOR_PARAMS, { value: [] })[CTOR_PARAMS];
while (parameters.length <= index) {

@@ -148,2 +164,6 @@ parameters.push(null);

exports.Annotator = Annotator;
/**
* @internal
* @hidden
*/
function makeMetadataCtor(props) {

@@ -150,0 +170,0 @@ return function ctor() {

import { Injector, Provider } from '@neoskop/injector';
/**
* @internal
* @hidden
*/
export declare function copyMultiProvider(tokens: any[], injector: Injector): Provider[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @internal
* @hidden
*/
function copyMultiProvider(tokens, injector) {

@@ -4,0 +8,0 @@ return tokens.map(function (token) {

{
"name": "@neoskop/nem",
"version": "0.1.1",
"version": "0.1.2",
"description": "Strucktured modules to build express apps",

@@ -5,0 +5,0 @@ "main": "lib/public_api.js",

@@ -54,2 +54,20 @@ # @neoskop/nem

### Dependency Injection
```
+-----------------------+
| rootProviders |
v |
+------------------------------+ +--------------------+ +---------------+ +-----------------+ +---------------------+
| Provided Injector (Optional) | --> | Bootstrap Injector | --> | Root Injector | --> | Module Injector | --> | Controller Injector |
+------------------------------+ +--------------------+ +---------------+ ^ +-----------------+ | +---------------------+
| |
| Nested Modules |
+-----------------------+
```
The bootstrap injector contains the required dependencies to bootstrap the app,
the root injector inherits from the bootstrap injector and contains all global depenendencies.
The module injectors inherits from the parent module injector or the root injector for the root module.
## Testing

@@ -56,0 +74,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc