@zerooneit/expressive-tea 1.3.0-beta.2 → 1.3.0-beta.3

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.
@@ -1,92 +0,0 @@
1
- /**
2
- * As Expressive Tea have some stages when is boot the application, this enum helps to attach plugin when use the Pour
3
- * or Plug decorations and this is the definition.
4
- *
5
- * <b>BOOT_DEPENDENCIES</b>: Used for some application dependencies, example, databases configuration or websocket settings.
6
- *
7
- * <b>INITIALIZE_MIDDLEWARES</b>: Used for application middlewares, example body-parser, cors, sessions express plugins.
8
- *
9
- * <b>APPLICATION</b>: Used internally to register all modules registered by Module decorator.
10
- *
11
- * <b>AFTER_APPLICATION_MIDDLEWARES</b>: Used to add middlewares after routers, commonly used for Error handling.
12
- *
13
- * <b>START</b>: This Stage is used to execute some code or attach middlewares before application starts and might be used to
14
- * settings something after plugins/middlewares registered.
15
- *
16
- * @inner
17
- * @export
18
- * @enum {number}
19
- * @summary Available Boot Stages
20
- */
21
- export declare enum BOOT_STAGES {
22
- BOOT_DEPENDENCIES = 0,
23
- INITIALIZE_MIDDLEWARES = 1,
24
- APPLICATION = 2,
25
- AFTER_APPLICATION_MIDDLEWARES = 3,
26
- START = 4,
27
- ON_HTTP_CREATION = 5
28
- }
29
- /**
30
- * This Determinate how the application is booting internally, this should not be modified unless you know what are you
31
- * doing, however, even that is the case should not be modified. The Order is the next one:
32
- *
33
- * <b><i>BOOT_DEPENDENCIES</i></b> --> <b><i>INITIALIZE_MIDDLEWARES</i></b> --> <b><i>APPLICATION</i></b> -->
34
- * <b><i>AFTER_APPLICATION_MIDDLEWARES</i></b> --> <b><i>START</i></b>
35
- * @inner
36
- * @type Array<BOOT_STAGES>
37
- * @constant
38
- * @summary Current Aplication Boot Order
39
- */
40
- export declare const BOOT_ORDER: BOOT_STAGES[];
41
- export declare const BOOT_STAGES_LIST: BOOT_STAGES[];
42
- export declare const STAGES_INIT: {
43
- 0: any[];
44
- 1: any[];
45
- 2: any[];
46
- 3: any[];
47
- 4: any[];
48
- };
49
- export declare const EXPRESS_DIRECTIVES: string[];
50
- export declare const BOOT_STAGES_KEY = "boot:stage-settings";
51
- export declare const ROUTER_HANDLERS_KEY = "app:routes:handlers";
52
- export declare const ROUTER_MIDDLEWARES_KEY = "app:routes:middlewares";
53
- export declare const ROUTER_PROXIES_KEY = "app:routes:proxies";
54
- export declare const PROXY_SETTING_KEY = "app:proxy:settings";
55
- export declare const REGISTERED_MODEL_KEY = "app:models:registered";
56
- export declare const REGISTERED_MODULE_KEY = "app:modules:registered";
57
- export declare const PLUGINS_KEY = "boot:app-plugins";
58
- export declare const REGISTERED_STATIC_KEY = "app:statics";
59
- export declare const REGISTERED_DIRECTIVES_KEY = "app:directives";
60
- export declare const ARGUMENTS_KEY = "app:routes:arguments";
61
- export declare const ROUTER_ANNOTATIONS_KEY = "app:routes:annotations";
62
- export declare const ASSIGN_TEAPOT_KEY = "app:gateway:teapot";
63
- export declare const ASSIGN_TEACUP_KEY = "app:gateway:teacup";
64
- export declare const ARGUMENT_TYPES: {
65
- BODY: symbol;
66
- GET_PARAM: symbol;
67
- NEXT: symbol;
68
- QUERY: symbol;
69
- REQUEST: symbol;
70
- RESPONSE: symbol;
71
- };
72
- export declare enum PROXY_METHODS {
73
- HOST = "host",
74
- PROXY_REQ_PATH_RESOLVER = "proxyReqPathResolver",
75
- FILTER = "filter",
76
- USER_RES_DECORATOR = "userResDecorator",
77
- USER_RES_HEADER_DECORATOR = "userResHeaderDecorator",
78
- SKIP_TO_NEXT_HANDLER_FILTER = "skipToNextHandlerFilter",
79
- PROXY_ERROR_HANDLER = "proxyErrorHandler",
80
- PROXY_REQ_OPT_DECORATOR = "proxyReqOptDecorator",
81
- PROXY_REQ_BODY_DECORATOR = "proxyReqBodyDecorator"
82
- }
83
- export declare enum PROXY_PROPERTIES {
84
- LIMIT = "limit",
85
- MEMOIZE_HOST = "memoizeHost",
86
- HTTPS = "https",
87
- PRESERVE_HOST_HDR = "preserveHostHdr",
88
- PARSE_REQ_BODY = "parseReqBody",
89
- REQ_AS_BUFFER = "reqAsBuffer",
90
- REQ_BODY_ENCODING = "reqBodyEncoding",
91
- TIMEOUT = "timeout"
92
- }
package/libs/constants.js DELETED
@@ -1,128 +0,0 @@
1
- "use strict";
2
- // tslint:disable:max-line-length
3
- /**
4
- * As Expressive Tea have some stages when is boot the application, this enum helps to attach plugin when use the Pour
5
- * or Plug decorations and this is the definition.
6
- *
7
- * <b>BOOT_DEPENDENCIES</b>: Used for some application dependencies, example, databases configuration or websocket settings.
8
- *
9
- * <b>INITIALIZE_MIDDLEWARES</b>: Used for application middlewares, example body-parser, cors, sessions express plugins.
10
- *
11
- * <b>APPLICATION</b>: Used internally to register all modules registered by Module decorator.
12
- *
13
- * <b>AFTER_APPLICATION_MIDDLEWARES</b>: Used to add middlewares after routers, commonly used for Error handling.
14
- *
15
- * <b>START</b>: This Stage is used to execute some code or attach middlewares before application starts and might be used to
16
- * settings something after plugins/middlewares registered.
17
- *
18
- * @inner
19
- * @export
20
- * @enum {number}
21
- * @summary Available Boot Stages
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.PROXY_PROPERTIES = exports.PROXY_METHODS = exports.ARGUMENT_TYPES = exports.ASSIGN_TEACUP_KEY = exports.ASSIGN_TEAPOT_KEY = exports.ROUTER_ANNOTATIONS_KEY = exports.ARGUMENTS_KEY = exports.REGISTERED_DIRECTIVES_KEY = exports.REGISTERED_STATIC_KEY = exports.PLUGINS_KEY = exports.REGISTERED_MODULE_KEY = exports.REGISTERED_MODEL_KEY = exports.PROXY_SETTING_KEY = exports.ROUTER_PROXIES_KEY = exports.ROUTER_MIDDLEWARES_KEY = exports.ROUTER_HANDLERS_KEY = exports.BOOT_STAGES_KEY = exports.EXPRESS_DIRECTIVES = exports.STAGES_INIT = exports.BOOT_STAGES_LIST = exports.BOOT_ORDER = exports.BOOT_STAGES = void 0;
25
- // tslint:enable:max-line-length
26
- var BOOT_STAGES;
27
- (function (BOOT_STAGES) {
28
- BOOT_STAGES[BOOT_STAGES["BOOT_DEPENDENCIES"] = 0] = "BOOT_DEPENDENCIES";
29
- BOOT_STAGES[BOOT_STAGES["INITIALIZE_MIDDLEWARES"] = 1] = "INITIALIZE_MIDDLEWARES";
30
- BOOT_STAGES[BOOT_STAGES["APPLICATION"] = 2] = "APPLICATION";
31
- BOOT_STAGES[BOOT_STAGES["AFTER_APPLICATION_MIDDLEWARES"] = 3] = "AFTER_APPLICATION_MIDDLEWARES";
32
- BOOT_STAGES[BOOT_STAGES["START"] = 4] = "START";
33
- BOOT_STAGES[BOOT_STAGES["ON_HTTP_CREATION"] = 5] = "ON_HTTP_CREATION";
34
- })(BOOT_STAGES = exports.BOOT_STAGES || (exports.BOOT_STAGES = {}));
35
- /**
36
- * This Determinate how the application is booting internally, this should not be modified unless you know what are you
37
- * doing, however, even that is the case should not be modified. The Order is the next one:
38
- *
39
- * <b><i>BOOT_DEPENDENCIES</i></b> --> <b><i>INITIALIZE_MIDDLEWARES</i></b> --> <b><i>APPLICATION</i></b> -->
40
- * <b><i>AFTER_APPLICATION_MIDDLEWARES</i></b> --> <b><i>START</i></b>
41
- * @inner
42
- * @type Array<BOOT_STAGES>
43
- * @constant
44
- * @summary Current Aplication Boot Order
45
- */
46
- exports.BOOT_ORDER = [
47
- BOOT_STAGES.BOOT_DEPENDENCIES,
48
- BOOT_STAGES.INITIALIZE_MIDDLEWARES,
49
- BOOT_STAGES.APPLICATION
50
- ];
51
- exports.BOOT_STAGES_LIST = [
52
- BOOT_STAGES.BOOT_DEPENDENCIES,
53
- BOOT_STAGES.INITIALIZE_MIDDLEWARES,
54
- BOOT_STAGES.APPLICATION,
55
- BOOT_STAGES.AFTER_APPLICATION_MIDDLEWARES,
56
- BOOT_STAGES.START
57
- ];
58
- exports.STAGES_INIT = {
59
- [BOOT_STAGES.BOOT_DEPENDENCIES]: [],
60
- [BOOT_STAGES.INITIALIZE_MIDDLEWARES]: [],
61
- [BOOT_STAGES.APPLICATION]: [],
62
- [BOOT_STAGES.AFTER_APPLICATION_MIDDLEWARES]: [],
63
- [BOOT_STAGES.START]: []
64
- };
65
- exports.EXPRESS_DIRECTIVES = [
66
- 'case sensitive routing',
67
- 'env',
68
- 'etag',
69
- 'jsonp callback name',
70
- 'json escape',
71
- 'json replacer',
72
- 'json spaces',
73
- 'query parser',
74
- 'strict routing',
75
- 'subdomain offset',
76
- 'trust proxy',
77
- 'views',
78
- 'view cache',
79
- 'view engine',
80
- 'x-powered-by'
81
- ];
82
- exports.BOOT_STAGES_KEY = 'boot:stage-settings';
83
- exports.ROUTER_HANDLERS_KEY = 'app:routes:handlers';
84
- exports.ROUTER_MIDDLEWARES_KEY = 'app:routes:middlewares';
85
- exports.ROUTER_PROXIES_KEY = 'app:routes:proxies';
86
- exports.PROXY_SETTING_KEY = 'app:proxy:settings';
87
- exports.REGISTERED_MODEL_KEY = 'app:models:registered';
88
- exports.REGISTERED_MODULE_KEY = 'app:modules:registered';
89
- exports.PLUGINS_KEY = 'boot:app-plugins';
90
- exports.REGISTERED_STATIC_KEY = 'app:statics';
91
- exports.REGISTERED_DIRECTIVES_KEY = 'app:directives';
92
- exports.ARGUMENTS_KEY = 'app:routes:arguments';
93
- exports.ROUTER_ANNOTATIONS_KEY = 'app:routes:annotations';
94
- exports.ASSIGN_TEAPOT_KEY = 'app:gateway:teapot';
95
- exports.ASSIGN_TEACUP_KEY = 'app:gateway:teacup';
96
- exports.ARGUMENT_TYPES = {
97
- BODY: Symbol('BODY'),
98
- GET_PARAM: Symbol('GET_PARAM'),
99
- NEXT: Symbol('NEXT'),
100
- QUERY: Symbol('QUERY'),
101
- REQUEST: Symbol('REQUEST'),
102
- RESPONSE: Symbol('RESPONSE')
103
- };
104
- var PROXY_METHODS;
105
- (function (PROXY_METHODS) {
106
- PROXY_METHODS["HOST"] = "host";
107
- PROXY_METHODS["PROXY_REQ_PATH_RESOLVER"] = "proxyReqPathResolver";
108
- PROXY_METHODS["FILTER"] = "filter";
109
- PROXY_METHODS["USER_RES_DECORATOR"] = "userResDecorator";
110
- PROXY_METHODS["USER_RES_HEADER_DECORATOR"] = "userResHeaderDecorator";
111
- PROXY_METHODS["SKIP_TO_NEXT_HANDLER_FILTER"] = "skipToNextHandlerFilter";
112
- PROXY_METHODS["PROXY_ERROR_HANDLER"] = "proxyErrorHandler";
113
- PROXY_METHODS["PROXY_REQ_OPT_DECORATOR"] = "proxyReqOptDecorator";
114
- PROXY_METHODS["PROXY_REQ_BODY_DECORATOR"] = "proxyReqBodyDecorator";
115
- })(PROXY_METHODS = exports.PROXY_METHODS || (exports.PROXY_METHODS = {}));
116
- // 'limit' | 'memoizeHost' | 'https' | 'preserveHostHdr' | 'parseReqBody' |
117
- // 'reqAsBuffer' | 'reqBodyEncoding' | 'timeout';
118
- var PROXY_PROPERTIES;
119
- (function (PROXY_PROPERTIES) {
120
- PROXY_PROPERTIES["LIMIT"] = "limit";
121
- PROXY_PROPERTIES["MEMOIZE_HOST"] = "memoizeHost";
122
- PROXY_PROPERTIES["HTTPS"] = "https";
123
- PROXY_PROPERTIES["PRESERVE_HOST_HDR"] = "preserveHostHdr";
124
- PROXY_PROPERTIES["PARSE_REQ_BODY"] = "parseReqBody";
125
- PROXY_PROPERTIES["REQ_AS_BUFFER"] = "reqAsBuffer";
126
- PROXY_PROPERTIES["REQ_BODY_ENCODING"] = "reqBodyEncoding";
127
- PROXY_PROPERTIES["TIMEOUT"] = "timeout";
128
- })(PROXY_PROPERTIES = exports.PROXY_PROPERTIES || (exports.PROXY_PROPERTIES = {}));
@@ -1,140 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Express, RequestHandler, Router } from 'express';
4
- import * as http from 'http';
5
- import * as https from 'https';
6
- import { ExpressiveTeaMiddleware, ExpressMiddlewareHandler } from './types';
7
- /**
8
- * Define the dynamic structure for an object and useful to provide a dynamic object type on the applications.
9
- * @typedef {Object} IDynamicObject
10
- * @summary Dynamic Object Definition
11
- */
12
- export interface IDynamicObject {
13
- [key: string]: any;
14
- }
15
- /**
16
- * Expressive Tea Application interface is the response from an started application, contains the express application
17
- * and a node http server instance.
18
- * @typedef {Object} ExpressiveTeaApplication
19
- * @property {Express} application Express Application Instance
20
- * @property {HTTPServer} server HTTP Server Object
21
- * @summary Application Interface
22
- */
23
- export interface ExpressiveTeaApplication {
24
- application: Express;
25
- server: http.Server;
26
- secureServer?: https.Server;
27
- }
28
- /**
29
- * Declare the properties which the server will save into settings, is a semi dynamic object since is allowed to save
30
- * any property but is contains only one defined property to keep the port of the server.
31
- * @typedef {Object} ExpressiveTeaServerProps
32
- * @property {number} [port] - Properties where server will be listen requests.
33
- * @summary Expressive Tea Server Properties
34
- */
35
- export interface ExpressiveTeaServerProps {
36
- port?: number;
37
- [key: string]: any;
38
- }
39
- /**
40
- * Define the Main Plugins Properties.
41
- * @typedef {Object} ExpressiveTeaPluginProps
42
- * @property {string} name - Define a Plugin Name
43
- * @property {number} priority - Define a Plugin Priority.
44
- * @summary Plugin Properties
45
- */
46
- export interface ExpressiveTeaPluginProps {
47
- name: string;
48
- priority: number;
49
- }
50
- export interface ExpressiveTeaPotSettings {
51
- serverKey: string;
52
- clientKey: string;
53
- port?: number;
54
- }
55
- export interface ExpressiveTeaCupSettings {
56
- address: string;
57
- clientKey: string;
58
- mountTo: string;
59
- serverUrl: string;
60
- }
61
- /**
62
- * Define Expressive Module Properties.
63
- * @typedef {Object} ExpressiveTeaModuleProps
64
- * @property {Object[]} controllers - Controllers Assigned to Module
65
- * @property {Object[]} providers -Dependency Injection Providers
66
- * @property {string} mountpoint - Endpoint part which Module it will use as root.
67
- * @summary
68
- */
69
- export interface ExpressiveTeaModuleProps {
70
- controllers: any[];
71
- providers?: any[];
72
- mountpoint: string;
73
- }
74
- export interface IExpressiveTeaModule {
75
- readonly settings: ExpressiveTeaModuleProps;
76
- readonly router: Router;
77
- readonly controllers: any[];
78
- __register(server: Express): void;
79
- }
80
- export interface IExpressiveTeaProxySettings {
81
- name: string;
82
- source: string;
83
- targetUrl: string;
84
- }
85
- export interface IExpressiveTeaProxy {
86
- readonly source: string;
87
- readonly target: string;
88
- readonly proxyHandler: RequestHandler;
89
- __register(server: Express): void;
90
- }
91
- export interface IExpressiveTeaRoute {
92
- readonly router: Router;
93
- readonly mountpoint: string;
94
- __mount(parent: Router): IExpressiveTeaRoute;
95
- __registerHandler(options: ExpressiveTeaHandlerOptions): ExpressMiddlewareHandler;
96
- }
97
- /**
98
- * @typedef {Object} ExpressiveTeaApplication
99
- * @property {Express} application Express Application Instance
100
- * @property {HTTPServer} server HTTP Server Object
101
- */
102
- export interface ExpressiveTeaStaticFileServer {
103
- dotfiles?: 'allow' | 'deny' | 'ignore';
104
- etag?: boolean;
105
- extensions?: string[];
106
- index?: boolean;
107
- maxAge?: string;
108
- redirect?: boolean;
109
- setHeaders?(res: any, path: any, stat: any): any;
110
- }
111
- export interface ExpressiveTeaStatic {
112
- root: string;
113
- virtual: string | null;
114
- options: ExpressiveTeaStaticFileServer | never;
115
- }
116
- export interface ExpressiveTeaDirective {
117
- name: string;
118
- settings: any[];
119
- }
120
- export interface ExpressiveTeaHandlerOptions {
121
- verb: string;
122
- route: string;
123
- handler: ExpressiveTeaMiddleware & ExpressiveTeaMiddlewareExtends;
124
- target: unknown;
125
- propertyKey: string | symbol;
126
- settings?: any;
127
- }
128
- export interface ExpressiveTeaArgumentOptions {
129
- key: string | symbol;
130
- index: number;
131
- type: symbol;
132
- arguments?: string | string[];
133
- }
134
- export interface ExpressiveTeaAnnotations {
135
- type: string;
136
- arguments?: any[];
137
- }
138
- export interface ExpressiveTeaMiddlewareExtends {
139
- $middlewares?: ExpressMiddlewareHandler[];
140
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/libs/types.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { NextFunction, Request, Response } from 'express';
2
- export declare type Resolvable<R> = R | PromiseLike<R>;
3
- export declare type Resolver<R> = (thenableOrResult?: Resolvable<R>) => void;
4
- export declare type Rejector = (error?: any) => void;
5
- export declare type ExpressiveTeaModuleClass<T> = new (...args: any[]) => T;
6
- export declare type ExpressiveTeaRouteClass<T> = new (...args: any[]) => T;
7
- export declare type ExpressMiddlewareHandler = (request?: Request, response?: Response, next?: NextFunction) => void;
8
- export declare type ExpressiveTeaMiddleware = (...args: unknown[]) => unknown | Promise<unknown>;
9
- export declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
10
- export declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
11
- export declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor | void;
12
- export declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
13
- export declare type ExpressiveTeaProxyOptions = 'proxyReqPathResolver' | 'host' | 'filter' | 'userResDecorator' | 'userResHeaderDecorator' | 'skipToNextHandlerFilter' | 'proxyErrorHandler' | 'proxyReqOptDecorator' | 'proxyReqBodyDecorator';
14
- export declare type ExpressiveTeaProxyProperty = 'limit' | 'memoizeHost' | 'https' | 'preserveHostHdr' | 'parseReqBody' | 'reqAsBuffer' | 'reqBodyEncoding' | 'timeout';
package/libs/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });