@@ -12,12 +12,12 @@ hero:
1212 - theme : brand
1313 text : Get Started
1414 link : /guide/getting-started
15- - theme : alt
16- text : View on GitHub
17- link : https://github.com/nDriaDev/vite-plugin-ws-rest-fs-api
1815 - theme : alt
1916 text : API Reference
2017 link : /api/
18+ - theme : alt
19+ text : View on GitHub
20+ link : https://github.com/nDriaDev/vite-plugin-ws-rest-fs-api
2121
2222features :
2323 - icon : 📁
@@ -57,61 +57,6 @@ features:
5757 details : Minimal footprint with no runtime dependencies. Works with Node 16+, Vite 4+.
5858---
5959
60- ## Quick Example
61-
62- ``` typescript
63- // vite.config.ts
64- import { defineConfig } from ' vite'
65- import mockApi from ' @ndriadev/vite-plugin-ws-rest-fs-api'
66-
67- export default defineConfig ({
68- plugins: [
69- mockApi ({
70- endpointPrefix: ' /api' ,
71- fsDir: ' mock' ,
72- enableWs: true ,
73- handlers: [
74- {
75- pattern: ' /users/{id}' ,
76- method: ' GET' ,
77- handle : async (req , res ) => {
78- const user = await db .findUser (req .params .id )
79- res .writeHead (200 , { ' Content-Type' : ' application/json' })
80- res .end (JSON .stringify (user ))
81- }
82- }
83- ],
84- wsHandlers: [
85- {
86- pattern: ' /ws/chat' ,
87- onMessage : (conn , msg ) => {
88- conn .broadcast (msg , { includeSelf: true })
89- }
90- }
91- ]
92- })
93- ]
94- })
95- ```
96-
97- ## Installation
98-
99- ::: code-group
100-
101- ``` bash [pnpm]
102- pnpm add -D @ndriadev/vite-plugin-ws-rest-fs-api
103- ```
104-
105- ``` bash [npm]
106- npm install -D @ndriadev/vite-plugin-ws-rest-fs-api
107- ```
108-
109- ``` bash [yarn]
110- yarn add -D @ndriadev/vite-plugin-ws-rest-fs-api
111- ```
112-
113- :::
114-
11560## Why This Plugin?
11661
11762Building modern web applications often requires mocking backend APIs during development. This plugin provides three complementary approaches:
0 commit comments