Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spinajs/http

Package Overview
Dependencies
Maintainers
1
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/http - npm Package Compare versions

Comparing version 2.0.14 to 2.0.19

8

lib/response-methods/file.d.ts
import * as express from 'express';
import { Response } from '../responses';
import { Row, FormatterOptionsArgs } from '@fast-csv/format';
export declare class FileResponse extends Response {

@@ -18,9 +17,2 @@ protected path: string;

}
export declare class CvsFileResponse<I extends Row, O extends Row> extends Response {
protected data: any;
protected filename: string;
protected options?: FormatterOptionsArgs<I, O> | undefined;
constructor(data: any, filename: string, options?: FormatterOptionsArgs<I, O> | undefined);
execute(_req: express.Request, res: express.Response): Promise<void>;
}
export declare class JsonFileResponse extends Response {

@@ -27,0 +19,0 @@ protected data: any;

32

lib/response-methods/file.js

@@ -29,3 +29,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonFileResponse = exports.CvsFileResponse = exports.FileResponse = void 0;
exports.JsonFileResponse = exports.FileResponse = void 0;
const exceptions_1 = require("@spinajs/exceptions");

@@ -36,3 +36,2 @@ const fs = __importStar(require("fs"));

const responses_1 = require("../responses");
const format_1 = require("@fast-csv/format");
const tempfile_1 = __importDefault(require("tempfile"));

@@ -70,31 +69,2 @@ class FileResponse extends responses_1.Response {

exports.FileResponse = FileResponse;
class CvsFileResponse extends responses_1.Response {
constructor(data, filename, options) {
super(null);
this.data = data;
this.filename = filename;
this.options = options;
}
async execute(_req, res) {
const csvStream = (0, format_1.format)(this.options);
const tempPath = (0, tempfile_1.default)('.cvs');
const file = await fs.promises.open(tempPath, 'w');
return new Promise((resolve, reject) => {
csvStream.pipe(file.createWriteStream()).on('end', () => {
file.close().then(() => {
res.download(tempPath, this.filename, (err) => {
if (err) {
reject(err);
}
else {
resolve();
}
fs.unlink(tempPath, null);
});
});
});
});
}
}
exports.CvsFileResponse = CvsFileResponse;
class JsonFileResponse extends responses_1.Response {

@@ -101,0 +71,0 @@ constructor(data, filename) {

2

lib/route-args/FromForm.d.ts

@@ -56,3 +56,3 @@ import { RouteArgs } from './RouteArgs';

}>;
protected parseCvs(path: string, options: any): Promise<unknown>;
protected parseCvs(path: string): Promise<unknown>;
}

@@ -59,0 +59,0 @@ export declare class FromFormField extends FromFormBase {

@@ -42,4 +42,4 @@ "use strict";

const di_1 = require("@spinajs/di");
const parse_1 = require("@fast-csv/parse");
const fs = __importStar(require("fs"));
const csv_1 = require("csv");
class FromFormBase extends RouteArgs_1.RouteArgs {

@@ -178,3 +178,3 @@ async parseForm(callData, param, req) {

}
const data = await this.parseCvs(sourceFile, param.Options);
const data = await this.parseCvs(sourceFile);
return {

@@ -187,7 +187,7 @@ CallData: Object.assign(Object.assign({}, callData), { Payload: {

}
async parseCvs(path, options) {
async parseCvs(path) {
const data = [];
return new Promise((res, rej) => {
fs.createReadStream(path)
.pipe((0, parse_1.parse)(options))
.pipe((0, csv_1.parse)())
.on('error', (err) => rej(err))

@@ -194,0 +194,0 @@ .on('data', (row) => data.push(row))

{
"name": "@spinajs/http",
"version": "2.0.14",
"version": "2.0.19",
"description": "framework HTTP module base on express.js",

@@ -53,9 +53,9 @@ "main": "lib/index.js",

"dependencies": {
"@spinajs/configuration": "^2.0.12",
"@spinajs/di": "^2.0.12",
"@spinajs/configuration": "^2.0.19",
"@spinajs/di": "^2.0.19",
"@spinajs/exceptions": "^2.0.12",
"@spinajs/internal-logger": "^2.0.12",
"@spinajs/log": "^2.0.14",
"@spinajs/reflection": "^2.0.14",
"@spinajs/validation": "^2.0.14",
"@spinajs/internal-logger": "^2.0.19",
"@spinajs/log": "^2.0.19",
"@spinajs/reflection": "^2.0.19",
"@spinajs/validation": "^2.0.19",
"compression": "^1.7.4",

@@ -65,4 +65,4 @@ "cookie-parser": "^1.4.5",

"cors": "^2.8.5",
"csv": "^6.2.0",
"express": "^4.17.1",
"fast-csv": "4.3.2",
"formidable": "^2.0.1",

@@ -79,3 +79,3 @@ "glob": "^7.1.4",

},
"gitHead": "81b84e0b70c385409a01e655412c48d021a96352"
"gitHead": "51e801176ecec955cbf1eb2d91e9f4740cb2b471"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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