
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
vite-plugin-es6-mock
Advanced tools
Support vite mock data, use es6-mock to mock data.
Install with npm:
$ npm install --save-dev vite-plugin-es6-mock
// es6-mock config default param: { path: '/mock', dir: './mock' }
import vitePluginMock from 'vite-plugin-es6-mock';
export default defineConfig({
server: {
port: 8088,
},
plugins: [vitePluginMock()]
});
// es6-mock config dir and path
import vitePluginMock from 'vite-plugin-es6-mock';
export default defineConfig({
plugins: [vitePluginMock({ path: '/mockjs', dir: './mockjs'})]
});
Make a new file test.js in the config dir.
// Import lib
import path from 'path';
import fs from 'fs';
import { delay, validate, request } from 'es6-mock';
// Import other mock datas
import test1 from './test1';
import test2 from './test2';
// Delay response 500ms
delay(500);
// Validate request ďźIf validate failed, will return validate messages as responseďź
validate({
// Validate header required
header: {
'Cache-Control': 'required|equals:no-cache',
cookie: {
_gid: 'required'
},
},
// Validate param requiredă type or format
param: {
name: 'required|string',
id: 'required|integer'
},
// Validate request method
method: 'get|post'
});
// Export mock dataďźif validate pass
export default {
// Use mockjs data template
'code|1-10': '0',
data: {
"switch|1-2": true,
name: 'test03.js',
// Use other mock data. This will very useful in large data content
test1,
test2,
// Get request get param
param: request.query,
// Get request post param
param2: request.body,
// Support node various operations
existTest1: fs.existsSync(path.join(__dirname, 'test1.js')),
existTest0: fs.existsSync(path.join(__dirname, 'no-exist.js'))
}
};
Start your vite, then you can get the mock content through the URL: http://localhost:8088/test
FAQs
vite mock data
The npm package vite-plugin-es6-mock receives a total of 0 weekly downloads. As such, vite-plugin-es6-mock popularity was classified as not popular.
We found that vite-plugin-es6-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: whatâs affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.