• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ’ An out of the box mock API server to help quickly create back-end prototype and data simulations.

logo

License Version Downloads Issues

Mokia

πŸ’ An out of the box mock API server to help quickly create back-end prototype and data simulations.

Documentation: δΈ­ζ–‡

Basic Usage

Create entry file (e.g. index.js):

// index.js
module.exports = {
  port: 3000,
  'GET /users'() {
    return this.list(() => ({ id: this.uuid(), name: this.fullName() }));
  },
  'GET /users/:id'(req) {
    return { id: req.params.id, name: this.fullName() };
  },
};

Start local http server:

npx mokia index.js --watch

Open browser and go to http://localhost:3000/users, you will get the response.

Advanced Usage

TypeScript Support and Class-style mock schema:

// index.ts

import mokia from 'mokia';

class User {
  @mokia.uuid()
  id: string;

  @mokia.fullName()
  name: string;

  constructor(id?: string) {
    if (id) this.id = id;
  }
}

class Article {
  @mokia.uuid()
  id: string;

  @mokia.generate(User)
  author: User;

  @mokia.passage()
  content: string;

  constructor(id?: string) {
    if (id) this.id = id;
  }
}

export default mokia.defineConfig({
  port: 3000,
  'GET /users': mokia.list(User),
  'GET /users/:id': (req) => new User(req.params.id),
  'GET /articles': mokia.list(Article),
  'GET /articles/:id': (req) => new Article(req.params.id),
});

License

MIT

More Repositories

1

varharrie.github.io

πŸ“˜ Personal blog site based on github issues.
TypeScript
3,644
star
2

react-hero

πŸ’Ό React toolkit.
TypeScript
41
star
3

vuex-action

πŸ”¨ Utilities for vuex to easily create and manage actions.
JavaScript
26
star
4

bright-ui

πŸ’Ž A set of components for React 16+.
TypeScript
25
star
5

fn

A lightweight file-based FaaS platform.
TypeScript
12
star
6

react-hero-form

A full-featured form component.
TypeScript
11
star
7

initialize_your_linux

Linuxε…₯坑鑻ηŸ₯。
10
star
8

angular-mdeditor

markdown editor for angular directive
HTML
5
star
9

simple_sandbox

Provides a simple sandbox environment to execute javascript code.
TypeScript
3
star
10

vue-store-lite

Simple state management for Vue based on reactive API.
TypeScript
2
star
11

passhub

πŸ”‘ A password manager built with React and Electron.
TypeScript
2
star
12

md2ubb

πŸ“ Simple script for conversion from markdown to ubb.
JavaScript
2
star
13

react-typescript-boilerplate

Simple and good development experience boilerplate project with React.
TypeScript
2
star
14

vue-inspector-plugin

A webpack plugin implements automatically open corresponding file in vscode when click element in browser.
TypeScript
2
star
15

vscode-import-beautify

✨ VSCode extension to help grouping and beautify import statments.
TypeScript
2
star
16

event-bus-station

🚌 Simple event bus.
TypeScript
1
star
17

ColorPicker

🎨 Color picker built with WPF.
C#
1
star
18

run-my-code

Execute javascript code from a string based on new function.
TypeScript
1
star
19

use-dragging

React hooks for dragging.
TypeScript
1
star
20

awesome-react-router

TypeScript
1
star
21

many-tabs

Tabs management extension.
1
star
22

vue-quick-preview

A lightweight lightbox.
Vue
1
star
23

vuemantic-ui

[🚫Deprecated] UI components build with vue1.0 and semantic-ui.
Vue
1
star
24

http-port-proxy

πŸ“‘ Http port proxying library.
TypeScript
1
star