Skip to content

Repository files navigation

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.

PropertyTypeMandatoryDescriptionDefault
dbFilestringOptionalThe database file location. e.g: public/raw.jsondb.json
dbDataPathstringOptionalThe root path to serve inside the databse file. e.g: /data/
apiRoutePrefixstringOptionalThe global prefix of the api. e.g: /apiV1/api
routesRouteConfigOptionalThe routing configuration.GET: Accept:all / POST: Reject:all
versionstringRequiredThe version of the configuration. Curent: 0.0.1

Describe RouteConfig

Note: We use path-to-regExp:6.2.1 to validate expression.
PropertyTypeMandatoryDescription
postPostApi[]OptionalThe list of route configuration for post request.
getstring[]OptionalThe list of get route regExp to authorize.

Describe PostApi

PropertyTypeMandatoryDescription
pathstringRequiredThe path expression for the desired route
scheduleNotificationPostNotificationOptionalThe a notification configuration if the current end point have to notify server like payment end point.
bodyFieldsRecord<string, boolean>OptionalDecribe the body of incoming request. It's a record of authorized field name as key and mandatory as value.
restrictedBodybooleanOptionalRestrict body to the defined body field. Default: false

Describe PostNotification

PropertyTypeMandatoryDescription
followPropstringRequiredThe body field of the incoming request which contain the url to notify
timeoutInSecondnumberOptionalThe delay before sending notification to the provided url. Default: 60
notificationMethodenum {'POST', 'GET'}OptionalThe method to use to notify the end point provided in the value of followProp. Default: GET
postDataPathstringOptionalThe 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

About

A simple json API that provides predefined data for testing.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages