Mock server for vue-typecript-admin-template project
Demo (used by vue-typecript-admin-template)
The javascript code under api
folder in this project was generated from the typescript source code located at here (by running tsc
command in this directory). The only manually change is to rename the mock-server.js
to index.js
.
The url schema is based on Swagger config file and follows REST api standard.
info: {
name: 'Mock API',
description: 'Mock API for vue-typescript-admin-template.',
version: '1.0.0'
},
paths: {
get: [
'/mock-api/v1/articles',
'/mock-api/v1/articles/:id',
'/mock-api/v1/pageviews',
'/mock-api/v1/transactions',
'/mock-api/v1/roles',
'/mock-api/v1/routes',
'/mock-api/v1/users',
'/mock-api/v1/users/:username'
],
post: [
'/mock-api/v1/articles',
'/mock-api/v1/roles',
'/mock-api/v1/users/register',
'/mock-api/v1/users/login',
'/mock-api/v1/users/logout',
'/mock-api/v1/users/info'
],
put: [
'/mock-api/v1/articles/:id',
'/mock-api/v1/roles/:id',
'/mock-api/v1/users/:username'
],
delete: [
'/mock-api/v1/articles/:id',
'/mock-api/v1/roles/:id',
'/mock-api/v1/users/:username'
]
}
First install all dependencies:
yarn # OR npm install
Then you can set up the server:
yarn mock # OR npm run mock
or use the vercel dev
command.
This mock server is hosted by Vercel.
See CONTRIBUTING.md