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

apit

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

apit

JSON/Object to REST API with zero effort

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

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

apit

JSON/Object to REST API with zero effort

npm package version npm downloads standard JS linter prettier code formatting travis ci build status project license make a pull request


Built with ❤︎ by tiaanduplessis and contributors

Table of Contents

Table of Contents
  • About
  • Install
  • Usage
  • Contribute
  • License
  • About

    The package takes json or plain object and turns it into a RESTful API server running on a given port (defaults to 8000).

    Install

    $ npm install apit
    # OR
    $ yarn add apit
    

    Or to use as CLI:

    $ npm -g install apit
    # OR
    $ yarn global add apit
    

    Usage

    const apit = require('apit')
    
    const data = {
      posts: {
        foo: {
          message: 'hello'
        }
      },
      other: 'foo',
      baz: [1,2,3],
      food: {
        steal: {
          healthy: true
        }
      }
    }
    
    apit(data)
    {"pid":54578,"hostname":"Tiaan-FF-Mac.local","name":"brewski","level":30,"time":1501775589826,"msg":"Server listening at http://localhost:3000","v":1}
    
    

    The above example will create the following routes with associated values:

    • / - {"posts":{"foo":{"message":"hello"}},"other":"foo","baz":[1,2,3],"food":{"steal":{"healthy":true}}}
    • /posts - {"foo":{"message":"hello"}}
    • /posts/foo - {"message":"hello"}
    • /posts/foo/message - "hello"
    • /other - "foo"
    • /baz - [1,2,3]
    • /food - {"steal":{"healthy":true}}
    • /food/steal - {"healthy":true}
    • /food/steal/healthy - true

    If you install the module globally, you can also use it with a json file or module that exports a object:

    apit --file=example.json
    # {"pid":56017,"hostname":"Tiaan-FF-Mac.local","name":"brewski","level":30,"time":1501776268494,"msg":"Server listening at http://localhost:8000","v":1}
    

    Contributing

    Contributions are welcome!

    1. Fork it.
    2. Create your feature branch: git checkout -b my-new-feature
    3. Commit your changes: git commit -am 'Add some feature'
    4. Push to the branch: git push origin my-new-feature
    5. Submit a pull request :D

    Or open up a issue.

    License

    Licensed under the MIT License.

    FAQs

    Package last updated on 03 Aug 2017

    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