@medux/dev-utils
Advanced tools
| import { NextFunction, Request, Response } from 'express'; | ||
| export declare function createMiddleware(mockFile: string): (req: Request, res: Response, next: NextFunction) => any; | ||
| export declare function createMiddleware(mockFile: string, databaseFile?: string): (req: Request, res: Response, next: NextFunction) => any; |
@@ -7,4 +7,3 @@ "use strict"; | ||
| const chalk = require("chalk"); | ||
| function createMiddleware(mockFile) { | ||
| console.info(`enable ${chalk.magenta('api mock')} file: ${chalk.underline(mockFile)}`); | ||
| function createMiddleware(mockFile, databaseFile) { | ||
| const mockDir = path.dirname(mockFile); | ||
@@ -17,2 +16,7 @@ if (!fs.existsSync(mockDir)) { | ||
| } | ||
| if (!databaseFile) { | ||
| const extname = path.extname(mockFile); | ||
| databaseFile = path.join(mockDir, `./database${extname}`); | ||
| } | ||
| console.info(`enable ${chalk.magenta('api mock')} \n api: ${chalk.underline(mockFile)} \n database: ${chalk.underline(databaseFile)}`); | ||
| return (req, res, next) => { | ||
@@ -46,2 +50,3 @@ const str = fs | ||
| if (mockPath) { | ||
| delete require.cache[databaseFile]; | ||
| delete require.cache[mockPath]; | ||
@@ -48,0 +53,0 @@ const middleware = require(mockPath); |
+1
-1
| { | ||
| "name": "@medux/dev-utils", | ||
| "version": "3.0.6", | ||
| "version": "3.0.7", | ||
| "description": "Common development tools.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/wooline/medux/tree/master/packages/dev-utils", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6934
4.19%118
4.42%