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

mockupccino

v1.1.0

Published

A REST/JSON simulation server

Downloads

9

Readme

Mockupccino - a REST/JSON server simulation tool

NPM version Build

License LGPL v3

##Overview Mockupccino is a REST/JSON server simulation tool which allow developers to test their REST clients.

Mockupccino doesn't require any intrusive configuration into your projects, just run Mockupccino with its configuration file and that's all. The main objective of Mockupccino is to prevent your projects from the risk of webservices connection bugs that could be caused by an intrusive faulty configuration. Its use was thought to be as simple as possible, you just have to create a file that describes how the REST webservice must respond and launch the Mockupccino server.

Particular case of projects that need CORS Headers:

If you are developping the front-end and back-end with different tools or the front-end files, in your dev environnement, are not accessible via the same domain (for ex. front-end on http://localhost:3000 and backend on http://localhost:9000 ), you may experience problems because your web browser will not allow you to access cross domain resources. As a solution, Mockupccino can work in 2 modes:

  1. CORS Headers mode: in that mode, Mockupccino will automatically set the right CORS headers in order to allow you to access the REST webservices.
  2. Serve static part mode: in that mode, Mockupccino will also serve the html, js and other files in your frontend as if everything was on the same test server.

Installation

Local install

npm install mockupccino

Global install

npm install -g mockupccino

Usage

Launching the server in a terminal

mockupccino <config file>

By default, if the <config file>parameter is not set, the mockupccino server will try to find a file named mockupccino-config.json in the current working directory. Please see the configuration file section, if you want to know how to setup the Mockupccino server.

Launching the server (within a project) with grunt

Currently, the best way to launch the Mockupccino server via grunt is to use the grunt-shell-spawn grunt module. Please see the grunt-shell-spawn module documentation in order to know how to install it. Then create a task (in your gruntfile) that should look like this:

shell: {
    mockupccino: {
        command: 'mockupccino <path to your config.json file> &',
        options: {
          async: true
        }
    }
}

##The configuration file The following example shows how the config file should look like:

JSON Format

{
    "global":{
        "port": 4000,
        "staticContent":[
            {
                "url": "/",
                "path": "/home/user/myProject/app"
            },
            {
                "url": "/styles",
                "path": "/home/user/myProject/.tmp/styles"
            }
        ]
    },
    "endpoints":[
        {
            "url": "/test1",
            "httpMethod": "GET",
            "loadSim": 5000,
            "response": {"msg":"Test1 OK", "ReturnCode":"200"}
        },
        {
            "url": "/test2",
            "httpMethod": "POST",
            "response":"Everything is OK"
        },
        {
            "url": "/test3",
            "httpMethod": "PUT",
            "response":{"msg":"Test 3 is ok also", "ReturnCode":"200"}
        },
        {
            "url": "/test4",
            "httpMethod": "DELETE",
            "responseFile": "/home/user/myProject/app/test/myTestObject.json"
        }
    ]
}

YAML Format

---
  global:
    port: 4000
    staticContent:
      - url: "/"
        path: "/home/user/myProject/app"

      - url: "/styles"
        path: "/home/user/myProject/.tmp/styles"

  endpoints:
    - url: "/test1"
      httpMethod: "GET"
      loadSim: 5000
      response:  {"msg":"Test1 OK", "ReturnCode":"200"}

    - url: "/test2"
      httpMethod: "POST"
      response: "Everything is OK"

    - url: "/test3"
      httpMethod: "PUT"
      response: {"msg":"Test 3 is ok also", "ReturnCode":"200"}

    - url: "/test4"
      httpMethod: "DELETE"
      responseFile: "/home/user/myProject/app/test/myTestObject.json"

In this file, you can find 2 main sections: the global section and the endpoints section.

The global section

In this section, you can set the server port and the staticContent that should served by the server.

  • port: (Mandatory) mockupccino server port
  • staticContent: (Optional) Array of path that should be served as soon as the given url is requested.

The endpointssection

This section is an array of the different endpoints that should be exposed by the server.

  • url: (Mandatory) endpoint's url exposed by the server
  • httpMethod: (Mandatory) endpoint's HTTP method
  • response: Response that Mockupcino should answer for a given url
  • responseFile: path of the file where the response is set.
  • loadSim: (Optional) Amount of milliseconds the Mockupccino server will wait in order to simulate a average server response time.

Pay attention, there should be at least, and no more than, one of the response* attribute.

##Future features

  1. Ability to configure the CORS Headers
  2. Ability to use a YAML/Swagger config file
  3. grunt/gulp module
  4. CLI interface for creating the config file