npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apimocka

v0.9.7

Published

Create quick hosted mock data from terminal

Downloads

16

Readme

Travis CI Build Status David Dependancy Status npm package npm package

Introduction

APImocka helps you create a quick hosted API server populated with mock data using the faker API.

This has many uses, including, but not limited to, quick prototyping, tests and/or simultaneously developing UI and backend API.

Features

  • Authenticate with the APImocka server.
  • deploy/delete mocks.
  • Run local version of mocks.

Table Of Content

Getting Started

Installation

# via npm
npm install -g apimocka
# via yarn
yarn global add apimocka

Authenticate

# register an account
apimocka register

#...
# login to your account
apimocka login

Create a Simple Mock config file

{
    "total": 5,
    "name": "trial",
    "routes": {
        "users": {
            "fullname": "name.firstName name.lastName",
            "avatar": "internet.avatar",
            "username": "internet.userName",
            "password": "internet.password"
        }
    }
}

save file as trialMock.json

To learn more about customizing your mock config file, check here

Deploy mock

apimocka deploy path/to/trialMock.json

Mock API

After creating a new mock, you get a personalized URL in the format:

https://mockd.co/{mockId}

Mock requests

All requests made to the mockd.co server must have the content-type header set to application/json

| Path (https://mockd.co/{projectId}) | Allowed Request type | Description |-----------------------------------------|-----------------------|--------------------------------- |/ | GET | fetches all mock information |/{route} | GET | fetches all data in specified route | | POST | Adds new data to route |/{route}/{id} | GET | Fetches data in specified index | | PUT | Replaces any specified field with new data | | DELETE | Delete specified index and all it's child contents |/{route}/verify | POST | Pass any object and verify if any match exists in specified route

Mock Configuration

A mock configuration file is used to specify mock settings, routes structure, and total number of data to mock for each route.

The mock data is generated using the faker API

Format: JSON or YAML

Sample

A simple configuration file looks like:

JSON format:

{
    "total": 5,
    "name": "trial",
    "routes": {
        "users": {
            "fullname": "name.firstName name.lastName",
            "avatar": "internet.avatar",
            "username": "internet.userName",
            "password": "internet.password"
        }
    }
}

YAML format:

---
total: 5
name: trial
routes:
  users:
    fullname: name.firstName name.lastName
    avatar: internet.avatar
    username: internet.userName
    password: internet.password

CLI Commands

Administrative commands

| Command | Description |------------------------|----------------------------- |register | Create a new APImocka account |login | Authenticate to your APImocka account |list | Show all your available mocks |deploy [configFile] | Create a new mock from config file |delete [mockId] | Delete an existing mock

Localization

| Command | Description |------------------------|------------------------------------- |localize [mockId] | Run a local version of existing mock