Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

miraze

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miraze

Quickly create RESTful http stubs.

  • 1.0.4
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Miraze

  • This is a framework for quickly stubbing a RESTful service.
  • Defining a webserver purely on basis of request/response json contracts.
  • Parsing JSON templates, based on request body/path/query params.

JSO-NG

  • JSO-NG is a templating language for serving json content. \
  • It extends the notion of compiling html templates to json.

So what can you do with this ?

You can use this to quickly setup a web-server that can stub a RESTful remote server.

A sample script :

var miraze     = require("./miraze").create();
miraze.post("/user").sendFile("../sample/create.json");
miraze.get("/user/:id").sendFile("../sample/request-path-param.json");
miraze.get("/user").sendFile("../sample/request-url-param.json");

miraze.app.listen(3000, function () {
 console.log('Example app listening on port 3000!');
});

Using expressions in JSO-NG

Given a hello.json is :

{
  "body": {
    "message": "hello",
    "id": "{{0 + 1 }}"
  }
}

And following url mapping is declared

miraze.post("/user").sendFile("../sample/hello.json")

Then making a GET request to '/user' results in :

{
   "message": "hello",
   "id": "1"
}

Using request path parameters

Given we declare following url :

 miraze.get("/user/:id").sendFile("../sample/request-path-param.json");

and request-path-param.json is :

{
  "body": {
    "id"      :"{{request.path.id}}",
    "name"    : "someone"
  }
}

Then if a request is made to url "user/101", above template renders to :

{
  "id": "101",
  "name": "someone"
}

Using request url params in response :

Given we declare following url :

miraze.get("/user").sendFile("../sample/request-url-param.json");

and request-url-param.json is :

{
  "body": {
    "search"  :"{{request.query.search}}",
    "page"   : "{{request.query.page}}",
    "size"   : "{{request.query.size}}"
  }
}

Then if a request is made to url "/user?search=searchme&page=32&size=21"; the above template renders to :

{
    "search": "searchme",
    "page": "32",
    "size": "21"
}

Using request body in response :

Given we declare following url :

miraze.post("/user").sendFile("../sample/create.json");

and create.json is :

{
"body": {
  "id"      :"1",
  "name"    : "{{request.body.name}}",
  "address" : {
    "street" : "{{request.body.address.street}}"
    }
  }
}

And we make a POST request is made to url "/user" with below body :

{
    "name": "Me",
    "address": {
      "street" : "MyPlace"
    }
}

Then we get following reponse :

{
    "id": "1",
    "name": "Me",
    "address": {
        "street": "MyPlace"
    }
}

Coming up...

  • support response status (200, 201, 404..)
  • support for cookies
  • asynchronous actions in controller
  • services and dependency injection

Keywords

FAQs

Package last updated on 02 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc