kamboja-core
Advanced tools
Comparing version 0.3.2 to 0.4.0-alpha.31575027
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
import "reflect-metadata"; | ||
export declare type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; | ||
export declare type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "EVENT"; | ||
export declare type TransformStatus = "ExitWithResult" | "Next" | "Exit"; | ||
@@ -17,2 +17,3 @@ export declare type TransformerName = "DefaultAction" | "IndexAction" | "HttpMethodDecorator" | "ApiConvention" | "InternalDecorator" | "Controller" | "ControllerWithDecorator" | "Module"; | ||
internal(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; | ||
type(typ: string): (...target: any[]) => void; | ||
} | ||
@@ -26,2 +27,3 @@ export declare class HttpDecorator { | ||
delete(route?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; | ||
event(route: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; | ||
} | ||
@@ -61,2 +63,4 @@ export declare class BinderDecorator { | ||
const DuplicateParameterName = 9; | ||
const QueryParameterNotAllowed = 10; | ||
const DecoratorNotAllowed = 11; | ||
} | ||
@@ -119,2 +123,3 @@ export interface AnalysisMessage { | ||
autoValidation?: boolean; | ||
authUserStore?: AuthUserStore; | ||
routeInfos?: RouteInfo[]; | ||
@@ -129,2 +134,5 @@ facilities?: Facility[]; | ||
showLog?: LogType; | ||
socketEngine?: Engine; | ||
socketApp?: any; | ||
httpApp?: any; | ||
} | ||
@@ -148,7 +156,30 @@ export interface MetaDataStorage { | ||
} | ||
export interface SocketRegistry { | ||
register(id: string, alias: string): Promise<void>; | ||
lookup(alias: string): Promise<string>; | ||
} | ||
export interface BaseController { | ||
request: HttpRequest; | ||
validator: Validator; | ||
} | ||
export interface AuthUserStore { | ||
save(user: AuthUser): Promise<void>; | ||
get(id: string): Promise<AuthUser>; | ||
} | ||
export interface AuthUser { | ||
readonly id: string; | ||
} | ||
export interface Handshake { | ||
contextType: "Handshake"; | ||
headers: any; | ||
id: string; | ||
rooms: string[]; | ||
user: AuthUser; | ||
params: { | ||
[key: string]: string; | ||
}; | ||
getHeader(key: string): string | undefined; | ||
getParam(key: string): string | undefined; | ||
} | ||
export interface HttpRequest { | ||
contextType: "HttpRequest"; | ||
httpVersion: string; | ||
@@ -165,3 +196,3 @@ httpMethod: HttpMethod; | ||
}; | ||
user: any; | ||
user: AuthUser; | ||
body: any; | ||
@@ -198,11 +229,14 @@ referrer: string; | ||
} | ||
export interface HttpResponse { | ||
export interface Response { | ||
send(result: ResponseResult): void; | ||
} | ||
export interface ResponseResult { | ||
body: any; | ||
type: string; | ||
status: number; | ||
header: { | ||
status?: number; | ||
type?: string; | ||
header?: { | ||
[key: string]: string | string[]; | ||
}; | ||
cookies: Cookie[]; | ||
send(): void; | ||
cookies?: Cookie[]; | ||
events?: SocketEvent[]; | ||
} | ||
@@ -213,4 +247,4 @@ export declare class HttpError { | ||
request: HttpRequest; | ||
response: HttpResponse; | ||
constructor(status: number, error: any, request: HttpRequest, response: HttpResponse); | ||
response: Response; | ||
constructor(status: number, error: any, request: HttpRequest, response: Response); | ||
} | ||
@@ -220,7 +254,7 @@ export declare abstract class Invocation { | ||
parameters: any[]; | ||
controllerInfo?: ControllerInfo; | ||
controllerInfo?: RouteInfo; | ||
middlewares?: Middleware[]; | ||
} | ||
export interface Middleware { | ||
execute(request: HttpRequest, next: Invocation): any; | ||
execute(context: Handshake | HttpRequest, next: Invocation): Promise<ActionResult>; | ||
} | ||
@@ -247,3 +281,9 @@ export interface Facility { | ||
} | ||
export declare class ActionResult { | ||
export interface SocketEvent { | ||
type: "Broadcast" | "Private" | "Room"; | ||
name: string; | ||
id?: string | string[]; | ||
payload?: any; | ||
} | ||
export declare class ActionResult implements ResponseResult { | ||
body: any; | ||
@@ -256,4 +296,6 @@ status: number | undefined; | ||
cookies?: Cookie[]; | ||
events?: SocketEvent[]; | ||
constructor(body: any, status?: number | undefined, type?: string | undefined); | ||
execute(request: HttpRequest, response: HttpResponse, routeInfo?: RouteInfo): Promise<void>; | ||
emit(event: SocketEvent): this; | ||
execute(context: HttpRequest | Handshake, response: Response, routeInfo?: RouteInfo): Promise<void>; | ||
} | ||
@@ -260,0 +302,0 @@ export declare function getRouteDetail(info: RouteInfo): string; |
@@ -10,2 +10,8 @@ "use strict"; | ||
Decorator.prototype.internal = function () { return function (target, propertyKey, descriptor) { }; }; | ||
Decorator.prototype.type = function (typ) { return function () { | ||
var target = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
target[_i] = arguments[_i]; | ||
} | ||
}; }; | ||
return Decorator; | ||
@@ -23,2 +29,3 @@ }()); | ||
HttpDecorator.prototype.delete = function (route) { return function (target, propertyKey, descriptor) { }; }; | ||
HttpDecorator.prototype.event = function (route) { return function (target, propertyKey, descriptor) { }; }; | ||
return HttpDecorator; | ||
@@ -64,2 +71,4 @@ }()); | ||
RouteAnalysisCode.DuplicateParameterName = 9; | ||
RouteAnalysisCode.QueryParameterNotAllowed = 10; | ||
RouteAnalysisCode.DecoratorNotAllowed = 11; | ||
})(RouteAnalysisCode = exports.RouteAnalysisCode || (exports.RouteAnalysisCode = {})); | ||
@@ -97,11 +106,12 @@ /** | ||
} | ||
ActionResult.prototype.execute = function (request, response, routeInfo) { | ||
ActionResult.prototype.emit = function (event) { | ||
if (!this.events) | ||
this.events = []; | ||
this.events.push(event); | ||
return this; | ||
}; | ||
ActionResult.prototype.execute = function (context, response, routeInfo) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
response.body = this.body; | ||
response.cookies = this.cookies || []; | ||
response.status = this.status || 200; | ||
response.type = this.type || "text/plain"; | ||
response.header = this.header; | ||
response.send(); | ||
response.send(this); | ||
return [2 /*return*/]; | ||
@@ -108,0 +118,0 @@ }); |
{ | ||
"name": "kamboja-core", | ||
"version": "0.3.2", | ||
"version": "0.4.0-alpha.31575027", | ||
"description": "Core library of KambojaJS", | ||
@@ -24,3 +24,3 @@ "main": "lib/index.js", | ||
"@types/node": "^8.0.1", | ||
"kecubung": "^0.3.2", | ||
"kecubung": "0.4.0-alpha.31575027", | ||
"lodash": "^4.17.4", | ||
@@ -27,0 +27,0 @@ "reflect-metadata": "^0.1.10", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19972
459
0
+ Addedkecubung@0.4.0-alpha.31575027(transitive)
- Removedkecubung@0.3.2(transitive)