vweb-mvc
Advanced tools
Comparing version 1.2.6 to 1.2.7
import { HttpMessageConverter } from "./MessageConverter"; | ||
import { FilterRegulator } from "./filter"; | ||
import { VWebMvcConfig } from "../declare"; | ||
import VWebApplicationContext from "vweb-core/lib/VWebApp"; | ||
declare class ControllerAdapter { | ||
@@ -7,3 +9,3 @@ readonly logger: any; | ||
readonly express: any; | ||
readonly config: any; | ||
readonly config: VWebMvcConfig; | ||
readonly context: any; | ||
@@ -16,3 +18,3 @@ readonly controllers: any; | ||
readonly handlerMappings: Map<any, any>; | ||
constructor(context: any, express: any, config: any); | ||
constructor(context: VWebApplicationContext, express: any, config: VWebMvcConfig); | ||
init(): void; | ||
@@ -19,0 +21,0 @@ startup(): void; |
@@ -193,9 +193,13 @@ "use strict"; | ||
startup() { | ||
const { logger, context, express, config: { port = process.env.PORT || 3000 } } = this; | ||
const { logger, context, express, config: { port = process.env.PORT || 3000, cors = false } } = this; | ||
this.controllers.push(...context.getComponent(anno_1.Controller)); | ||
this.init(); | ||
if (cors) { | ||
express.options('*', (req, res, next) => { | ||
res.status(200).send('ok'); | ||
}); | ||
} | ||
express.use(function (req, res, next) { | ||
next(createError(404)); | ||
}) | ||
.use(function (err, req, res, next) { | ||
}).use(function (err, req, res, next) { | ||
res.locals.message = err.message; | ||
@@ -202,0 +206,0 @@ let { active = 'development' } = process.env; |
@@ -1,9 +0,7 @@ | ||
/// <reference types="node" /> | ||
import ControllerAdapter from "./controller/index"; | ||
import { Controller, Delete, Filter, Get, Interceptor, Param, Post, Put, Request, Response, Scope, Validator } from "./anno"; | ||
import { Fail, Forward, Redirect, RestModel, Success, View, Download } from "./model"; | ||
import { Download, Fail, Forward, Redirect, RestModel, Success, View } from "./model"; | ||
import { HttpInterceptor } from "./interceptor"; | ||
import { FilterAdapter } from "./controller/filter"; | ||
import { SessionConfig } from './session'; | ||
import { Config } from "vweb-core/lib/VWebApp"; | ||
import { VWebMvcConfig } from "./declare"; | ||
declare const annotation: { | ||
@@ -40,65 +38,2 @@ Controller: typeof Controller; | ||
} | ||
export declare interface VWebCookieConfig { | ||
secret?: string | string[]; | ||
options?: Object; | ||
} | ||
export declare interface Options { | ||
inflate?: boolean | undefined; | ||
limit?: number | string | undefined; | ||
type?: string | string[] | ((req: any) => any) | undefined; | ||
verify?(req: any, res: any, buf: Buffer, encoding: string): void; | ||
} | ||
export declare interface OptionsJson extends Options { | ||
reviver?(key: string, value: any): any; | ||
strict?: boolean | undefined; | ||
} | ||
export declare interface OptionsText extends Options { | ||
defaultCharset?: string | undefined; | ||
} | ||
export declare interface OptionsUrlencoded extends Options { | ||
extended?: boolean | undefined; | ||
parameterLimit?: number | undefined; | ||
} | ||
export declare interface OptionsXml extends Options { | ||
async?: boolean; | ||
explicitArray?: boolean; | ||
normalize?: boolean; | ||
normalizeTags?: boolean; | ||
trim?: boolean; | ||
} | ||
export declare interface ParserOptions { | ||
common?: Options; | ||
raw?: Options; | ||
xml?: OptionsXml; | ||
json?: OptionsJson; | ||
text?: OptionsText; | ||
urlencoded: OptionsUrlencoded; | ||
} | ||
export declare interface VWebMvcConfig extends Config { | ||
port?: number; | ||
options?: ParserOptions; | ||
view?: { | ||
engine?: string; | ||
root?: string; | ||
resource?: string; | ||
}; | ||
session?: false | SessionConfig; | ||
cookie?: VWebCookieConfig; | ||
multipart?: { | ||
maxFields?: number; | ||
maxFieldsSize?: number; | ||
maxFilesSize?: number; | ||
uploadDir?: string; | ||
encoding?: string; | ||
}; | ||
compress?: { | ||
filter?: (req: any, res: any) => {}; | ||
threshold?: number; | ||
chunkSize?: number; | ||
level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; | ||
memLevel: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; | ||
strategy: any; | ||
windowBits: any; | ||
}; | ||
} | ||
declare const _default: { | ||
@@ -105,0 +40,0 @@ name: string; |
@@ -19,2 +19,3 @@ "use strict"; | ||
const model_1 = require("./model"); | ||
Object.defineProperty(exports, "Download", { enumerable: true, get: function () { return model_1.Download; } }); | ||
Object.defineProperty(exports, "Fail", { enumerable: true, get: function () { return model_1.Fail; } }); | ||
@@ -26,3 +27,2 @@ Object.defineProperty(exports, "Forward", { enumerable: true, get: function () { return model_1.Forward; } }); | ||
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return model_1.View; } }); | ||
Object.defineProperty(exports, "Download", { enumerable: true, get: function () { return model_1.Download; } }); | ||
const interceptor_1 = require("./interceptor"); | ||
@@ -29,0 +29,0 @@ Object.defineProperty(exports, "HttpInterceptor", { enumerable: true, get: function () { return interceptor_1.HttpInterceptor; } }); |
{ | ||
"name": "vweb-mvc", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "mvc ", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
71007
28
1868