New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rapid.js

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rapid.js

  • 0.0.3
  • Source
  • npm
  • Socket score

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

A Fluent Interface To Rapidly Interact With APIs Create simple, resusable, and cleaner wrappers and interfaces for your API requests.

This is the first release of rapid and it is still in development. Please report any bugs to the github page.

Read the official docs at http://rapidjs.io.

Define Simple Models

var Post = new Rapid({ modelName: 'Post' });

Post.find(1).then((response) => {
    // GET => /api/post/1
});

Post.collection.findBy('category', 'featured').then((response) => {
    // GET => /api/posts/category/featured
});

Post.withParams({ limit: 20, order: 'desc' }).all().then((response) => {
    // GET => /api/posts?limit=20&order=desc
});

Post.update(25, { title: 'Rapid JS Is Awesome!' })
    // POST => /api/posts/25/update

Post.destroy(9)
    // POST => /api/posts/9/destroy

Easily Customize Your API Requests

var Post = new Rapid({
    modelName: 'Post',
    suffixes: {
        destroy: '',
        update: 'save'
    },
    methods: {
        destroy: 'delete'
    },
    trailingSlash: true
 });

Post.update(25, { title: 'Rapid JS Is Awesome!' })
    // POST => /api/posts/25/save/

Post.destroy(9)
    // DELETE => /api/posts/9/

Create Reusable Base Models

class Base extends Rapid {
    boot () {
        this.baseURL = 'https://myapp.com/api';
        this.config.globalParameters = { key: 'MY_API_KEY' }
    }
}

var Photo = new Base({ modelName: 'Photo' });
var Gallery = new Base({ modelName: 'Gallery' });
var Tag = new Base({ modelName: 'Tag' });

Photo.find(1)
    // GET => https://myapp.com/api/photo/1?key=MY_API_KEY

Tag.collection.findBy('color', 'red')
    // GET => https://myapp.com/api/tags/color/red?key=MY_API_KEY

Gallery.id(23).get('tags', 'nature')
    // GET => https://myapp.com/api/gallery/23/tag/nature?key=MY_API_KEY

Write API Wrappers For Your Endpoints

class GalleryWrapper extends Rapid {
    boot () {
        this.baseURL = 'https://myapp.com/gallery/api';
        this.modelName = 'Gallery';
    }

    tagSearch (query) {
        return this.url('tagsearch').withParam('query', query);
    }

    json () {
        return this.url('json');
    }
}

var Gallery = new GalleryWrapper({
    globalParameters: { key: 'MY_API_KEY' }
});

Gallery.tagSearch('nature').json().get().then(...);
    // GET https://myapp.com/gallery/api/tagsearch/json?query=nature&key=MY_API_KEY

Read the official docs at http://rapidjs.io.

FAQs

Package last updated on 04 Apr 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