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

vite-plugin-mock-server

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-mock-server - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

publish.sh

2

package.json
{
"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,

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