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

dummy-json-route

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dummy-json-route

Serve up dummy JSON data at a URL endpoint based on a Dummy JSON template file

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

dummy-json-route

Purpose:

Serve up dummy JSON data at a URL endpoint based on a Dummy JSON template file

Command line Interface:

  • '-p :portNumber': Description: Port to serve data on (must be integer) Default: 9000

  • '-r :routeName': Description: Route to serve data on (must be string) Default: base route '/'

  • '-t :dataTemplateFilePath' Description: Path to Dummy JSON data file path OR a valid template string Default: A default template file that will be packaged with the module install

Example Commands:

Ex.1:

Serve up dummy data at http://localhost:9000/myDummyData from template file 'dummyData.hbs'

pc:~ rkalkur$ dummyjsonroute -p 9000 -r /myDummyData -t /myDataTemplates/dummyData.hbs


Ex.2:

Serve up dummy data at http://localhost:9000/person/:id/purchases from template file 'dummyPurchaseData.hbs'

pc:~ rkalkur$ dummyjsonroute -p 9000 -r /person/:id/purchases -t /myDataTemplates/dummyPurchaseData.hbs

Ex.3:

Serve up dummy data at http://localhost:9000/person/:id/purchases from template file 'dummyPurchaseData.hbs'

However, inject the URL parameters into the dummy data where they are specified in the given template file

pc:~ rkalkur$ dummyjsonroute -p 9000 -r /person/:id/purchases -t /myDataTemplates/dummyPurchaseData.hbs

dummyPurchaseData.hbs file contents:

{ 
	"id": {{ params.id }},
	"name": "Kleenex"
}

Then, if you issue an HTTP GET request to http://localhost:9000/person/1/purchases, you would get back the following response (in JSON format):

{	
	"id": 1,
	"name": "Kleenex"
}

If you want to pass non-numeric values in as URL parameters, you need to remember to wrap the property value in double-quotes within the template file.

For example, if you issue an HTTP GET request to http://localhost:9000/person/aq575uti00/purchases, the data template file would need to look like the following:

{ 
	"id": "{{ params.id }}",
	"name": "Kleenex"
}

FAQs

Package last updated on 17 May 2014

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