GithubHelp home page GithubHelp logo

mockapi's Introduction

Mock Api Logo

An other open source api for mocking json data with a bonus of end point notification.

Serve Data

Note: only public github repository is supported

Mockapi use the file '.mockapi.yml' from your repository as a configuration file.

Property Type Mandatory Description Default
dbFile string Optional The database file location. e.g: public/raw.json db.json
dbDataPath string Optional The root path to serve inside the databse file. e.g: /data /
apiRoutePrefix string Optional The global prefix of the api. e.g: /apiV1 /api
routes RouteConfig Optional The routing configuration. GET: Accept:all / POST: Reject:all
version string Required The version of the configuration. Curent: 0.0.1

Describe RouteConfig

Note: We use path-to-regExp:6.2.1 to validate expression.
Property Type Mandatory Description
post PostApi[] Optional The list of route configuration for post request.
get string[] Optional The list of get route regExp to authorize.

Describe PostApi

Property Type Mandatory Description
path string Required The path expression for the desired route
scheduleNotification PostNotification Optional The a notification configuration if the current end point have to notify server like payment end point.
bodyFields Record<string, boolean> Optional Decribe the body of incoming request. It's a record of authorized field name as key and mandatory as value.
restrictedBody boolean Optional Restrict body to the defined body field. Default: false

Describe PostNotification

Property Type Mandatory Description
followProp string Required The body field of the incoming request which contain the url to notify
timeoutInSecond number Optional The delay before sending notification to the provided url. Default: 60
notificationMethod enum {'POST', 'GET'} Optional The method to use to notify the end point provided in the value of followProp. Default: GET
postDataPath string Optional The database path to the notification data. Used only when the notificationMethod is 'POST'.
Note: When notificationMethod is POST postDataPath is defined and the desired data wasn't found in the database, null body will be posted to the notificationMethod.

API Reference

Once the database created, The base path of your end point would be https:mockapi.taurs.dev/:GITHUB_OWNER_ID/:REPO_NAME

Note: Your main branch should be one of ['main', 'dev', 'master']

E.g: Get List of predefined user.

  GET https://mockapi.taurs.dev/tadjaur/mockapi/api-1/user # api-1 here is the defined route prefix.

E.g: Get The first user of predefined users.

  GET https://mockapi.taurs.dev/tadjaur/mockapi/api-1/user/0

Usages

Acknowledgements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.