Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helpscout/moxie
😘 Moxie: Create client side mock API endpoints
https://github.com/helpscout/moxie
api client-side generator javascript mock open-source
Last synced: about 2 months ago
JSON representation
😘 Moxie: Create client side mock API endpoints
- Host: GitHub
- URL: https://github.com/helpscout/moxie
- Owner: helpscout
- License: mit
- Created: 2019-02-01T00:36:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-08T20:23:32.000Z (almost 6 years ago)
- Last Synced: 2024-10-31T18:57:52.977Z (3 months ago)
- Topics: api, client-side, generator, javascript, mock, open-source
- Language: TypeScript
- Homepage:
- Size: 169 KB
- Stars: 3
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 😘 Moxie
[![Build Status](https://travis-ci.org/helpscout/moxie.svg?branch=master)](https://travis-ci.org/helpscout/moxie)
> Create client side mock API endpoints
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Thanks!](#thanks)## Installation
```
npm install --save-dev @helpscout/moxie
```## Usage
```js
import {createMoxie, createSchema, faker} from '@helpscout/moxie'// Define your schemas
const UserSchema = createSchema({
id: faker.random.uuid(),
name: faker.name.firstName(),
})// Create some initial state
const initialState = {
users: [
{
id: '123',
name: 'Randy Marsh',
},
],
}// Create the mock database
const moxie = createMoxie(
'users',
{
users: UserSchema,
},
initialState,
)// Make the "get" request!
moxie.get('users/123').then(response => {
console.log(response)
// {
// status: 200,
// statusText: 'OK',
// data: {
// id: '123',
// name: 'Randy Marsh',
// },
// headers: {
// 'Content-Type': 'application/json',
// },
// }
})
```## Thanks!
Thanks to [lowdb](https://github.com/lowdb/lowdb) for the database set up and to [@jmauerhan](https://github.com/jmauerhan) for picking the 😘 emoji for Moxie!