couriourc
mock_server
TypeScript

Simple Mock JSON Server

Last updated Jun 10, 2026
76
Stars
3
Forks
0
Issues
0
Stars/day
Attention Score
13
Language breakdown
No language data available.
β–Έ Files click to expand
README

SimpleMockServer


Demo | nightly builds | Example | wiki

GitHub Workflow Status Node version contributions welcome

Introduction

There is a most simple mock server use file organization, just drag your file, and rm your filename,and u got a server;

Direct use

Download the bin version ->

startup your download application,and it will auto create directories named static,apis, and then will start a server, Place the folder that requires Mock in the apis directory, and then start the service, where the api rule is, the directory determines the prefix,[apisuffix]. [apimethod] .json, where apisuffix represents the api path, apimethod represents the interception method, and supports get| post| patch| head| delete| option| put , this is just to keep the results consistent. Index.json is automatically intercepted here as/.

Features

  • Returns static JSON data
  • Returns based on interface information
  • Generated based on the Mock template, see http://mockjs.com/examples.html
Here, a {{}} writing similar to Vue is supported, and the replaced result is converted using Mockjs, which means that random data is generated through json. We provided the 'cookie', 'user-agent', 'headers', 'body', 'route', 'query', ' content-type',just like {{headers.contentType}} or {{query.key1}}

Example

PS D:\projects\mock_server> tree .\example\ /f
β”‚  .simple-mock.yaml
β”‚  [SimpleMockServer] your download application
β”œβ”€apis
β”‚  └─api
β”‚      β”‚  index.delete.json
β”‚      β”‚  index.get.json
β”‚      β”‚  index.json
β”‚      β”‚  index.option.json
β”‚      β”‚  index.patch.json
β”‚      β”‚  index.post.json
β”‚      β”‚  querybyentity.json
β”‚      β”‚
β”‚      └─index
β”‚              test.json
β”‚
β”œβ”€plugins
β”‚  └─peer-stream
β”‚      β”‚  index.js
β”‚      β”‚  package.json
β”‚      β”‚  pnpm-lock.yaml
β”‚      └─node_modules
└─static
        bootstrap.min.css
        index.html
        jquery.min.js
        normalize.css
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ index β”‚ url               β”‚ method β”‚ file                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚ api/              β”‚ delete β”‚ apis\api\index.delete.json  β”‚
β”‚     2 β”‚ api/              β”‚ get    β”‚ apis\api\index.get.json     β”‚
β”‚     3 β”‚ api/              β”‚ get    β”‚ apis\api\index.json         β”‚
β”‚     4 β”‚ api/              β”‚ option β”‚ apis\api\index.option.json  β”‚
β”‚     5 β”‚ api/              β”‚ patch  β”‚ apis\api\index.patch.json   β”‚
β”‚     6 β”‚ api/              β”‚ post   β”‚ apis\api\index.post.json    β”‚
β”‚     7 β”‚ api/querybyentity β”‚ get    β”‚ apis\api\querybyentity.json β”‚
β”‚     8 β”‚ api/index/test    β”‚ get    β”‚ apis\api\index\test.json    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

and you can fetch /api to access content of apis\api\index.delete.json

Plugins

We also offer a plugin system to extend it, I am writing wiki

Swagger

The Swagger plugin is pre-installed in the project and can be seen directly by visiting /swagger. image

❀️ Many thanks to Elysia for the handy and nice ui . https://github.com/elysiajs/elysia-swagger

Cors

Handles cross-domain issues and can give XHR direct access to Mock's APIs

all of plugins can configuration by set field plugins of .simple_mock.yaml

root_dir: .
api_dir: apis
static_dir: static
staticrouteprefix: /
port: 3000
silent:
errorlogfile_path: ./error.log
log_size: 10M
debuglogfile_path: ./debug.log
watch:
  • plugins:
  • swagger:
  • cors:
rewrites: - path: '' test: ^(index)$

Configuration

Please see source code ,[WIP]

Check list

  • [ x ] Plugin Loaded
  • [ x ] Support Static HTML to deploy
  • [ x ] Mock JSON by filename
  • [ ] WIKI

Thank You!

Help spread the Code Quality Love! ❀️
πŸ”— More in this category

Β© 2026 GitRepoTrend Β· couriourc/mock_server Β· Updated daily from GitHub