Socket
Socket
Sign inDemoInstall

vweb-mvc

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vweb-mvc - npm Package Compare versions

Comparing version 1.1.23 to 1.1.24

13

lib/controller/index.js

@@ -65,8 +65,11 @@ "use strict";

if (rest)
return proxy[rest.json ? 'json' : 'send'](result);
return response[rest.json ? 'json' : 'send'](result);
if (result instanceof model_1.View) {
proxy[result.signature()](...result.getArg());
response[result.signature()](...result.getArg());
}
else if (result instanceof model_1.Download) {
response.download(result);
}
else if (result instanceof model_1.RestModel) {
proxy.json(result);
response.json(result);
}

@@ -89,6 +92,6 @@ else if (typeof result === 'string') {

}
proxy[method](path);
response[method](path);
}
else {
proxy.success(result);
response.success(result);
}

@@ -95,0 +98,0 @@ filterChain.complete(parameter, result, chainOptions);

@@ -0,1 +1,2 @@

import { Download } from "../model";
export default class Response {

@@ -9,2 +10,3 @@ readonly req: any;

send(model: any): void;
download({ content, filename }: Download): void;
json(model: any): void;

@@ -11,0 +13,0 @@ success(model: any): void;

@@ -25,2 +25,33 @@ "use strict";

}
download({ content, filename }) {
this.res.attachment(filename);
if (content instanceof URL) {
let { protocol } = content;
let url = content.toString();
if (/^http/.test(protocol)) {
let axios = require("axios");
axios.get(url, {
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}`,
}
}).then(({ data }) => {
this.res.send(data);
}).catch(err => {
this.res.send(err.message);
});
}
else {
try {
this.res.download(decodeURIComponent(url), filename);
}
catch (e) {
this.logger.error(e);
this.res.send('');
}
}
}
else {
this.res.send(content);
}
}
json(model) {

@@ -27,0 +58,0 @@ this.res.json(model);

/// <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 } from "./model";
import { Fail, Forward, Redirect, RestModel, Success, View, Download } from "./model";
import { HttpInterceptor } from "./interceptor";

@@ -29,6 +29,7 @@ import { FilterAdapter } from "./controller/filter";

Forward: typeof Forward;
Download: typeof Download;
};
declare const SUCCESS: Success;
declare const FAIL: Fail;
export { SUCCESS, FAIL, Request, Response, Get, Post, Put, Delete, Scope, Param, HttpInterceptor, Fail, Success, RestModel, View, Redirect, Forward, FilterAdapter, Filter, Validator, Controller, Interceptor, model, annotation, };
export { SUCCESS, FAIL, Request, Response, Get, Post, Put, Delete, Scope, Param, HttpInterceptor, Fail, Success, RestModel, View, Redirect, Forward, Download, FilterAdapter, Filter, Validator, Controller, Interceptor, model, annotation, };
declare global {

@@ -35,0 +36,0 @@ const mvc: ControllerAdapter;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.annotation = exports.model = exports.Interceptor = exports.Controller = exports.Validator = exports.Filter = exports.FilterAdapter = exports.Forward = exports.Redirect = exports.View = exports.RestModel = exports.Success = exports.Fail = exports.HttpInterceptor = exports.Param = exports.Scope = exports.Delete = exports.Put = exports.Post = exports.Get = exports.Response = exports.Request = exports.FAIL = exports.SUCCESS = void 0;
exports.annotation = exports.model = exports.Interceptor = exports.Controller = exports.Validator = exports.Filter = exports.FilterAdapter = exports.Download = exports.Forward = exports.Redirect = exports.View = exports.RestModel = exports.Success = exports.Fail = exports.HttpInterceptor = exports.Param = exports.Scope = exports.Delete = exports.Put = exports.Post = exports.Get = exports.Response = exports.Request = exports.FAIL = exports.SUCCESS = void 0;
const index_1 = require("./controller/index");

@@ -25,2 +25,3 @@ const anno_1 = require("./anno");

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");

@@ -52,3 +53,3 @@ Object.defineProperty(exports, "HttpInterceptor", { enumerable: true, get: function () { return interceptor_1.HttpInterceptor; } });

exports.annotation = annotation;
const model = { Fail: model_1.Fail, Success: model_1.Success, RestModel: model_1.RestModel, View: model_1.View, Redirect: model_1.Redirect, Forward: model_1.Forward };
const model = { Fail: model_1.Fail, Success: model_1.Success, RestModel: model_1.RestModel, View: model_1.View, Redirect: model_1.Redirect, Forward: model_1.Forward, Download: model_1.Download };
exports.model = model;

@@ -55,0 +56,0 @@ const SUCCESS = new model_1.Success();

@@ -0,1 +1,2 @@

/// <reference types="node" />
export declare class RestModel {

@@ -35,1 +36,6 @@ constructor();

}
export declare class Download {
readonly filename: string;
readonly content: Buffer | string | URL;
constructor(filename: string, content: Buffer | string | URL);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Redirect = exports.Forward = exports.View = exports.Success = exports.Fail = exports.RestModel = void 0;
exports.Download = exports.Redirect = exports.Forward = exports.View = exports.Success = exports.Fail = exports.RestModel = void 0;
class RestModel {

@@ -83,1 +83,8 @@ constructor() {

exports.Redirect = Redirect;
class Download {
constructor(filename, content) {
this.filename = filename;
this.content = content;
}
}
exports.Download = Download;
{
"name": "vweb-mvc",
"version": "1.1.23",
"version": "1.1.24",
"description": "mvc ",

@@ -34,2 +34,3 @@ "main": "./lib/index",

"@types/node": "^16.11.12",
"axios": "^1.1.3",
"babel-plugin-transform-decorators-legacy": "^1.3.5",

@@ -36,0 +37,0 @@ "connect-redis": "^6.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc