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

@restroom-mw/files

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restroom-mw/files - npm Package Compare versions

Comparing version 0.12.3-d624e4f.0 to 0.12.3-f67e107.4

1

dist/actions.d.ts
export declare const DOWNLOAD = "download the {} and extract it into {}";
export declare const STORE_RESULT = "store {} in the file {}";

3

dist/actions.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DOWNLOAD = void 0;
exports.STORE_RESULT = exports.DOWNLOAD = void 0;
exports.DOWNLOAD = "download the {} and extract it into {}";
exports.STORE_RESULT = "store {} in the file {}";

@@ -27,2 +27,9 @@ "use strict";

const actions_1 = require("./actions");
/**
* `store 'myVariable' in the file 'myFolder'`
*
* Store the content of the variable `myVariable` in the filesystem at the path
* `myFolder` on the server
*/
const actions_2 = require("./actions");
exports.default = (req, res, next) => {

@@ -60,4 +67,27 @@ const rr = new core_1.Restroom(req, res);

}
if (zencode.match(actions_2.STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(actions_2.STORE_RESULT);
for (let i = 0; i < allPassOutputs.length; i += 2) {
const variable = result[allPassOutputs[i]];
const file = result[allPassOutputs[i + 1]];
if (variable && file) {
const variableJson = JSON.stringify(variable);
try {
const absoluteFile = path_1.default.resolve(file);
const absoluteFolder = path_1.default.dirname(absoluteFile);
fs_1.default.mkdirSync(absoluteFolder, { recursive: true });
fs_1.default.writeFileSync(absoluteFile, variableJson);
}
catch (e) {
next(e);
throw new Error(`[FILES] Error saving the result to "${file}": ${e}`);
}
}
else {
throw new Error(`[FILES] variable or destination folder not defined`);
}
}
}
}));
next();
};
{
"name": "@restroom-mw/files",
"version": "0.12.3-d624e4f.0+d624e4f",
"version": "0.12.3-f67e107.4+f67e107",
"description": "Utilities middleware to work with files for Restroom",

@@ -35,3 +35,3 @@ "author": "Alberto Lerda <alberto@dyne.org>",

},
"gitHead": "d624e4f957c02afccc835b6d400b3fa959c950f4"
"gitHead": "f67e107cdadae53b954f9d15011ed2d639acf854"
}
export const DOWNLOAD= "download the {} and extract it into {}";
export const STORE_RESULT= "store {} in the file {}";

@@ -17,3 +17,11 @@ import { Restroom } from "@restroom-mw/core";

import { DOWNLOAD } from "./actions";
/**
* `store 'myVariable' in the file 'myFolder'`
*
* Store the content of the variable `myVariable` in the filesystem at the path
* `myFolder` on the server
*/
import { STORE_RESULT } from "./actions";
export default (req: Request, res: Response, next: NextFunction) => {

@@ -52,2 +60,27 @@ const rr = new Restroom(req, res);

}
if (zencode.match(STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(STORE_RESULT);
for (let i = 0; i < allPassOutputs.length; i += 2) {
const variable = result[allPassOutputs[i]]
const file = result[allPassOutputs[i+1]]
if (variable && file) {
const variableJson = JSON.stringify(variable)
try {
const absoluteFile = path.resolve(file);
const absoluteFolder = path.dirname(absoluteFile);
fs.mkdirSync(absoluteFolder, { recursive: true });
fs.writeFileSync(absoluteFile, variableJson);
} catch (e) {
next(e);
throw new Error(`[FILES] Error saving the result to "${file}": ${e}`);
}
}
else {
throw new Error(`[FILES] variable or destination folder not defined`);
}
}
}
});

@@ -54,0 +87,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