vite-plugin-mock-server
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "vite-plugin-mock-server", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Vite mock server plugin", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
declare module '@howiefh/ant-path-matcher' { | ||
export type DoMatchFunction = { | ||
(pattern: string, path: string, fullMatch: boolean, pathVars?: { [key: string]: string }): boolean | ||
} | ||
class AntPathMatcher { | ||
constructor() | ||
doMatch: DoMatchFunction | ||
doMatch(pattern: string, path: string, fullMatch: boolean, pathVars?: { [key: string]: string }): boolean | ||
} | ||
@@ -11,0 +6,0 @@ |
@@ -34,24 +34,25 @@ import { Plugin, ViteDevServer, Connect } from 'vite' | ||
export default (options?: MockOptions): Plugin => { | ||
// init options | ||
options = options || {} | ||
options.logLevel = options.logLevel || 'error' | ||
options.urlPrefixes = options.urlPrefixes || ['/api/'] | ||
options.mockRootDir = options.mockRootDir || './mock' | ||
options.mockJsSuffix = options.mockJsSuffix || '.mock.js' | ||
options.mockTsSuffix = options.mockTsSuffix || '.mock.ts' | ||
options.noHandlerResponse404 = options.noHandlerResponse404 || true | ||
if (options.mockModules && options.mockModules.length > 0) { | ||
console.warn('[' + PLUGIN_NAME + '] mock modules will be set automatically, and the configuration will be ignored', options.mockModules) | ||
} | ||
options.mockModules = [] | ||
LOG_LEVEL = options.logLevel | ||
// watch mock files | ||
watchMockFiles(options).then(() => { | ||
console.log('[' + PLUGIN_NAME + '] mock server started. options =', options) | ||
}) | ||
// build url matcher | ||
const matcher = new AntPathMatcher() | ||
return { | ||
name: PLUGIN_NAME, | ||
configureServer: async (server: ViteDevServer) => { | ||
// build url matcher | ||
const matcher = new AntPathMatcher() | ||
// init options | ||
options = options || {} | ||
options.logLevel = options.logLevel || 'error' | ||
options.urlPrefixes = options.urlPrefixes || ['/api/'] | ||
options.mockRootDir = options.mockRootDir || './mock' | ||
options.mockJsSuffix = options.mockJsSuffix || '.mock.js' | ||
options.mockTsSuffix = options.mockTsSuffix || '.mock.ts' | ||
options.noHandlerResponse404 = options.noHandlerResponse404 || true | ||
if (options.mockModules && options.mockModules.length > 0) { | ||
console.warn('[' + PLUGIN_NAME + '] mock modules will be set automatically, and the configuration will be ignored', options.mockModules) | ||
} | ||
options.mockModules = [] | ||
LOG_LEVEL = options.logLevel | ||
// watch mock files | ||
watchMockFiles(options).then(() => { | ||
console.log('[' + PLUGIN_NAME + '] mock server started. options =', options) | ||
}) | ||
server.middlewares.use(( | ||
@@ -58,0 +59,0 @@ req: Connect.IncomingMessage, |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
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
0
15035
7
241
1