Skip to content

Commit

Permalink
optimized module loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalguptaofficial committed Apr 4, 2019
1 parent 4cf2e25 commit 8cf240b
Show file tree
Hide file tree
Showing 91 changed files with 563 additions and 390 deletions.
474 changes: 305 additions & 169 deletions dist/fort.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/fort.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions dist/ts/abstracts/controller.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { HttpResponse } from "../types/http_response";
import { HttpRequest } from "../types/http_request";
import { FileManager } from "../models/file_manager";
import { HttpRequest, HttpResponse } from "../types";
import { CookieManager, FileManager } from "../models";
import { SessionProvider } from ".";
export declare abstract class Controller {
request: HttpRequest;
response: HttpResponse;
Expand Down
10 changes: 3 additions & 7 deletions dist/ts/abstracts/guard.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { Controller } from "./controller";
import { HttpResult } from "../types";
import { HttpRequest } from "../types/http_request";
import { HttpResponse } from "../types/http_response";
import { FileManager } from "../models/file_manager";
import { HttpRequest, HttpResponse, HttpResult } from "../types";
import { CookieManager, FileManager } from "../models";
import { SessionProvider, Controller } from ".";
export declare abstract class Guard implements Controller {
request: HttpRequest;
response: HttpResponse;
Expand Down
1 change: 1 addition & 0 deletions dist/ts/abstracts/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './session_provider';
export * from './guard';
export * from './view_engine';
export * from './wall';
export * from "./xml_parser";
4 changes: 2 additions & 2 deletions dist/ts/abstracts/session_provider.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CookieManager } from "../models/cookie_manager";
import { SessionValue } from "../types/session_value";
import { CookieManager } from "../models";
import { SessionValue } from "../types";
export declare abstract class SessionProvider {
sessionId: string;
protected cookie: CookieManager;
Expand Down
9 changes: 3 additions & 6 deletions dist/ts/abstracts/shield.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Controller } from "./controller";
import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { HttpResult } from "../types";
import { HttpRequest } from "../types/http_request";
import { HttpResponse } from "../types/http_response";
import { HttpRequest, HttpResponse, HttpResult } from "../types";
import { CookieManager } from "../models";
import { SessionProvider, Controller } from ".";
export declare abstract class Shield implements Controller {
request: HttpRequest;
response: HttpResponse;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/abstracts/view_engine.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewEngineData } from "../types/view_engine_data";
import { ViewEngineData } from "../types";
export declare abstract class ViewEngine {
abstract render(value: ViewEngineData): Promise<string>;
}
9 changes: 3 additions & 6 deletions dist/ts/abstracts/wall.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Controller } from "./controller";
import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { HttpResult } from "../types";
import { HttpRequest } from "../types/http_request";
import { HttpResponse } from "../types/http_response";
import { HttpRequest, HttpResponse, HttpResult } from "../types";
import { CookieManager } from "../models";
import { SessionProvider, Controller } from ".";
export declare abstract class Wall implements Controller {
request: HttpRequest;
response: HttpResponse;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/decorators/default_worker.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { HTTP_METHOD } from "../enums/http_method";
import { HTTP_METHOD } from "../enums";
export declare const DefaultWorker: (allowedMethods?: HTTP_METHOD[]) => MethodDecorator;
2 changes: 2 additions & 0 deletions dist/ts/enums/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './mime_type';
export * from './http_method';
export * from './http_status_code';
export * from "./etag_type";
export * from "./error_type";
1 change: 1 addition & 0 deletions dist/ts/extra/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './mustache_view_engine';
export * from "./memory_session_provider";
3 changes: 3 additions & 0 deletions dist/ts/generics/generic_controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Controller } from "../abstracts";
export declare class GenericController extends Controller {
}
5 changes: 5 additions & 0 deletions dist/ts/generics/generic_guard.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Guard } from "../abstracts";
import { HttpResult } from "../types";
export declare class GenericGuard extends Guard {
check(): Promise<HttpResult>;
}
14 changes: 14 additions & 0 deletions dist/ts/generics/generic_session_provider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SessionProvider } from "../abstracts";
import { SessionValue } from "../types";
import { CookieManager } from "../models";
export declare class GenericSessionProvider extends SessionProvider {
sessionId: string;
cookie: CookieManager;
get(): any;
getAll(): any;
set(key: any, value: any): any;
isExist(key: any): any;
remove(key: any): any;
setMany(values: SessionValue[]): Promise<null>;
clear(): Promise<void>;
}
5 changes: 5 additions & 0 deletions dist/ts/generics/generic_shield.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Shield } from "../abstracts";
import { HttpResult } from "../types";
export declare class GenericShield extends Shield {
protect(): Promise<HttpResult>;
}
5 changes: 5 additions & 0 deletions dist/ts/generics/generic_wall.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Wall } from "../abstracts";
import { HttpResult } from "../types";
export declare class GenericWall extends Wall {
onIncoming(): Promise<HttpResult>;
}
5 changes: 5 additions & 0 deletions dist/ts/generics/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './generic_guard';
export * from './generic_shield';
export * from './generic_session_provider';
export * from "./generic_wall";
export * from "./generic_controller";
11 changes: 4 additions & 7 deletions dist/ts/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/// <reference types="node" />
import * as http from "http";
import { GenericSessionProvider } from "./models/generic_session_provider";
import { GenericWall } from "./models/generic_wall";
import { ViewEngine } from "./abstracts/view_engine";
import { ErrorHandler } from "./models/error_handler";
import { EtagOption } from "./types/etag_option";
import { FolderMap } from "./types/folder_map";
import { XmlParser } from "./abstracts/xml_parser";
import { ErrorHandler } from "./models";
import { ViewEngine, XmlParser } from "./abstracts";
import { EtagOption, FolderMap } from "./types";
import { GenericSessionProvider, GenericWall } from "./generics";
export declare class Global {
static request: http.IncomingMessage;
static response: http.ServerResponse;
Expand Down
3 changes: 1 addition & 2 deletions dist/ts/handlers/controller_handler.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HttpResult } from "../types/http_result";
import { HttpResult, HttpFormatResult } from "../types";
import { FileHandler } from "./file_handler";
import { HttpFormatResult } from "../types";
export declare class ControllerHandler extends FileHandler {
private controllerResult_;
private getDataBasedOnMimeType_;
Expand Down
6 changes: 6 additions & 0 deletions dist/ts/handlers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from "./route_handler";
export * from "./request_handler";
export * from "./file_handler";
export * from "./request_handler_helper";
export * from "./controller_handler";
export * from "./post_handler";
2 changes: 1 addition & 1 deletion dist/ts/handlers/post_handler.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ControllerHandler } from "./controller_handler";
import { FileManager } from "../models/file_manager";
import { FileManager } from "../models";
export declare class PostHandler extends ControllerHandler {
protected body: any;
protected file: FileManager;
Expand Down
7 changes: 3 additions & 4 deletions dist/ts/handlers/request_handler_helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/// <reference types="node" />
import { MIME_TYPE, HTTP_METHOD } from "../enums";
import * as http from "http";
import { MIME_TYPE } from "../enums/mime_type";
import { HTTP_METHOD } from "../enums/http_method";
import { CookieManager } from "../models/cookie_manager";
import { Wall } from "../abstracts/wall";
import { CookieManager } from "../models";
import { Wall } from "../abstracts";
export declare class RequestHandlerHelper {
protected cookieManager: CookieManager;
protected response: http.ServerResponse;
Expand Down
7 changes: 2 additions & 5 deletions dist/ts/handlers/route_handler.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { RouteInfo } from "../types/route_info";
import { GenericShield } from "../models/generic_shield";
import { WorkerInfo } from "../types/worker_info";
import { GenericGuard } from "../models/generic_guard";
import { ParentRoute } from "../types/route";
import { RouteInfo, WorkerInfo, ParentRoute } from "../types";
import { GenericShield, GenericGuard } from "../generics";
export declare class RouteHandler {
static readonly routerCollection: RouteInfo[];
static addToRouterCollection(value: ParentRoute): void;
Expand Down
6 changes: 6 additions & 0 deletions dist/ts/helpers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ export * from './file_result';
export * from './redirect_result';
export * from './view_result';
export * from './get_view_from_file';
export * from "./promise";
export * from './log_helper';
export * from './xml_helper';
export * from "./get_mime_type_from_extension";
export * from "./parse_match_route";
export * from "./parse_cookie";
8 changes: 4 additions & 4 deletions dist/ts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './abstracts/index';
export * from './decorators/index';
export * from './abstracts';
export * from './decorators';
export * from './enums';
export * from './helpers/index';
export * from './models/index';
export * from './helpers';
export * from './models';
export * from './types';
export * from './extra';
2 changes: 2 additions & 0 deletions dist/ts/interfaces/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./http_cookie";
export * from "./exception";
2 changes: 1 addition & 1 deletion dist/ts/models/error_handler.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IException } from "../interfaces/exception";
import { IException } from "../interfaces";
export declare class ErrorHandler {
onServerError(ex: IException): Promise<string>;
onBadRequest(ex: IException): Promise<string>;
Expand Down
8 changes: 3 additions & 5 deletions dist/ts/models/fort.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/// <reference types="node" />
import { ParentRoute } from "../types/route";
import { Wall, ViewEngine, SessionProvider } from "../abstracts";
import { AppOption } from "../types";
import { ErrorHandler } from "./error_handler";
import { ParentRoute, AppOption } from "../types";
import { Wall, ViewEngine, SessionProvider, XmlParser } from "../abstracts";
import { ErrorHandler } from ".";
import * as http from "http";
import { XmlParser } from "../abstracts/xml_parser";
export declare class Fort {
routes: ParentRoute[];
walls: Array<typeof Wall>;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/models/generic_guard.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Guard } from "../abstracts/guard";
import { Guard } from "../abstracts";
import { HttpResult } from "../types";
export declare class GenericGuard extends Guard {
check(): Promise<HttpResult>;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/models/generic_session_provider.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SessionProvider } from "../abstracts";
import { SessionValue } from "../types/session_value";
import { SessionValue } from "../types";
import { CookieManager } from "./cookie_manager";
export declare class GenericSessionProvider extends SessionProvider {
sessionId: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/models/http_cookie.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IHttpCookie } from "../interfaces/http_cookie";
import { IHttpCookie } from "../interfaces";
export declare class HttpCookie implements IHttpCookie {
name: string;
value: string;
Expand Down
3 changes: 3 additions & 0 deletions dist/ts/models/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ export * from './error_handler';
export * from './http_cookie';
export * from './fort';
export * from './router';
export * from './cookie_manager';
export * from "./file_manager";
export * from "./http_file";
2 changes: 1 addition & 1 deletion dist/ts/models/router.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RouteInfo } from "../types/route_info";
import { RouteInfo } from "../types";
export declare class Router {
routes: RouteInfo[];
}
3 changes: 1 addition & 2 deletions dist/ts/types/app_option.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EtagOption } from "./etag_option";
import { FolderMap } from "./folder_map";
import { FolderMap, EtagOption } from ".";
export declare type AppOption = {
/**
* port at which app will listen, default - 4000
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/types/etag_option.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETag_Type } from "../enums/etag_type";
import { ETag_Type } from "../enums";
export declare type EtagOption = {
type: ETag_Type;
};
2 changes: 1 addition & 1 deletion dist/ts/types/http_format_result.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTTP_STATUS_CODE } from "../enums/http_status_code";
import { HTTP_STATUS_CODE } from "../enums";
export declare type HttpFormatResult = {
statusCode: HTTP_STATUS_CODE;
responseFormat?: {
Expand Down
5 changes: 2 additions & 3 deletions dist/ts/types/http_result.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HTTP_STATUS_CODE } from "../enums/http_status_code";
import { MIME_TYPE } from "../enums/mime_type";
import { FileResultInfo } from "./file_result_info";
import { HTTP_STATUS_CODE, MIME_TYPE } from "../enums";
import { FileResultInfo } from ".";
export declare type HttpResult = {
statusCode: HTTP_STATUS_CODE;
responseData: any;
Expand Down
9 changes: 8 additions & 1 deletion dist/ts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ export * from './view_engine_data';
export * from './http_request';
export * from './http_response';
export * from './route_info';
export * from './route';
export * from './parent_route';
export * from "./session_value";
export * from "./worker_info";
export * from "./etag_option";
export * from "./folder_map";
export * from "./multi_part_parse_result";
export * from "./file_result_info";
export * from "./route_match";
2 changes: 1 addition & 1 deletion dist/ts/types/multi_part_parse_result.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpFile } from "../models/http_file";
import { HttpFile } from "../models";
export declare type MultiPartParseResult = {
field: {
[key: string]: any;
Expand Down
5 changes: 5 additions & 0 deletions dist/ts/types/parent_route.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Controller } from "../abstracts";
export declare type ParentRoute = {
path: string;
controller: typeof Controller;
};
3 changes: 1 addition & 2 deletions dist/ts/types/route_info.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { WorkerInfo } from "./worker_info";
import { GenericShield } from "../models/generic_shield";
import { GenericController } from "../models/generic_controller";
import { GenericShield, GenericController } from "../generics";
export declare type RouteInfo = {
controller: typeof GenericController;
controllerName: string;
Expand Down
5 changes: 2 additions & 3 deletions dist/ts/types/route_match.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WorkerInfo } from "./worker_info";
import { GenericShield } from "../models/generic_shield";
import { GenericController } from "../models/generic_controller";
import { WorkerInfo } from ".";
import { HTTP_METHOD } from "../enums";
import { GenericController, GenericShield } from "../generics";
export declare type RouteMatch = {
controller: typeof GenericController;
actionInfo: WorkerInfo;
Expand Down
2 changes: 1 addition & 1 deletion dist/ts/types/worker_info.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTTP_METHOD } from "../enums";
import { GenericGuard } from "../models/generic_guard";
import { GenericGuard } from "../generics";
export declare type WorkerInfo = {
workerName: string;
methodsAllowed: HTTP_METHOD[];
Expand Down
10 changes: 5 additions & 5 deletions src/abstracts/controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { HttpResponse } from "../types/http_response";
import { HttpRequest } from "../types/http_request";
import { FileManager } from "../models/file_manager";
import { HttpRequest, HttpResponse } from "../types";
import { CookieManager, FileManager } from "../models";
import { SessionProvider } from ".";

export abstract class Controller {
request: HttpRequest;
response: HttpResponse;
Expand Down
11 changes: 3 additions & 8 deletions src/abstracts/guard.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import { SessionProvider } from "./session_provider";
import { CookieManager } from "../models/cookie_manager";
import { Controller } from "./controller";
import { HttpResult } from "../types";
import { HttpRequest } from "../types/http_request";
import { HttpResponse } from "../types/http_response";
import { FileManager } from "../models/file_manager";
import { HttpRequest, HttpResponse, HttpResult } from "../types";
import { CookieManager, FileManager } from "../models";
import { SessionProvider, Controller } from ".";

export abstract class Guard implements Controller {
request: HttpRequest;
Expand Down
3 changes: 2 additions & 1 deletion src/abstracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from './shield';
export * from './session_provider';
export * from './guard';
export * from './view_engine';
export * from './wall';
export * from './wall';
export * from "./xml_parser";
4 changes: 2 additions & 2 deletions src/abstracts/session_provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CookieManager } from "../models/cookie_manager";
import { CookieManager } from "../models";
import * as getUniqId from "uniqid";
import { Global } from "../global";
import { SessionValue } from "../types/session_value";
import { SessionValue } from "../types";

export abstract class SessionProvider {

Expand Down
Loading

0 comments on commit 8cf240b

Please sign in to comment.