You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
import { MockMethod } from 'vite-plugin-mock'
|
|
export default [
|
|
{
|
|
url: '/api/login',
|
|
method: 'get',
|
|
response: ({ query }) => {
|
|
return {
|
|
code: 0,
|
|
data: {
|
|
token: 'sadw@fjdsfsdkfsd3g6ujhj8i54wdvu7un7sadsaa',
|
|
},
|
|
}
|
|
},
|
|
},
|
|
{
|
|
url: '/api/sendcode',
|
|
method: 'post',
|
|
timeout: 1500,
|
|
response: {
|
|
code: 0,
|
|
data: null,
|
|
message: 'success',
|
|
},
|
|
},
|
|
{
|
|
url: '/api/text',
|
|
method: 'post',
|
|
rawResponse: async (req, res) => {
|
|
let reqbody = ''
|
|
await new Promise((resolve) => {
|
|
req.on('data', (chunk) => {
|
|
reqbody += chunk
|
|
})
|
|
req.on('end', () => resolve(undefined))
|
|
})
|
|
res.setHeader('Content-Type', 'text/plain')
|
|
res.statusCode = 200
|
|
res.end(`hello, ${reqbody}`)
|
|
},
|
|
},
|
|
] as MockMethod[]
|
|
|