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

vite-plugin-fake-server

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.0.2 to 2.0.0-beta.0

4

package.json
{
"name": "vite-plugin-fake-server",
"version": "1.0.2",
"version": "2.0.0-beta.0",
"type": "module",

@@ -50,5 +50,5 @@ "license": "MIT",

"dependencies": {
"bundle-require": "^4.0.2",
"chokidar": "^3.5.3",
"fast-glob": "^3.3.1",
"import-from-string": "^0.0.3",
"path-to-regexp": "^6.2.1",

@@ -55,0 +55,0 @@ "picocolors": "^1.0.0",

@@ -15,3 +15,3 @@ # Vite-plugin-fake-server

- ESM first.
- Support `ts`, `js`, `mjs` files.
- Support `ts`, `js`, `mjs`, `cjs`, `cts`, `mts` files.
- Support multiple response methods —— [responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).

@@ -50,3 +50,3 @@ - Support custom response headers.

By default, it is only valid in the development environment (`enableDev = true`), and monitors in real time (`watch = true`) all `ts`, `js`, `mjs` files in the mock folder under the current project. When the browser has For the real requested link, the terminal will automatically print the requested URL (Vite's `logLevel = "info"` and `clearScreen = true`).
By default, it is only valid in the development environment (`enableDev = true`), and monitors in real time (`watch = true`) all `xxx.fake.{ts,js,mjs,cjs,cts,mts}` files in the fake(`include = fake`) folder under the current project. When the browser has For the real requested link, the terminal will automatically print the requested URL (`logger = true`).

@@ -82,3 +82,3 @@ ## Examples

### In `.ts` file
### In `xxx.fake.ts` file

@@ -102,3 +102,3 @@ ```ts

{
url: "/mock/get-user-info",
url: "/api/get-user-info",
response: () => {

@@ -126,3 +126,3 @@ return adminUserInfo;

### In `.js` file
### In `xxx.fake.js` file

@@ -133,3 +133,3 @@ ```javascript

{
url: "/mock/esm",
url: "/api/esm",
response: ({ query }) => {

@@ -140,3 +140,3 @@ return { format: "ESM", query };

{
url: "/mock/response-text",
url: "/api/response-text",
response: (_, req) => {

@@ -147,3 +147,3 @@ return req.headers["content-type"];

{
url: "/mock/post",
url: "/api/post",
method: "POST",

@@ -157,7 +157,7 @@ response: ({ body }) => {

### In `.mjs` file
### In `xxx.fake.mjs` file
```javascript
export default {
url: "/mock/mjs",
url: "/api/mjs",
method: "POST",

@@ -181,5 +181,5 @@ statusCode: 200,

Type: `string`\
Default: `"mock"`
Default: `"fake"`
Set the folder where the mock/fake `ts`, `js`, `mjs` files is stored.
Set the folder where the fake `xxx.fake.{ts,js,mjs,cjs,cts,mts}` files is stored.

@@ -195,2 +195,9 @@ ##### exclude

##### infixName
Type: `string | boolean`\
Default: `"fake"`
Set the infix name used in the fake file name.
##### watch

@@ -203,8 +210,25 @@

##### logger
Type: `boolean`\
Default: `true`
Set whether to display the request log on the console.
In order to maintain logs and screen clearing strategies consistent with Vite style on the terminal, the vite-plugin-fake-server plugin will automatically read the following three parameters in the Vite configuration file or in the Vite command line.
- [loglevel](https://vitejs.dev/config/shared-options.html#loglevel)
- [customlogger](https://vitejs.dev/config/shared-options.html#customlogger)
- [clearScreen](https://vitejs.dev/config/shared-options.html#clearScreen)
A preview image:
![shapes at 23-10-24 15 23 18](https://github.com/condorheroblog/vite-plugin-fake-server/assets/47056890/a6b11fcb-ee30-40a5-9beb-b1d9a0a51b39)
##### extensions
Type: `string[]`\
Default: `["ts", "js", "mjs"]`
Default: `["ts", "js", "mjs", "cjs", "cts", "mts"]`
Set the mock files extensions.
Set the fake files extensions.

@@ -250,3 +274,3 @@ ##### timeout

> ⚠️ The node module cannot be used in the mock file, otherwise the production environment will fail.As an alternative to keep consistent with the development environment, you can build a standalone deployment server, see [build option](https://github.com/condorheroblog/vite-plugin-fake-server#build).
> ⚠️ The node module cannot be used in the fake file, otherwise the production environment will fail.As an alternative to keep consistent with the development environment, you can build a standalone deployment server, see [build option](https://github.com/condorheroblog/vite-plugin-fake-server#build).

@@ -284,3 +308,3 @@ Compared with the development environment, the API interface defined in the production environment does not have a `rawResponse` function. The response function does not have the second parameter `request` and the third parameter `response`.

* directory exists, it will be removed before the build.
* @default "mockServer"
* @default "fakeServer"
*/

@@ -291,14 +315,2 @@ outDir?: string;

#### Shared Options
In order to maintain logs and screen clearing strategies consistent with Vite style on the terminal, the vite-plugin-fake-server plugin will automatically read the following three parameters in the Vite configuration file or in the Vite command line.
- [loglevel](https://vitejs.dev/config/shared-options.html#loglevel)
- [customlogger](https://vitejs.dev/config/shared-options.html#customlogger)
- [clearScreen](https://vitejs.dev/config/shared-options.html#clearScreen)
A preview image:
![shapes at 23-10-24 15 23 18](https://github.com/condorheroblog/vite-plugin-fake-server/assets/47056890/a6b11fcb-ee30-40a5-9beb-b1d9a0a51b39)
## Principle

@@ -305,0 +317,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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