rapid js - An ORM-like Interface For Your Frontend Requests.

An ORM-like Interface and a Router For Your API Requests

Create simple, resusable, and cleaner wrappers, define custom routes, and more for your API requests.

Get Started

Define Simple Models

                            
                                const 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

                            
                                const 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' }
                                    }
                                }

                                const photo = new Base({ modelName: 'Photo' });
                                const gallery = new Base({ modelName: 'Gallery' });
                                const 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');
                                    }
                                }

                                const 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