Comparing version 1.2.2 to 1.2.3
@@ -52,3 +52,3 @@ export declare function Controller(name: any): (target: any, property: any) => void; | ||
} | ||
declare type ResponseType = 'json' | 'rest'; | ||
declare type ResponseType = 'json' | 'rest' | 'text' | 'csv' | 'xlsx'; | ||
export interface ResponseDescriber { | ||
@@ -55,0 +55,0 @@ readonly type: ResponseType; |
@@ -57,6 +57,5 @@ "use strict"; | ||
}); | ||
let value; | ||
try { | ||
parameterValidators[name] && parameter.validate(proxy, parameterValidators[name][method]); | ||
value = proxy[method].apply(proxy, parameter.getArgs()); | ||
let value = proxy[method].apply(proxy, parameter.getArgs()); | ||
if (value) { | ||
@@ -67,3 +66,3 @@ const end = result => { | ||
if (rest.type === 'rest') { | ||
return response.json(new model_1.Success(result)); | ||
return response.json(result instanceof model_1.RestModel ? result : new model_1.Success(result)); | ||
} | ||
@@ -73,2 +72,8 @@ else if (rest.type === 'json') { | ||
} | ||
else if (rest.type === 'xlsx') { | ||
if (!(result instanceof model_1.XlsxDownload)) { | ||
throw new Error(`【${name}#${method}】 If you want to download xlsx, please return value type use XlsxDownload`); | ||
} | ||
return response.send(result); | ||
} | ||
return response.send(result); | ||
@@ -75,0 +80,0 @@ } |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (value.length <= 16) { | ||
let val = value.indexOf('.') !== -1 ? parseFloat(value) : parseInt(value); | ||
let val = Number(value); | ||
if (val !== Infinity) | ||
@@ -25,0 +25,0 @@ return val; |
@@ -34,3 +34,3 @@ "use strict"; | ||
headers: { | ||
UserAgent: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.${Math.random() * 100} Safari/537.${Math.random() * 100}`, | ||
"User-Agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.${Math.random() * 100} Safari/537.${Math.random() * 100}`, | ||
} | ||
@@ -37,0 +37,0 @@ }).then(({ data }) => { |
@@ -38,4 +38,16 @@ /// <reference types="node" /> | ||
readonly filename: string; | ||
readonly content: Buffer | string | URL; | ||
constructor(filename: string, content: Buffer | string | URL); | ||
content: Buffer | string | URL | Array<any>; | ||
constructor(filename: string, content: Buffer | string | URL | Array<any>); | ||
} | ||
declare interface XlsxSheet { | ||
readonly name: string; | ||
readonly title?: string[]; | ||
readonly data: string[]; | ||
} | ||
export declare class XlsxDownload extends Download { | ||
readonly filename: string; | ||
readonly sheets: XlsxSheet[]; | ||
constructor(filename: string, sheets: XlsxSheet | XlsxSheet[]); | ||
private build; | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Download = exports.Redirect = exports.Forward = exports.View = exports.Success = exports.Fail = exports.RestModel = void 0; | ||
exports.XlsxDownload = exports.Download = exports.Redirect = exports.Forward = exports.View = exports.Success = exports.Fail = exports.RestModel = void 0; | ||
class RestModel { | ||
@@ -90,1 +90,24 @@ constructor() { | ||
exports.Download = Download; | ||
class XlsxDownload extends Download { | ||
constructor(filename, sheets) { | ||
super(filename, ''); | ||
this.filename = filename; | ||
this.sheets = Array.isArray(sheets) ? sheets : [sheets]; | ||
this.build(); | ||
} | ||
build() { | ||
let sheets = []; | ||
for (let { name, title, data } of this.sheets) { | ||
let list = []; | ||
if (title) | ||
list.push(title); | ||
list.push(...data); | ||
sheets.push({ | ||
name, | ||
data: list | ||
}); | ||
} | ||
this.content = require("node-xlsx").build(sheets); | ||
} | ||
} | ||
exports.XlsxDownload = XlsxDownload; |
{ | ||
"name": "vweb-mvc", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "mvc ", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68062
1778